Ejemplo n.º 1
0
        private void OnDestroy()
        {
            if (mAudioEngineSource != null)
            {
                mAudioEngineSource.Destroy();
                mAudioEngineSource = null;
            }

            if (mSource != null)
            {
                mSource.Release();
                mSource = null;
            }

            mThis.Free();
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            mSimulator = SteamAudioManager.Simulator;

            var settings = SteamAudioManager.GetSimulationSettings(false);

            mSource = new Source(SteamAudioManager.Simulator, settings);

            mAudioEngineSource = AudioEngineSource.Create(SteamAudioSettings.Singleton.audioEngine);
            if (mAudioEngineSource != null)
            {
                mAudioEngineSource.Initialize(gameObject);
                mAudioEngineSource.UpdateParameters(this);
            }

            mAudioSource = GetComponent <AudioSource>();

            mThis = GCHandle.Alloc(this);

            if (SteamAudioSettings.Singleton.audioEngine == AudioEngineType.Unity &&
                distanceAttenuation &&
                distanceAttenuationInput == DistanceAttenuationInput.CurveDriven &&
                reflections &&
                useDistanceCurveForReflections)
            {
                mAttenuationData.rolloffMode = mAudioSource.rolloffMode;
                mAttenuationData.minDistance = mAudioSource.minDistance;
                mAttenuationData.maxDistance = mAudioSource.maxDistance;
                mAttenuationData.curve       = mAudioSource.GetCustomCurve(AudioSourceCurveType.CustomRolloff);

                mCurveAttenuationModel.type     = DistanceAttenuationModelType.Callback;
                mCurveAttenuationModel.callback = EvaluateDistanceCurve;
                mCurveAttenuationModel.userData = GCHandle.ToIntPtr(mThis);
                mCurveAttenuationModel.dirty    = Bool.False;
            }
        }