Skip to main content

Plugin Development

If you're a developer and are interested in creating new plugins for VNyan you can follow instructions detailed on this page.

Getting Started​

VNyan plugins are compiled C# Assemblies made by referencing VNyan's own interface dll, VNyanInterface.dll. You will also need to reference specific Unity libraries if you want to use Unity's components.

Requirements​

  • Visual Studio 2022
  • Unity 2022.3.62
  • VNyan 1.2.1 or later

Setting up Visual Studio project​

First step is to Launch Visual Studio and click Create a new project.

From the list of templates select C# Class Library that says it targets .NET Standard or .NET Core

Plugin Template

Give your project unique name so it'll not conflict with other Assemblies.

Make sure to select .NET Standard 2.1 when asked for Framework version.

Plugin Template

Click Create and you're done! Your project will then open up with a blank template file called Class1.cs. You can rename and create more files are you're working.

Adding VNyan and Unity dependencies​

To be able to work with VNyan's and Unity's components and functions you'll need to include couple references to your fresh project.

  • Right click the Dependencies in your solution and from the dropdown select Add Project Reference
  • Click the Browse-button and find VNyanInterface.dll from VNyan's installation directory under VNyan_Data\Managed\
  • Repeat the steps and add UnityEngine.dll from Unity's editor directory. This is often located in C:\Program Files\Unity\Hub\Editor\2022.3.62f3\Editor\Data\Managed

Adding Plugin Manifest​

If you're working on a plugin instead of a custom component then it's recommended that you create a Plugin Manifest. This allows the plugin to start automatically rather than rely on having the component be present in a GameObject.

The Plugin Manifest can be done simply by including a class in your project that implements the IVNyanPluginManifest-interface.

namespace MyPlugin
{

public class MyPluginManifest : IVNyanPluginManifest
{
public string PluginName { get; } = "MyPlugin";
public string Version { get; } = "v1.0.0";
public string Title { get; } = "My Plugin";
public string Author { get; } = "Suvidriel";
public string Website { get; } = "https://vnyan.net/";

public void InitializePlugin()
{
new MyPlugin(); // Initialize instance of your plugin here
}
}
}

Registering Plugin-button in Plugins-window​

It's recommended that plugins register a button in VNyan's plugins window. This will allow easy access to the plugins' settings and also gives user indication that the plugin has indeed been succesfully loaded.

To register the Plugin Window-button you need to implement the IButtonClickedHandler from VNyanInterface in your Plugin's class. This can be done for example like this:

namespace MyPlugin
{

public class MyPlugin: VNyanInterface.IButtonClickedHandler
{
private VNyanInterface.IVNyanUIWindow pluginWindow;

public MyPlugin()
{
VNyanInterface.VNyanInterface.VNyanUI.registerPluginButton("My Plugin", this);

// Create ui
pluginWindow = VNyanInterface.VNyanInterface.VNyanUI.createDraggableWindow(300, 300, true, false);
pluginWindow.setVisible(false);
}

public void pluginButtonClicked()
{
// Open plugin window when button is clicked
pluginWindow.setVisible(true);
pluginWindow.bringToFront();

}
}
}