Namespaces and Libraries

When writing plugins for Virt-A-Mate (VaM), you often see several using statements at the top of your C# script. Each statement references a specific namespace or library that provides the classes and functions you’ll use. Below is an overview of each commonly used namespace, where it comes from, and how it’s typically used in VaM plugin development.


using System;

  • What It Is: The base .NET namespace, containing fundamental classes such as String, Exception, and many other core data types.
  • Why It’s Used: Essential for basic C# functionality—throwing/catching exceptions, working with built-in data types, etc.
  • Reference: Microsoft Docs - System Namespace

using System.Collections;

  • What It Is: A .NET namespace that provides classes and interfaces for non-generic collections (e.g., ArrayList, Hashtable).
  • Why It’s Used: While modern code typically uses generic collections, some older APIs and certain operations may still require these non-generic classes.
  • Reference: Microsoft Docs - System.Collections Namespace

using System.Collections.Generic;

  • What It Is: A .NET namespace for type-safe, generic collections like List<T>, Dictionary<TKey,TValue>, HashSet<T>, etc.
  • Why It’s Used: Provides essential data structures for managing lists, dictionaries, and other collections in a VaM plugin.
  • Reference: Microsoft Docs - System.Collections.Generic Namespace

using System.Linq;

  • What It Is: A .NET namespace for Language-Integrated Query (LINQ) functionality.
  • Why It’s Used: Allows concise and powerful querying of collections (e.g., Where, Select, FirstOrDefault) which can be very handy when searching through atoms, storables, etc.
  • Reference: Microsoft Docs - System.Linq Namespace

using SimpleJSON;

  • What It Is: A lightweight JSON parsing library that Virt-A-Mate includes for handling JSON data.

  • Why It’s Used: VaM uses SimpleJSON under the hood for serializing and deserializing plugin data, especially in JSONStorable objects.

  • Reference:

    • GitHub - SimpleJSON (Official Repository)
      (Note: The SimpleJSON namespace included by VaM is a custom version tailored specifically for the application. Not all SimpleJSON documentation from GitHub will exactly match VaM’s implementation.)

using UnityEngine;

  • What It Is: The core Unity engine namespace that VaM is built upon.
  • Why It’s Used: Provides access to Unity-specific classes like MonoBehaviour, GameObject, Transform, and various engine features. VaM plugins derive from MVRScript (which itself extends Unity’s MonoBehaviour).
  • Reference: Unity Documentation - UnityEngine Namespace

using UnityEngine.UI;

  • What It Is: The Unity UI framework namespace for creating user interface elements such as Button, Toggle, Slider, etc.
  • Why It’s Used: VaM’s plugin UI system relies heavily on Unity’s UI classes. You’ll often bind JSONStorable parameters to these UI elements.
  • Reference: Unity Documentation - UnityEngine.UI Namespace

Putting It All Together

A typical VaM plugin script might look like this at the top:

// .NET namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

// SimpleJSON
using SimpleJSON;

// Unity Engine namespaces
using UnityEngine;
using UnityEngine.UI;

public class MyVaMPlugin : MVRScript
{
    // Plugin logic here
}