Used for retrieving data and invoking behaviors that do not relate to any specific ViRSE Components in your scene

<aside> ℹ️ The ViRSEAPI is found on the ViRSEManager GameObject. If your scene is missing a VIRSEManager, see ViRSE Scene Setup

</aside>

The VIRSEAPI exposes a number of events in its inspector, this lets you specify your own functions to execute when users join and leave the instance, when the local user switches between VR and 2D modes, when the local user becomes host, or admin, etc

The ViRSEAPI also exposes an interface, allowing you to invoke its functions, and retrieve further data. In the example below, when the local user becomes the admin, we want to spawn a particular GameObject, and move it to the user’s position. To do this we link the OnBecomeAdmin to the ViRSEAPI’s OnBecomeAdmin event in the inspector, and then use the ViRSEAPI’s interface to retrieve the local user’s player position so we can spawn the GameObject at the correct position

//Some GameObject to spawn when we become admin
public GameObject adminToolToSpawn; 

//Link this function to the OnBecomeAdmin event in V_ViRSEAPI's inspector
//An example of executing your own code when the OnBecomeAdmin event is invoked
private void OnBecomeAdmin() 
{
	//Spawn admin tool referencing some GameObject we've assigned a reference to in the inspector for our script
	GameObject adminTool = Instantiate(adminToolToSpawn);

	//Move admin tool to the player's position, plus forward a little so its in front of them
	Transform playerTransform = Plugin_Home.virseAPI.GetLocalPlayerGameObject().transform; //Make sure PluginRoot has a Plugin_Home component!
	adminTool.transform.position = playerTransform.position + playerTransform.forward;
}

<aside> 🤓 You might notice we’re referencing “virseAPI” through “Plugin_Home”. This is a script that lives on the ViRSEManager that has been set up to hold a static reference to the ViRSEAPI. This is essentially just a shortcut so you write Plugin_Home.virseAPI rather than having to expose a public reference to the GameObject with the ViRSEAPI and then get the IViRSEAPI component, like you normally would for the other ViRSE components

</aside>