// Unity 4 is deprecated; UNITY_5 still valid with plug-in
#if !UNITY_5
    /// <summary>
    /// Update this instance.
    /// </summary>
    void Update()
    {
        AudioSource source = GetComponent <AudioSource>();

        if (source == null)
        {
            // We already caught the error in Awake so bail
            return;
        }

        // Set speaker mode
        if (useVirtualSpeakers == true)
        {
            source.SetAmbisonicDecoderFloat(paramVSpeakerMode, 1.0f); // VSpeakerMode
        }
        else
        {
            source.SetAmbisonicDecoderFloat(paramVSpeakerMode, 0.0f); // OclusAmbi
        }
        float statusF = 0.0f;

        // PGG 5/25/2017 There is a bug in the 2017.2 beta that does not
        // allow for ambisonic params to be passed through to native
        // from C# Get latest editor from Unity when available
        source.GetAmbisonicDecoderFloat(paramAmbiStat, out statusF);

        ovrAmbisonicsNativeStatus status = (ovrAmbisonicsNativeStatus)statusF;

        // TODO: Add native result/error codes
        if (status != currentStatus)
        {
            switch (status)
            {
            case (ovrAmbisonicsNativeStatus.NotEnabled):
                Debug.Log("Ambisonic Native: Ambisonic not enabled on clip. Check clip field and turn it on");
                break;

            case (ovrAmbisonicsNativeStatus.Uninitialized):
                Debug.Log("Ambisonic Native: Stream uninitialized");
                break;

            case (ovrAmbisonicsNativeStatus.Success):
                Debug.Log("Ambisonic Native: Stream successfully initialized and playing/playable");
                break;

            case (ovrAmbisonicsNativeStatus.StreamError):
                Debug.Log("Ambisonic Native WARNING: Stream error (bad input format?)");
                break;

            case (ovrAmbisonicsNativeStatus.ProcessError):
                Debug.Log("Ambisonic Native WARNING: Stream process error (check default speaker setup)");
                break;

            default:
                break;
            }
        }

        currentStatus = status;
    }
示例#2
0
    static int GetAmbisonicDecoderFloat(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        AudioSource obj  = (AudioSource)LuaScriptMgr.GetUnityObjectSelf(L, 1, "AudioSource");
        int         arg0 = (int)LuaScriptMgr.GetNumber(L, 2);
        float       arg1;
        bool        o = obj.GetAmbisonicDecoderFloat(arg0, out arg1);

        LuaScriptMgr.Push(L, o);
        LuaScriptMgr.Push(L, arg1);
        return(2);
    }