public static SoundBank CreateNewSoundBank(Type type, string name)
        {
            SoundBank bank = ScriptableObject.CreateInstance(type) as SoundBank;

            AssetDatabase.CreateAsset(bank, AssetDatabase.GenerateUniqueAssetPath("Assets/" + name + ".asset"));
            AssetDatabase.SaveAssets();

            return(bank);
        }
Exemple #2
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();
        }
Exemple #3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            _bank = target as SoundBank;

            serializedObject.ApplyModifiedProperties();

            SerializedProperty expandFilters = serializedObject.FindProperty("_expandFilterGUI");

            expandFilters.boolValue = EditorGUILayout.Foldout(expandFilters.boolValue, new GUIContent("Filters", "Optional filters to apply to this sound, and all of its child sounds."), true);

            if (expandFilters.boolValue)
            {
                DrawFilterSection();
            }

            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.Separator();

            DrawButtonSection();
            DrawStatusSection();
        }