This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Professional (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Landscape Tool
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World Nodes
Звуковые объекты
Объекты поиска пути
Players
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Materials and Shaders
Rebuilding the Engine Tools
GUI
Двойная точность координат
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Сэмплы материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::Plugin Class

Header: #include <UniginePlugin.h>

Unigine Plugin class allows loading a custom library dynamically at Unigine runtime.

Plugin Class

Members


virtual void * get_data ( ) #

Returns the plugin data.

Return value

Plugin data.

virtual const char * get_name ( ) #

Returns the name of the plugin.

Return value

Plugin name.

int get_order ( ) #

Returns the execution order of the plugin. Each plugin has its execution order, which determines the sequence in which plugin’s functions (update / postUpdate / render / shutdown) will be executed. The only exception is the init function as it is called just after loading the plugin.
Notice
Remember, when writing your own plugin, that requires interaction with other ones, specifying correct order value is required to avoid issues and ensure proper execution sequence. If in your case the order doesn't matter, set the default 0 value.

Return value

Plugin execution order.

virtual int getCompilationFlags ( ) const#

Returns the Unigine compilation flags.

Return value

Unigine compilation flags.

virtual void updatePhysics ( ) #

Engine calls this function before updating each physics frame.

virtual void gui ( ) #

Engine calls this function before gui each render frame.

virtual int init ( ) #

Engine calls this function on plugin initialization.

Return value

Returns 1 on success, or 0 if an error has occurred.

virtual bool loadWorld ( const XmlPtr & xml ) #

Engine calls this function on world loading.

Arguments

  • const XmlPtr & xml - Xml instance from which the data is to be loaded.

Return value

true on success; otherwise, false.

virtual void render ( ) #

Engine calls this function before rendering each render frame.

virtual bool saveState ( const StreamPtr & stream ) #

Engine calls this function on world saving.

Example using saveState() and restoreState() methods:

Source code (C++)
class MyPlugin: public Plugin
{
public:
	MyPlugin() {}
	virtual ~MyPlugin() {}

	const char *get_name() override { return "MyPlugin"; }

	
	// override method save/restore state
	virtual int saveState(const StreamPtr &stream) override { stream->writeInt(getValue()); return 1;}
	virtual int restoreState(const StreamPtr &stream) override { setValue(stream->readInt());  return 1;}
	
	void setValue(int v) { some_value = v; }
	int getValue() const { return some_value; }
	
private:
	int some_value = 0;
};

	//...
	
	MyPlugin * plugin = /*...*/;
	plugin->setValue(5);
	int v1 = plugin->getValue(); // v1 = 5;
	
	
	// save state
	BlobPtr blob_state = Blob::create();
	plugin->saveState(blob_state);
	
	// change state
	plugin->setValue(10);
	int v2 = plugin->getValue(); // v2 = 10;
	
	// restore state
	blob_state->seekSet(0);
	plugin->restoreState(blob_state);
	
	
	int v3 = plugin->getValue(); // v3 = 5; 
						
	//...

Arguments

  • const StreamPtr & stream - Stream, to which the current state is to be saved.

Return value

true on success; otherwise, false.

virtual int restoreState ( const StreamPtr & stream ) #

Engine calls this function on world restoring.

Example using saveState() and restoreState() methods:

Source code (C++)
class MyPlugin: public Plugin
{
public:
	MyPlugin() {}
	virtual ~MyPlugin() {}

	const char *get_name() override { return "MyPlugin"; }

	
	// override method save/restore state
	virtual int saveState(const StreamPtr &stream) override { stream->writeInt(getValue()); return 1;}
	virtual int restoreState(const StreamPtr &stream) override { setValue(stream->readInt());  return 1;}
	
	void setValue(int v) { some_value = v; }
	int getValue() const { return some_value; }
	
private:
	int some_value = 0;
};

	//...
	
	MyPlugin * plugin = /*...*/;
	plugin->setValue(5);
	int v1 = plugin->getValue(); // v1 = 5;
	
	
	// save state
	BlobPtr blob_state = Blob::create();
	plugin->saveState(blob_state);
	
	// change state
	plugin->setValue(10);
	int v2 = plugin->getValue(); // v2 = 10;
	
	// restore state
	blob_state->seekSet(0);
	plugin->restoreState(blob_state);
	
	
	int v3 = plugin->getValue(); // v3 = 5; 
						
	//...

Arguments

  • const StreamPtr & stream - Stream, from which the previously saved state is to be restored.

Return value

Returns 1 on success, or 0 if an error has occurred.

virtual int saveWorld ( const XmlPtr & xml ) #

Engine calls this function on world saving.

Arguments

  • const XmlPtr & xml - Xml instance to which the data is to be saved.

Return value

Returns 1 on success, or 0 if an error has occurred.

virtual int shutdown ( ) #

Engine calls this function on plugin shutdown.

Return value

Returns 1 on success, or 0 if an error has occurred.

virtual void swap ( ) #

Engine calls this function before swapping each render frame.

virtual void update ( ) #

Engine calls this function before updating each render frame.

void postUpdate ( ) #

Engine calls this function after updating each render frame.
Last update: 10.03.2022
Build: ()