Paul.Brodin Posted February 11, 2015 Share Posted February 11, 2015 Weve got a nice little process going now for optimising the creation of new worlds in editor mode Can anyone tell me how to make a call back into the 'world'.cpp source code from the c# app iam trying to call engine.console.run("editor_quit"); but cant find a way of getting to this from the c# app Link to comment
Paul.Brodin Posted February 11, 2015 Author Share Posted February 11, 2015 actually this may not have been the correct question. all i really want to do is remove the editor ui. that would be fine, if having the editor loaded but not visible, doesnt hae any performance implications Link to comment
koshachy Posted February 12, 2015 Share Posted February 12, 2015 Hi Paul! If I have understood correctly your question, you need a callback for the console command run. If you want just to call a console command from C# code, do the following: Unigine.Console console = Unigine.Console.get(); console.run("editor_quit"); console.flush(); To call the C# function from UnigineScript, you should create the function and export it: static void QuitEditor() { // get the current console instance Unigine.Console console = Unigine.Console.get(); // execute the command console.run("editor_quit"); console.flush(); } [STAThread] static void Main(string[] args) { Wrapper.init(); // Export the QuitEditor function to UnigineScript Interpreter.addExternFunction("QuitEditor", new Interpreter.Function0(QuitEditor)); Engine engine = Engine.init(Engine.VERSION,args); engine.main(); Engine.shutdown(); } After that, just call the function in your world .cpp file: int init() { // your code // call the exported function QuitEditor(); return 1; } That's it! You can read this article to know more about callbacks in C#: https://developer.unigine.com/en/docs/1.0/csharp_api/usage/callbacks Here you can find special aspects of function exporting in C# API: https://developer.unigine.com/en/docs/1.0/csharp_api/reference/#export_functions Do not hesitate to ask any questions. :) Link to comment
Paul.Brodin Posted February 16, 2015 Author Share Posted February 16, 2015 Hi - yes that first code piece was all i was after! so thats removing the editor UI nicely. Now this may be a silly question, but with the editor UI removed, how do you move around the world - none of the keys or mouse mouses seem to have an affect. Thanks Paul Link to comment
unclebob Posted February 17, 2015 Share Posted February 17, 2015 Howdy! When you quit the editor, you can't use its functionality such as world navigation and many other useful features. So you have to handle world navigation by yourself, probably by creating PlayerActor or PlayerDummy in the world script. But what I want to suggest to you is instead of quitting the editor it's better to hide its interface and keep using its features. For that purposes we have a plugin called "Hide interface". In 2.0 it's available via top menu (Plugins -> Manage -> check "Hide Interface" to enable it). Press 'ctrl+h' to toggle the ui. In 1.0 it's available via tools window (tabs plugin, then core, then "Hide Interface" to enable it). Press 'v' button to toggle the ui. Link to comment
Paul.Brodin Posted February 25, 2015 Author Share Posted February 25, 2015 Hi there - yes that 'Hide Interface' plugin is ideal. is there any performance affects of having the editor 'loaded' but hidden? also - is it possible to call the Hide Interface from code? Link to comment
unclebob Posted February 25, 2015 Share Posted February 25, 2015 Yes, editor functionality will require some CPU time to manage its own internal state even if you turn UI off. It's possible to call such functionality from editor and even world script. Just have look at the bottom of core/editor/editor_tools.h file in Unigine 1.0 or editor/editor_plugins.h file in Unigine 2.0 and you'll find what you need. Don't forget that if you want to call that from world script, you have to use engine.editor.call instead of direct function call. Link to comment
Recommended Posts