Creating VNyan Plugins¶
Written by lunazera
Abstract
Step-by-step guide for how to get started coding plugins for VNyan! Hope this might be helpful for anybody who wants to look into making plugins, but haven't done anything like that before or used Visual Studio before.
Things you'll need:¶
- Visual Studio Community IDE - https://visualstudio.microsoft.com/downloads/
- Unity 2022.3.62f2
- You can download through the Unity Hub, find the version here and click install https://unity.com/releases/editor/archive
- Latest version of VNyan & VNyan SDK
Main files you'll need¶
- VNyanInterface.dll -
..\vnyan\VNyan_Data\Managed\VNyanInterface.dll - UnityEngine.dll -
..\vnyan\VNyan_Data\Managed\UnityEngine.dll
Info
You can also get the Unity DLL's from your Unity installation
(eg. ..\Unity\2022.3.62f2\Editor\Data\Managed\UnityEngine.dll)
Setting up a Visual Studio Project¶
- Launch Visual Studio and click "Create a new project"
- You'll see a list of templates to choose from. You're looking for the C# Class Library that says it targets .NET Standard or .NET Core.
- You can name and put it wherever you want
- When asked for a Framework, make sure .NET Standard 2.0 is selected
- Click create and you're done! When your project opens, you'll have a blank template file to work in called
Class1.cs. You can rename and create more files as you're working.
Adding VNyan and Unity Dependencies¶
- Right click the Dependencies dropdown and click "Add Project Reference"
- In the new window, click the Browse on the bottom right. Navigate to the two main files you'll need.
- Once you add them, they should pop up in the Browse tab on the right as recent references. They should be check marked. Press okay, and it'll add them to your project.
- To add the dependencies to your code, just type in
using UnityEngine;andusing VNyanInterface;. Your starting code might look something like this:
Plugin Manifest¶
If you want to create a full plugin with a user interface interactable within VNyan, you will now need to build your plugin DLL and bring it into Unity to continue. However, if your plugin is relatively simple and doesn't need that kind of interface, you can use VNyan's Manifest Interface.
In your same project file, create a new class that extends the IVNyanPluginManifest interface. You will define your plugin details through the required methods.
The InitializePlugin() method will be called by VNyan on startup, and here we are telling it to create a new Unity GameObject with your main plugin class attached. This forego's the need to have to do this through Unity yourself.