Search Unity

  1. Unity 2019.1 beta is now available.
    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. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. 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: