Example #1
0
        protected override void Setup()
        {
            myScript = (AudioParticles)target;

            sound       = serializedObject.FindProperty("sound");
            soundFile   = serializedObject.FindProperty("soundFile");
            playSoundOn = serializedObject.FindProperty("playSoundOn");
        }
        private void OnEnable()
        {
            myScript = (AudioParticles)target;

            if (AudioManager.instance)
            {
                enumType = AudioManager.instance.GetSceneSoundEnum();
                if (enumType != null)
                {
                    foreach (string s in System.Enum.GetNames(enumType))
                    {
                        options.Add(s);
                    }
                }
            }

            sound       = serializedObject.FindProperty("sound");
            soundFile   = serializedObject.FindProperty("soundFile");
            playSoundOn = serializedObject.FindProperty("playSoundOn");
        }
Example #3
0
        public override void OnInspectorGUI()
        {
            if (am == null)
            {
                am = AudioManager.instance;
            }

            AudioParticles myScript = (AudioParticles)target;

            List <string> options = new List <string>();

            options.Add("None");
            foreach (string s in am.GetSoundDictionary().Keys)
            {
                options.Add(s);
            }

            string sound = serializedObject.FindProperty("sound").stringValue;

            if (sound == "None")
            {
                EditorGUILayout.HelpBox("Choose a sound to play before running!", MessageType.Error);
            }

            DrawDefaultInspector();

            GUIContent soundDesc = new GUIContent("Sound", "Sound that will be played when particles spawn/die");

            if (sound.Equals("") || !options.Contains(sound)) // Default to "None"
            {
                sound = options[EditorGUILayout.Popup(soundDesc, 0, options.ToArray())];
            }
            else
            {
                sound = options[EditorGUILayout.Popup(soundDesc, options.IndexOf(sound), options.ToArray())];
            }

            serializedObject.FindProperty("sound").stringValue = sound;

            serializedObject.ApplyModifiedProperties();
        }
Example #4
0
        public override void OnInspectorGUI()
        {
            AudioParticles myScript = (AudioParticles)target;

            List <string> options = new List <string>();

            System.Type enumType = AudioManager.instance.GetSceneSoundEnum();
            if (enumType == null)
            {
                EditorGUILayout.HelpBox("Could not find Audio File info! Try regenerating Audio Files in AudioManager!", MessageType.Error);
            }
            else
            {
                foreach (string s in System.Enum.GetNames(enumType))
                {
                    options.Add(s);
                }
            }

            EditorGUILayout.LabelField("Choose a Sound to Play", EditorStyles.boldLabel);

            int sound = serializedObject.FindProperty("sound").intValue;

            GUIContent soundDesc = new GUIContent("Sound", "Sound that will be played when particles spawn/die");

            using (new EditorGUI.DisabledScope(myScript.GetAttachedSound() != null))
            {
                serializedObject.FindProperty("sound").intValue = EditorGUILayout.Popup(soundDesc, sound, options.ToArray());
            }

            GUIContent         fileText    = new GUIContent("Custom AudioClip", "Overrides the \"Sound\" parameter with an AudioClip if not null");
            SerializedProperty customSound = serializedObject.FindProperty("soundFile");

            EditorGUILayout.Space();

            GUIContent fontent = new GUIContent("Custom AudioClip Settings", "These settings only apply if you input your own custom AudioClip rather than choosing from the generated Audio Library");

            if (myScript.GetAttachedSound() == null)
            {
                showAudioClipSettings = EditorGUILayout.Foldout(showAudioClipSettings, fontent);
            }
            else
            {
                showAudioClipSettings = EditorGUILayout.BeginFoldoutHeaderGroup(showAudioClipSettings, fontent);
            }
            if (showAudioClipSettings)
            {
                EditorGUILayout.ObjectField(customSound, fileText);
                using (new EditorGUI.DisabledScope(myScript.GetAttachedSound() == null))
                {
                    DrawPropertiesExcluding(serializedObject, new[] { "m_Script", "soundFile", "playOnStart", "playOnEnable",
                                                                      "stopOnDisable", "stopOnDestroy", "playSoundOn" });
                }
            }
            if (myScript.GetAttachedSound() != null)
            {
                EditorGUILayout.EndFoldoutHeaderGroup();
            }
            EditorGUILayout.PropertyField(serializedObject.FindProperty("playSoundOn"));

            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.Space();

            showHowTo = EditorGUILayout.BeginFoldoutHeaderGroup(showHowTo, "Quick Reference Guide");
            if (showHowTo)
            {
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Overview", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox("This component is meant to be attached to a Particle System." +
                                        " When a particle is created or is destroyed, AudioParticles will play a sound."
                                        , MessageType.None);
                EditorGUILayout.HelpBox("This component should be placed on the same GameObject that holds the Particle System."
                                        , MessageType.None);

                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Tips", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox("Feel free to use multiple different AudioParticles components on the same GameObject so your" +
                                        " Particle System plays sounds on both instantiation and destruction!"
                                        , MessageType.None);
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
        }