// 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;
    }
    /// <summary>
    /// OnEnable this instance.
    /// </summary>
    void OnEnable()
    {
// Unity 4 is deprecated; UNITY_5 still valid with plug-in
#if UNITY_5
        Debug.Log("Ambisonic ERROR: Ambisonic support in Unity 2017 or higher");
#else
        AudioSource source = GetComponent <AudioSource>();

        currentStatus = ovrAmbisonicsNativeStatus.Uninitialized;

        if (source == null)
        {
            Debug.Log("Ambisonic ERROR: AudioSource does not exist.");
        }
        else
        {
            if (source.spatialize == true)
            {
                Debug.Log("Ambisonic WARNING: Turning spatialize field off for Ambisonic sources.");
                source.spatialize = false;
            }

            if (source.clip == null)
            {
                Debug.Log("Ambisonic ERROR: AudioSource does not contain an audio clip.");
            }
            else
            {
                if (source.clip.channels != numFOAChannels)
                {
                    Debug.Log("Ambisonic ERROR: AudioSource clip does not have correct number of channels.");
                }
            }
        }
#endif
    }