This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Custom Editor Plugins

With a plugin system, customizing the Unigine editor for project-specific needs is very easy. After a script with custom functionality is coded, adding new tabs into the default windows or new editor modules, as well as changing a set of editor features for different projects is just a few clicks away.

To load editor plugins, choose Tools panel -> Plugins tab -> Add option. Plugins are saved and automatically loaded on the next application start-up.

Step 1. Create an Editor Plugin

A plugin is any *.cpp file written in UnigineScript language.

  1. An editor plugin should contain getName() function that returns an arbitrary namespace name for the plugin. Use this namespace for all created GUI elements and callbacks, or if you need to call plugin functions from outside a plugin namespace.
  2. To code plugin logic, implement init() and shutdown() functions. They will be called on editor initialization and shutdown, respectively.
  3. If necessary, implement also update() function that is called each frame while the editor is loaded. The engine passes to this function need_reload flag that indicates you may need to reload your custom resources. This flag is 1 when:
    • A world is loaded.
    • A world state is restored.
    • A new node is added to the editor.
    • A node is removed from the editor.
    • The editor releases its ownership of a node (for it to be handled from scripts).

Below is an example of a plugin that creates a simple titled window.

Source code (UnigineScript)
// editor_plugin.cpp

WidgetWindow window;

/*
 */
// This function should return your plugin namespace name.
string getName() {
	return "TestPlugin";
}

/*
 */
// Implement plugin initialization logic.
void init() {

	Gui gui = engine.getGui();
	
	window = new WidgetWindow(gui);
	window.setText("Title");
	window.setSizeable(1);
	window.setWidth(300);
	window.setHeight(300);
	gui.addChild(window,GUI_ALIGN_OVERLAP | GUI_ALIGN_CENTER);
	
	// If you want to call a plugin function from the outside, add a plugin namespace name.
	log.message("Plugin namespace: %s\n",call("TestPlugin::getName"));
}

/*
 */
// Implement plugin shutdown logic.
void shutdown() {
	Gui gui = engine.getGui();
	gui.removeChild(window);
	
	delete window;
	log.message("shut down");
}

/*
 */
// Implement plugin update logic.
void update(int need_reload) {
	
	// The flag of 1 indicates that the editor resources should be updated.
	if(need_reload) {
		// Update custom resources, if necessary.
	}
	
}

Step 2. Load Editor Plugins

To load the created editor plugin, all you need to do is:

  1. Open Tools panel.
  2. Go to Plugins tab.
  3. Click Add button.

The plugin will appear in a list. Multiple plugins can be loaded in editor runtime.

Step 3. Modify Editor Plugins

After the editor plugin is modified, you can quickly see changes in action:

  1. Select the plugin in the list of loaded ones.
  2. Click Reload button.
Last update: 2017-07-03
Build: ()