This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
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
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Unigine.Plugin Class

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

Plugin Class

Members


virtual IntPtr GetData ( ) #

Returns the plugin data.

Return value

Plugin data.

virtual string GetName ( ) #

Returns the name of the plugin.

Return value

Plugin name.

int GetOrder ( ) #

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 void UpdatePhysics ( ) #

Engine calls this function before updating each physics frame.

virtual void Gui ( EngineWindowViewport window ) #

Engine calls this function before gui each render frame for the specified engine window viewport.

Arguments

virtual bool Init ( ) #

Engine calls this function on plugin initialization.

Return value

true on success, or false if an error has occurred.

virtual bool LoadWorld ( Xml xml ) #

Engine calls this function on world loading.

Arguments

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

Return value

true on success; otherwise, false.

virtual void Render ( EngineWindowViewport window ) #

Engine calls this function before rendering each render frame for the specified Engine window viewport.

Arguments

virtual bool SaveState ( Stream 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

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

Return value

true on success; otherwise, false.

virtual bool RestoreState ( Stream 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

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

Return value

Returns true on success, or false if an error has occurred.

virtual bool SaveWorld ( Xml xml ) #

Engine calls this function on world saving.

Arguments

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

Return value

Returns true on success, or false if an error has occurred.

virtual bool Shutdown ( ) #

Engine calls this function on plugin shutdown.

Return value

Returns true on success, or false 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.
Last update: 2024-04-19
Build: ()