Exemplo n.º 1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (!property.FindPropertyRelative("_initialized").boolValue)
            {
                property.FindPropertyRelative("Sound").SetValue(new ClipOrBank(true));
                property.FindPropertyRelative("RolloffDistance").SetValue(SoundManagerSettings.Instance.SequenceBank.SectionRolloffDistance);
                property.FindPropertyRelative("Loop").SetValue(SoundManagerSettings.Instance.SequenceBank.SectionLooping);
                property.FindPropertyRelative("Repititions").SetValue(SoundManagerSettings.Instance.SequenceBank.SectionRepititions);
                property.FindPropertyRelative("Delay").SetValue(SoundManagerSettings.Instance.SequenceBank.SectionDelay);

                property.FindPropertyRelative("_initialized").boolValue = true;
            }

            _isBank     = property.FindPropertyRelative("Sound").FindPropertyRelative("_isBank").boolValue;
            _loop       = property.FindPropertyRelative("Loop").boolValue;
            _isExpanded = property.isExpanded;

            string name  = "Empty";
            Object value = property.FindPropertyRelative("Sound").FindPropertyRelative(_isBank ? "_soundBank" : "_audioClip").objectReferenceValue;

            if (value != null)
            {
                name = value.name;
            }

            _loopable = true;
            if (_isBank)
            {
                SoundBank bank = property.FindPropertyRelative("Sound").FindPropertyRelative("_soundBank").objectReferenceValue as SoundBank;

                if (bank != null)
                {
                    _loopable = bank.GetType() != typeof(AmbienceSoundBank);
                }
            }



            EditorGUI.BeginProperty(position, label, property);
            EditorGUILayout.PropertyField(property, new GUIContent(name), false);
            EditorUtils.ForEachChildProperty(property, DrawProperty);
            EditorGUI.EndProperty();
        }
Exemplo n.º 2
0
        public SoundInstance Fetch(ISoundPool pool)
        {
            if (IsEmpty)
            {
                return(null);
            }

            if (_isBank)
            {
                Type type = _soundBank.GetType();
                if (type == typeof(AmbienceSoundBank))
                {
                    return((_soundBank as AmbienceSoundBank).Fetch(pool));
                }
                if (type == typeof(BlendSoundBank))
                {
                    return((_soundBank as BlendSoundBank).Fetch(pool));
                }
                if (type == typeof(EffectSoundBank))
                {
                    return((_soundBank as EffectSoundBank).Fetch(pool));
                }
                if (type == typeof(ImpactSoundBank))
                {
                    return((_soundBank as ImpactSoundBank).Fetch(pool, 0f));
                }
                if (type == typeof(SequenceSoundBank))
                {
                    return((_soundBank as SequenceSoundBank).Fetch(pool));
                }

                throw new NotImplementedException("SoundBank type not implemented: " + type);
            }

            EffectSoundInstance sound = pool.FetchFromPool <EffectSoundInstance>();

            sound.SetClip(_audioClip);

            return(sound);
        }