Exemplo n.º 1
0
 public virtual void OnRecycle()
 {
     if (Scope == RTPCScope.Local)
     {
         TypePoolManager.Recycle(ref value);
     }
 }
Exemplo n.º 2
0
        protected override void RemoveSource(int index)
        {
            base.RemoveSource(index);

            TypePoolManager.Recycle(dynamicData.Pop(index));
            UpdateSequence();
        }
Exemplo n.º 3
0
 public void OnRecycle()
 {
     if (recycle)
     {
         TypePoolManager.Recycle(ref option);
     }
 }
Exemplo n.º 4
0
        protected override void ApplyOptionNow(AudioOption option, bool recycle)
        {
            if (state != AudioStates.Stopped)
            {
                switch (option.Type)
                {
                case AudioOption.Types.VolumeScale:
                    float[] volumeData = option.GetValue <float[]>();
                    SetVolumeScale(volumeData[0], volumeData[1], (TweenUtility.Ease)volumeData[2], true);
                    break;

                case AudioOption.Types.PitchScale:
                    float[] pitchData = option.GetValue <float[]>();
                    SetPitchScale(pitchData[0], pitchData[1], (TweenUtility.Ease)pitchData[2], true);
                    break;

                case AudioOption.Types.RandomVolume:
                    float randomVolume = option.GetValue <float>();
                    Settings.RandomVolume         = randomVolume;
                    volumeModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomVolume, randomVolume);
                    break;

                case AudioOption.Types.RandomPitch:
                    float randomPitch = option.GetValue <float>();
                    Settings.RandomPitch         = randomPitch;
                    pitchModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomPitch, randomPitch);
                    break;

                case AudioOption.Types.FadeIn:
                    float[] fadeInData = option.GetValue <float[]>();
                    Settings.FadeIn     = fadeInData[0];
                    Settings.FadeInEase = (TweenUtility.Ease)fadeInData[1];
                    break;

                case AudioOption.Types.FadeOut:
                    float[] fadeOutData = option.GetValue <float[]>();
                    Settings.FadeIn     = fadeOutData[0];
                    Settings.FadeInEase = (TweenUtility.Ease)fadeOutData[1];
                    break;

                case AudioOption.Types.Loop:
                    Settings.Loop = option.GetValue <bool>();
                    break;

                default:
                    for (int i = 0; i < sources.Count; i++)
                    {
                        sources[i].ApplyOption(option, false);
                    }
                    break;
                }
            }

            if (recycle)
            {
                TypePoolManager.Recycle(ref option);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Internaly used by the pooling system.
        /// </summary>
        public virtual void OnRecycle()
        {
            // Only the AudioItem root should recycle the spatializer as it is shared with it's children
            if (parent == null)
            {
                TypePoolManager.Recycle(ref spatializer);
            }

            TypePoolManager.RecycleElements(delayedOptions);
            ClearEvents();
        }
Exemplo n.º 6
0
        protected void UpdateOptions()
        {
            for (int i = 0; i < delayedOptions.Count; i++)
            {
                var delayedOption = delayedOptions[i];

                if (delayedOption.Update())
                {
                    ApplyOptionNow(delayedOption.Option, false);
                    delayedOptions.RemoveAt(i--);
                    TypePoolManager.Recycle(ref delayedOption);
                }
            }
        }
Exemplo n.º 7
0
        void RemoveComponent(IComponentOld component, bool raiseEvent)
        {
            if (allComponents.Remove(component))
            {
                UnregisterComponent(component);

                // Raise event
                if (raiseEvent)
                {
                    RaiseOnComponentRemovedEvent(component);
                }

                TypePoolManager.Recycle(component);
            }
        }
Exemplo n.º 8
0
        public void ResolveEvents()
        {
            SwitchQueues();

            while (resolvingEvents.Count > 0)
            {
                var eventData = resolvingEvents.Dequeue();

                if (eventData.Resolve())
                {
                    TypePoolManager.Recycle(eventData);
                }
                else
                {
                    Trigger(eventData, 0f);
                }
            }
        }
Exemplo n.º 9
0
        void RemoveAllComponents(bool raiseEvent)
        {
            for (int i = 0; i < allComponents.Count; i++)
            {
                var component = allComponents[i];
                UnregisterComponent(component);

                // Raise event
                if (raiseEvent)
                {
                    RaiseOnComponentRemovedEvent(component);
                }

                TypePoolManager.Recycle(component);
            }

            allComponents.Clear();
        }
Exemplo n.º 10
0
        public override void StopImmediate()
        {
            if (state == AudioStates.Stopped)
            {
                return;
            }

            source.Stop();
            SetState(AudioStates.Stopped);
            RaiseStopEvent();

            if (parent == null)
            {
                itemManager.Deactivate(this);
            }

            spatializer.RemoveSource(source.transform);
            TypePoolManager.Recycle(this);
        }
Exemplo n.º 11
0
        public override void StopImmediate()
        {
            if (state == AudioStates.Stopped)
            {
                return;
            }

            for (int i = 0; i < sources.Count; i++)
            {
                sources[i].StopImmediate();
            }

            SetState(AudioStates.Stopped);
            RaiseStopEvent();

            if (parent == null)
            {
                itemManager.Deactivate(this);
            }

            TypePoolManager.Recycle(this);
        }
Exemplo n.º 12
0
        protected override void ApplyOptionNow(AudioOption option, bool recycle)
        {
            if (state != AudioStates.Stopped)
            {
                switch (option.Type)
                {
                case AudioOption.Types.VolumeScale:
                    var volumeData = option.GetValue <Vector3>();
                    SetVolumeScale(volumeData.x, volumeData.y, (TweenUtility.Ease)volumeData.z, true);
                    break;

                case AudioOption.Types.PitchScale:
                    var pitchData = option.GetValue <Vector3>();
                    SetPitchScale(pitchData.x, pitchData.y, (TweenUtility.Ease)pitchData.z, true);
                    break;

                case AudioOption.Types.RandomVolume:
                    float randomVolume = option.GetValue <float>();
                    settings.RandomVolume         = randomVolume;
                    volumeModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomVolume, randomVolume);
                    break;

                case AudioOption.Types.RandomPitch:
                    float randomPitch = option.GetValue <float>();
                    settings.RandomPitch         = randomPitch;
                    pitchModifier.RandomModifier = 1f + UnityEngine.Random.Range(-randomPitch, randomPitch);
                    break;

                case AudioOption.Types.FadeIn:
                    var fadeInData = option.GetValue <Vector2>();
                    settings.FadeIn     = fadeInData.x;
                    settings.FadeInEase = (TweenUtility.Ease)fadeInData.y;
                    break;

                case AudioOption.Types.FadeOut:
                    var fadeOutData = option.GetValue <Vector2>();
                    settings.FadeIn     = fadeOutData.x;
                    settings.FadeInEase = (TweenUtility.Ease)fadeOutData.y;
                    break;

                case AudioOption.Types.Loop:
                    bool loop = option.GetValue <bool>();
                    settings.Loop = loop;
                    source.loop   = loop && !hasBreak;
                    break;

                case AudioOption.Types.Clip:
                    var clip = option.GetValue <AudioClip>();
                    settings.Clip = clip;
                    source.clip   = clip;
                    break;

                case AudioOption.Types.Output:
                    var output = option.GetValue <AudioMixerGroup>();
                    settings.Output = output;
                    source.outputAudioMixerGroup = output;
                    break;

                case AudioOption.Types.DopplerLevel:
                    source.dopplerLevel = option.GetValue <float>();
                    break;

                case AudioOption.Types.RolloffMode:
                    if (option.HasCurve())
                    {
                        source.rolloffMode = AudioRolloffMode.Custom;
                        source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, option.GetValue <AnimationCurve>());
                    }
                    else
                    {
                        source.rolloffMode = option.GetValue <AudioRolloffMode>();
                    }
                    break;

                case AudioOption.Types.MinDistance:
                    source.minDistance = option.GetValue <float>();
                    break;

                case AudioOption.Types.MaxDistance:
                    source.maxDistance = option.GetValue <float>();
                    break;

                case AudioOption.Types.Spread:
                    if (option.HasCurve())
                    {
                        source.SetCustomCurve(AudioSourceCurveType.Spread, option.GetValue <AnimationCurve>());
                    }
                    else
                    {
                        source.spread = option.GetValue <float>();
                    }
                    break;

                case AudioOption.Types.Mute:
                    source.mute = option.GetValue <bool>();
                    break;

                case AudioOption.Types.BypassEffects:
                    source.bypassEffects = option.GetValue <bool>();
                    break;

                case AudioOption.Types.BypassListenerEffects:
                    source.bypassListenerEffects = option.GetValue <bool>();
                    break;

                case AudioOption.Types.BypassReverbZones:
                    source.bypassReverbZones = option.GetValue <bool>();
                    break;

                case AudioOption.Types.Priority:
                    source.priority = option.GetValue <int>();
                    break;

                case AudioOption.Types.StereoPan:
                    source.panStereo = option.GetValue <float>();
                    break;

                case AudioOption.Types.SpatialBlend:
                    if (option.HasCurve())
                    {
                        source.SetCustomCurve(AudioSourceCurveType.SpatialBlend, option.GetValue <AnimationCurve>());
                    }
                    else
                    {
                        source.spatialBlend = option.GetValue <float>();
                    }
                    break;

                case AudioOption.Types.ReverbZoneMix:
                    if (option.HasCurve())
                    {
                        source.SetCustomCurve(AudioSourceCurveType.ReverbZoneMix, option.GetValue <AnimationCurve>());
                    }
                    else
                    {
                        source.reverbZoneMix = option.GetValue <float>();
                    }
                    break;

                case AudioOption.Types.PlayRange:
                    var playRangeData = option.GetValue <Vector2>();
                    settings.PlayRangeStart = playRangeData.x;
                    settings.PlayRangeEnd   = playRangeData.y;
                    lastTime = source.time;
                    break;

                case AudioOption.Types.Time:
                    source.time = option.GetValue <float>();
                    lastTime    = source.time;
                    break;

                case AudioOption.Types.TimeSamples:
                    source.timeSamples = option.GetValue <int>();
                    lastTime           = source.time;
                    break;

                case AudioOption.Types.VelocityUpdateMode:
                    source.velocityUpdateMode = option.GetValue <AudioVelocityUpdateMode>();
                    break;

                case AudioOption.Types.IgnoreListenerPause:
                    source.ignoreListenerPause = option.GetValue <bool>();
                    break;

                case AudioOption.Types.IgnoreListenerVolume:
                    source.ignoreListenerVolume = option.GetValue <bool>();
                    break;

                case AudioOption.Types.Spatialize:
                    source.spatialize = option.GetValue <bool>();
                    break;
                }
            }

            if (recycle)
            {
                TypePoolManager.Recycle(ref option);
            }
        }
Exemplo n.º 13
0
 void IPoolable.OnRecycle()
 {
     TypePoolManager.Recycle(ref value);
 }