Working With Scripts
Last updated
Last updated
Scripts add interactive behaviors to objects in an experience. In Sansar, you can create, upload and add your own scripts in C#.
Script API documentation
For more information on creating scripts for Sansar, read our .
Alternatively, you may also find the API Documentation within the Sansar program folder. You can find the documentation on your system using the following file path: Program Files > Sansar > Client > Script API > Documentation.
To stay updated on the latest Script API changes, see .
If you are interested in uploading scripts written in C# (.cs) to your inventory from your computer, see for a step-by-step guide on the upload process. Note that you will receive a warning if your script makes use of one of the .
Adding a script to an object
You can add scripts to objects in order to make them perform actions or interact with avatars and the environment. Currently, there are two ways to add a script to an object in a scene. For more information on these two ways, see .
Note: As of October 31, 2017, objects do not need to be set to IsDynamic in order to trigger collision events. Additionally, animated objects may trigger collision events if their animation causes them to collide with another object or avatar.
Setting the script's parameters
Some scripts allow you to enter parameters to modify the way the script works. Each script is unique, so the name and function of parameters for each script may be different based on how it was defined by the script writer. For more information on setting a script's parameters, see .
We have provided several example scripts in the Sansar client's install folder for you to use. You can find the example scripts by following the file path: Program Files > Sansar > Client > Script API > Examples.
To help you get started with scripting in Sansar, we have provided a project file, ScriptExamples.csproj, in the install folder which imports all of Sansar's APIs and example scripts into Visual Studio. It is located located in the Sansar install folder: Program Files > Sansar > Client > Script API > Examples. Simply open the folder in Visual Studio 2015 and the project will import the APIs and example scripts.
You can also find some documentation (and some download links) for some of these example scripts at .