Plugin Lifecycle Methods

Virt-A-Mate plugins, derived from MVRScript (and thus Unity’s MonoBehaviour), support standard Unity lifecycle methods. Understanding these methods helps you manage your plugin’s behavior effectively throughout its lifecycle:

Init()

(override required)
Called once when the plugin is initialized. Typically used to initialize UI elements, JSONStorables, event listeners, and initial plugin states.

public override void Init()
{
    // Initialization logic here
}

Start()

(optional)
Called once, immediately after Init(). Useful if you need additional initialization dependent on other plugins or atoms.

public void Start() {
    // Additional initialization logic
}

Update()

(optional)
Called every rendered frame. Ideal for dynamic, frame-by-frame behavior like animations or continuous checks.

public void Update() {
    // Runs once per frame
}

FixedUpdate()

(optional)
Invoked at fixed intervals (default every 0.02 seconds), independent of frame rate. Use this for physics simulations or predictable timing-based logic.

public void FixedUpdate() {
    // Physics-based or time-sensitive logic
}

OnDestroy()

(optional but recommended for cleanup)
Called when the plugin is unloaded. Perform cleanup here (e.g., unregister event listeners, release resources).

private void OnDestroy() {
    // Cleanup logic
}