Skip to content

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:

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

  1. Launch Visual Studio and click "Create a new project"
  2. 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.
  3. You can name and put it wherever you want
  4. When asked for a Framework, make sure .NET Standard 2.0 is selected
  5. 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. Screenshot of Visual Studio with the Class Library option highlighted

Adding VNyan and Unity Dependencies

  1. Right click the Dependencies dropdown and click "Add Project Reference"
  2. In the new window, click the Browse on the bottom right. Navigate to the two main files you'll need.
  3. 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.
  4. To add the dependencies to your code, just type in using UnityEngine; and using VNyanInterface;. Your starting code might look something like this:
using System;
using UnityEngine;
using VNyanInterface;

namespace VNyan_Project_Name
{
    public class VNyan_Project_Name_Class : MonoBehaviour
    {
      public void Start()
      {
      }
    }
}

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.

  public class ExamplePluginManifest: IVNyanPluginManifest
  {
      public string PluginName { get; } = "ExamplePlugin";
      public string Version { get; } = "v0.1.0";
      public string Title { get; } = "Jayo's Example Plugin";
      public string Author { get; } = "Anastasia Jayo";
      public string Website { get; } = "https://vtuber.works/";

      public void InitializePlugin()
      {
          GameObject obj = new GameObject("ExamplePluginHolder", typeof(ExamplePlugin));
      }
  }

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.

Full example of plugin setup

  namespace VNyanProjectTemplate
  {
      public class ExamplePluginManifest: IVNyanPluginManifest
      {
          public string PluginName { get; } = "ExamplePlugin";
          public string Version { get; } = "v0.1.0";
          public string Title { get; } = "Jayo's Example Plugin";
          public string Author { get; } = "Anastasia Jayo";
          public string Website { get; } = "https://vtuber.works/";

          public void InitializePlugin()
          {
              GameObject obj = new GameObject("ExamplePluginHolder", typeof(ExamplePlugin));
          }
      }

      public class ExamplePlugin : MonoBehaviour
      {
          void Start()
          {
              Debug.Log("Example Plugin Started!");
          }
      }
  }