Add Command Prefabs to GenvidSession¶
Commands let you tell your game to do specific things from a separate website, such as an administrator site.
Unlike events, commands go directly from the website to your game without a MapReduce system. This makes it possible to send individual instructions to the game with minimal delay.
We recommend limiting commands to an administrator or similarly access-controlled page.
Drag and drop a Commands prefab into GenvidSession as a child of the GenvidSession.
The GenvidSession has a Commands section. Drag and drop your current Commands prefab into this field.
Change the Ids Size to the number of game-data streams that you want to create.
Open one element and give it a unique name in the Id field.
In the script receiving the command, create a public function that takes the following parameters in this order:
- A string.
- A second string.
- An integer pointer.
Drag and drop the object with your script into the On Command Triggered box.
From the dropdown list displaying No Function, select the game script and function you created.
In your public function you can use the information received from the command:
First String: Id of the command.
Note: You’ll use this Id later when setting up your Commands configuration and website calls.
Second String: Results of the command.
IntPtr: Specific pointer used for the callback.
The public function tells your game how to interpret commands sent from an external website. Commands are generally used for administrative functions and what they do is completely up to you. You can see examples of commands on the sample admin website.