Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Don't miss out on the Unite LA Keynote for the latest information from Unity! Set a reminder!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

unity spatializer user params (script)

Discussion in 'Documentation' started by scottcolburn, Sep 27, 2018.

  1. scottcolburn

    scottcolburn

    Joined:
    Sep 18, 2018
    Posts:
    1
    I'm trying to find documentation on what the parameters are controled in this script. It comes with the Native Audio SDK demo where you choose the spatialization via "demo spatializer". In the demo, there is a scene called Spatilization and this script is on all the audio sources, but i can't find any documentation explaining what the script does.

    See attached file of the script attached to the audio source in the demo

    Here's the script

    // The spatialization API is only supported by the final Unity 5.2 version and newer.
    // If you get script compile errors in this file, comment out the line below.
    #define ENABLE_SPATIALIZER_API
    using UnityEngine;
    using System.Collections;
    public class SpatializerUserParams : MonoBehaviour
    {
    #if ENABLE_SPATIALIZER_API
    public bool EnableSpatialization = true;
    public float DistanceAttn = 1.0f;
    public float FixedVolume = 0.0f;
    public float CustomRolloff = 0.0f;
    #endif
    void Start()
    {
    }
    void Update()
    {
    var source = GetComponent<AudioSource>();
    #if ENABLE_SPATIALIZER_API
    source.SetSpatializerFloat(0, DistanceAttn);
    source.SetSpatializerFloat(1, FixedVolume);
    source.SetSpatializerFloat(2, CustomRolloff);
    source.GetSpatializerFloat(0, out DistanceAttn); // Get back clipped parameters from plugin
    source.GetSpatializerFloat(1, out FixedVolume);
    source.GetSpatializerFloat(2, out CustomRolloff);
    source.spatialize = EnableSpatialization;
    #endif
    }
    }
     

    Attached Files: