The example script, Sound Randomizer (SoundRandomizer.cs), plays randomly from a list of sounds at randomized intervals. You can get the file from the download link at the end of the page.
Here is a step-by-step guide to using the script:
- In the My Experiences app, choose the scene you want to edit and click the Edit Scene button.
- If you already have the file in your inventory, jump to step 3 to start using the script. Otherwise, download the SoundRandomizer.cs example script at the bottom of this page and upload the file into your inventory. See Uploading items in Sansar for more information.
- Now that you have the script in your inventory, choose an object in the scene to which you want to apply the script.
- Select the SoundRandomizer.cs file from your Inventory and drag the script onto the object in the scene.
- Now that the script has been applied to the object, open the properties panel for the object. In the properties panel, set IsDynamic to On.
- Set look at the Script Settings section on the Properties panel. Make sure that the script dropdown menu is set to the SoundRandomizer.cs example script. If the script is set correctly, a set of editable parameters appears. See below for a short guide on each parameter.
- Once you have finished setting the parameters for your object, your script is ready! Save and build your scene.
- If you want to verify that the script is running correctly, visit the scene once it is built.
Here is a short guide for each parameter you can set:
|Parameters for Sound Randomizer.|
If your object has an AudioComponent, setting this to "On" causes the sounds to play on the object. The sounds also follow the object if the object moves around. Otherwise, the sounds play directly to your speakers/headphones (like Sansar's UI sounds).
|MinDelayBetweenSounds||The delay between each sound is randomized to fall into this range. If you leave them set to zero, there is no delay between sounds.|
|Sound1||Assign any of these slots to sounds in your inventory. You do not need to assign all of them. The script plays from the slots that have been assigned.|
Creative Commons License
This content is licensed under the terms of the Creative Commons Attribution 4.0 International License. When using this content, you must:
- Acknowledge that the content is from the Sansar Knowledge Base.
- Include our copyright notice: "© 2017 Linden Research, Inc."
- Indicate that the content is licensed under the Creative Commons Attribution-Share Alike 4.0 International License.
Include the URL for, or link to, the license summary at https://creativecommons.org/licenses/by-sa/4.0/deed.hi (and, if possible, to the complete license terms at https://creativecommons.org/licenses/by-sa/4.0/legalcode.
"This work uses content from the Sansar Knowledge Base. © 2017 Linden Research, Inc. Licensed under the Creative Commons Attribution 4.0 International License (license summary available at https://creativecommons.org/licenses/by/4.0/ and complete license terms available at https://creativecommons.org/licenses/by/4.0/legalcode)."