Search Unity

  1. Unity 2018.3 is now released.
    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. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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: