Skip to content

Commit 29e3262

Browse files
committed
add info on how to get a reference to a game plugin
1 parent 4734dab commit 29e3262

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

manual/scripting/plugins/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,33 @@ void MyPlugin::Deinitialize()
144144
145145
Your game can also use a Game Plugins within a code to implement various gameplay features because plugins don't rely on loaded scenes or scene objects and are created before the scenes loading (compared to the normal scripts).
146146
147+
### How to get your Game Plugin
148+
149+
You can now get a reference to your Game Plugin with:
150+
```cs
151+
MyPlugin gamePlugin = PluginManager.GetPlugin<>(MyPlugin);
152+
```
153+
154+
To make access to the plugin easier, you can define a property in your MyPlugin class like this:
155+
```cs
156+
public static MyPlugin Instance
157+
{
158+
get
159+
{
160+
if (_instance == null)
161+
_instance = PluginManager.GetPlugin<MyPlugin>();
162+
163+
return _instance;
164+
}
165+
}
166+
private static MyPlugin _instance;
167+
```
168+
169+
Now you can access the Game Plugin like this:
170+
```cs
171+
MyPlugin gamePlugin = MyPlugin.Instance;
172+
```
173+
147174
### Game Plugin Settings
148175

149176
If you need to include custom settings for your plugin see [this tutorial](../tutorials/custom-settings.md) to learn more.

0 commit comments

Comments
 (0)