paul.w Posted March 31, 2014 Share Posted March 31, 2014 Hi If I add objects by code (ObjectGUI_2) then run the game in editor and press save, I get two version of the ObjectGUI_2 and ObjectGUI_3 :( How to stop this? ObjectGui object_gui = add_editor(new ObjectGui(45.0f,35.0f)); Link to comment
azagniy Posted March 31, 2014 Share Posted March 31, 2014 Hi Paul. You have two ObjectGui nodes in a save state. The first ObjectGui node is a node in a world script. The world script knows about this node because you created it by "new" operator. Second node is node in editor script. The editor script knows about this node after "add_editor" function calling. If you need this node in editor just call "node_remove" function like this: ObjectGui object_gui = add_editor(node_remove(new ObjectGui(45.0f,35.0f))); See also: https://developer.unigine.com/en/docs/1.0/code/memory_management#editor Link to comment
paul.w Posted March 31, 2014 Author Share Posted March 31, 2014 Hi yingaz Once I add this code " ObjectGui object_gui = add_editor(node_remove(new ObjectGui(45.0f,35.0f))); " I get the following error see image: Thanks Paul Link to comment
azagniy Posted March 31, 2014 Share Posted March 31, 2014 Is your object creation in world script? If you code running in a editor script don't use "add_editor" function, just use the engine.editor.addNode() function.see also https://developer.unigine.com/en/docs/1.0/scripting/library/engine/engine.editor#engine.editor.addNode_Node Link to comment
paul.w Posted March 31, 2014 Author Share Posted March 31, 2014 Its running in a script (videoObject.cpp) that is called from the world script ObjectGui object_gui = add_editor(new ObjectGui(45.0f,35.0f)); object_gui.setPosition(Vec3(-39.6f,-20.0f,-12.0f)); object_gui.setMaterial("gui_base","*"); object_gui.setProperty("surface_base","*"); object_gui.setMaterialState("mode",2,0); object_gui.setBillboard(1); Gui gui = object_gui.getGui(); sprite_video = new WidgetSpriteVideo(gui,"data/all_unigine_newgame/videos/SQ001_SH0010_Fill_Up_01_High.ogv"); gui.addChild(sprite_video,GUI_ALIGN_EXPAND); How to change the above code so I don't use the add_editor ? Link to comment
paul.w Posted March 31, 2014 Author Share Posted March 31, 2014 this works ObjectGui object_gui = new ObjectGui(45.0f,35.0f); engine.editor.addNode(object_gui); BUT when I press exit the engine crashes :( Link to comment
paul.w Posted April 1, 2014 Author Share Posted April 1, 2014 Still not working for me I have this code now: ObjectGui object_gui = new ObjectGui(45.0f,35.0f); engine.editor.addNode(node_remove(object_gui)); But when I press "SAVE" in the editor I get two versions of the object! All I want to do is add some objects by code and some objects by the editor or both and save the scene. Link to comment
sebastianbah Posted April 2, 2014 Share Posted April 2, 2014 Hello paul.w,I'm afraid, that all the objects added to the editor will be saved into the .world file. So after world reloading engine creates all nodes from .world file and all the nodes defined in script.You can check it by saving SDK samples from the editor.To avoid this issue, you can check the nodes from script(by name, for example) and skip the nodes which already exist. The other way is to edit all objects from editor or from the script only. Link to comment
paul.w Posted April 3, 2014 Author Share Posted April 3, 2014 Is this the same for the Game Framework, if I make levels in the editor can I call the levels from code ? Link to comment
sebastianbah Posted April 3, 2014 Share Posted April 3, 2014 Hi,Could you please clarify what do you want to do?How do you want to interact with levels? Link to comment
paul.w Posted April 4, 2014 Author Share Posted April 4, 2014 Basically, is the main cpp file global ? I'm going to use scheduler to load levels. Link to comment
sebastianbah Posted April 4, 2014 Share Posted April 4, 2014 Hi,Could you describe what do you mean by "main.cpp"? Also, if you want to create something using scheduler, remember that it starts after init. Link to comment
paul.w Posted April 7, 2014 Author Share Posted April 7, 2014 the "project_name.cpp" this is created when you click "New Project" see screenshot! Link to comment
azagniy Posted April 9, 2014 Share Posted April 9, 2014 Hi Paul, the "project_name.cpp" is a main cpp world script file for the default "project_name.world" which automatically generated by "New project" browser function. This is a just sample world. If you are use a Game framework please see a level creation from Game framework editor https://developer.unigine.com/en/docs/1.0/scripting/scripts/game_framework/editor#level_creation. In the Game framework logic your custom world logic must be implemented in Level based class (see https://developer.unigine.com/en/docs/1.0/scripting/scripts/game_framework/editor#custom_level_logic). But you can't work with a editor while the game is running. It may cause the engine crush. Another way (Game framework hack) to work with a editor is a modify "framework/game/game_world_script.h" file and write your custom logic while editor is running (you can check editor running by engine.editor.isLoaded() function). This file is main world scrip logic for all Game framework levels. But be careful when changing logic and make sure that you can merged this file with new file version when it will be updated in a follow SDK. I hope my answer can help you Link to comment
Recommended Posts