Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            UmbraAudioArmyKnife umbraAudioArmyKnife = (UmbraAudioArmyKnife)target;

            EditorGUILayout.PropertyField(serializedObject.FindProperty("audioType"));
            switch (umbraAudioArmyKnife.audioType)
            {
            case UmbraAudioArmyKnife.AudioType.Custom:
                EditorGUILayout.HelpBox("With Custom selected, you will be able to associate your own scriptable object (create one with the following menu path Assets->Create->UmbraEvolution->UmbraAudioArmyKnife->AudioKnifeSettings). The settings of this audio source and all audio sources with that scriptable object associated will be controlled by editing the settings on the scriptable object.", MessageType.Info, false);
                break;

            case UmbraAudioArmyKnife.AudioType.Music:
                EditorGUILayout.HelpBox("Settings will be controlled by the scriptable object called MusicDefaults in the UmbraAudioArmyKnife resources folder. Should be used for background music.", MessageType.Info, false);
                break;

            case UmbraAudioArmyKnife.AudioType.Ambient:
                EditorGUILayout.HelpBox("Settings will be controlled by the scriptable object called AmbientDefaults in the UmbraAudioArmyKnife resources folder. Should be used for 3D ambient sound (animals, creaks, wind, music from an in-game source like a radio or bard, etc.)", MessageType.Info, false);
                break;

            case UmbraAudioArmyKnife.AudioType.Triggered:
                EditorGUILayout.HelpBox("Audio will be turned on/off with a trigger located on the same GameObject as this script. Settings are controlled by the scriptable object assigned below (create one with the following menu path Assets->Create->UmbraEvolution->UmbraAudioArmyKnife->AudioKnifeSettings). The settings of this audio source and all audio sources with that scriptable object associated will be controlled by editing the settings on the scriptable object. Should be used for triggered sounds like doors opening, or sound effects you want to happen when the player reaches a certain location in the level.", MessageType.Info, false);
                if (!umbraAudioArmyKnife.GetComponent <Collider>())
                {
                    EditorGUILayout.HelpBox("This GameObject does not have a trigger collider attached, a collider set to be a trigger is required to Play/Stop audio.", MessageType.Warning);
                }
                else if (!umbraAudioArmyKnife.GetComponent <Collider>().isTrigger)
                {
                    EditorGUILayout.HelpBox("This GameObject has a collider attached, but it is not set as a trigger. This mode requires a trigger to Play/Stop audio.", MessageType.Warning);
                }
                break;

            case UmbraAudioArmyKnife.AudioType.SoundEffect2D:
                EditorGUILayout.HelpBox("This cannot be played automatically - you will have to call Play() on this component. Generally used for 2D sound effects like UI button clicks for example. Settings are controlled by the scriptable object called SoundEffect2DDefaults in the UmbraAudioArmyKnife resources folder.", MessageType.Info, false);
                break;

            case UmbraAudioArmyKnife.AudioType.SoundEffect3D:
                EditorGUILayout.HelpBox("This cannot be played automatically - you will have to call Play() on this component. Generally used for one-off 3D sound effects like the player activating a terminal for example. Settings are controlled by the scriptable object called SoundEffect3DDefaults in the UmbraAudioArmyKnife resources folder.", MessageType.Info, false);
                break;
            }

            if (umbraAudioArmyKnife.audioType == UmbraAudioArmyKnife.AudioType.Custom || umbraAudioArmyKnife.audioType == UmbraAudioArmyKnife.AudioType.Triggered)
            {
                if (!umbraAudioArmyKnife.maintainAudioSourceSettings)
                {
                    if (umbraAudioArmyKnife.mySettings != null)
                    {
                        EditorGUILayout.HelpBox("The settings in the AudioSource are being controlled externally by a scriptable object assigned below", MessageType.Info, false);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("You are allowing a scriptable object to control the settings of this AudioSource, but there is no scriptable object assigned in the slot below.", MessageType.Warning);
                    }
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("mySettings"));
                }
                else
                {
                    EditorGUILayout.HelpBox("The AudioSource is maintaining settings instead of allowing the scriptable asset assigned below to modify them", MessageType.Info, false);
                }
            }
            else
            {
                if (!umbraAudioArmyKnife.maintainAudioSourceSettings)
                {
                    EditorGUILayout.HelpBox("The settings in the AudioSource are being controlled externally by a scriptable object in /Assets/UmbraEvolution/UmbraEvolutionAudioKnife/Resources", MessageType.Info, false);
                }
                else
                {
                    EditorGUILayout.HelpBox("The AudioSource is maintaining settings instead of allowing the scriptable asset in /Assets/UmbraEvolution/UmbraEvolutionAudioKnife/Resources to modify them", MessageType.Info, false);
                }
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("maintainAudioSourceSettings"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("volumeModifier"));

            if (umbraAudioArmyKnife.audioType != UmbraAudioArmyKnife.AudioType.SoundEffect2D && umbraAudioArmyKnife.audioType != UmbraAudioArmyKnife.AudioType.SoundEffect3D && !umbraAudioArmyKnife.onlyPlayOnce)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("playAndLoopAutomatically"));
                if (umbraAudioArmyKnife.playAndLoopAutomatically)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("minTimeBetweenPlays"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("maxTimeBetweenPlays"));
                }
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("playRandomChoice"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("fadeIn"));
            if (umbraAudioArmyKnife.fadeIn)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("fadeInTime"));
            }
            EditorGUILayout.PropertyField(serializedObject.FindProperty("fadeOut"));
            if (umbraAudioArmyKnife.fadeOut)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("fadeOutTime"));
            }
            if (umbraAudioArmyKnife.fadeIn || umbraAudioArmyKnife.fadeOut)
            {
                EditorGUILayout.HelpBox("When fading clips in/out be warned that short clips may not appear to play at all.", MessageType.None, false);
            }
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useLoopingClipStructure"));
            if (umbraAudioArmyKnife.useLoopingClipStructure)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("loopUntilStopped"));
                if (!umbraAudioArmyKnife.loopUntilStopped)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("timeToLoop"));
                }
            }

            if (umbraAudioArmyKnife.audioType == UmbraAudioArmyKnife.AudioType.Triggered)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("useTags"));
                if (umbraAudioArmyKnife.useTags)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("triggerTags"), true);
                    if (umbraAudioArmyKnife.triggerTags.Length < 1)
                    {
                        EditorGUILayout.HelpBox("You are checking against tags before the audio is triggered, but no tags are specified. This audio will never play/stop.", MessageType.Warning);
                    }
                }
                EditorGUILayout.PropertyField(serializedObject.FindProperty("playOnEnter"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("playOnExit"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("onlyPlayOnce"));
                if (!umbraAudioArmyKnife.onlyPlayOnce)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("stopOnEnter"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("stopOnExit"));
                }
                EditorGUILayout.PropertyField(serializedObject.FindProperty("minDelayWhenTriggered"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("maxDelayWhenTriggered"));
                if (!umbraAudioArmyKnife.playOnEnter && !umbraAudioArmyKnife.playOnExit)
                {
                    EditorGUILayout.HelpBox("The UmbraAudioArmyKnife is set to Triggered, but it is not set to play on enter or exit and will therefore never play.", MessageType.Warning);
                }
                if (umbraAudioArmyKnife.playOnEnter && umbraAudioArmyKnife.stopOnEnter)
                {
                    EditorGUILayout.HelpBox("The UmbraAudioArmyKnife is set to both play and stop on enter. It can only do one or the other.", MessageType.Warning);
                }
                if (umbraAudioArmyKnife.playOnExit && umbraAudioArmyKnife.stopOnExit)
                {
                    EditorGUILayout.HelpBox("The UmbraAudioArmyKnife is set to both play and stop on exit. It can only do one or the other.", MessageType.Warning);
                }
                if (!umbraAudioArmyKnife.GetComponent <Collider>())
                {
                    EditorGUILayout.HelpBox("The UmbraAudioArmyKnife is set to Triggered, but has no collider and will therefore never play", MessageType.Warning);
                }
                else if (!umbraAudioArmyKnife.GetComponent <Collider>().isTrigger)
                {
                    EditorGUILayout.HelpBox("The UmbraAudioArmyKnife is set to Triggered, but its collider is not set to trigger and it will therefore never play", MessageType.Warning);
                }
            }

            if (umbraAudioArmyKnife.playRandomChoice && umbraAudioArmyKnife.useLoopingClipStructure)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("loopingClips"), true);
                if (umbraAudioArmyKnife.loopingClips.Length < 2)
                {
                    EditorGUILayout.HelpBox("Your UmbraAudioArmyKnife is set to play a random looping clip, but there are less than two looping clips added to the Looping Clips array. If you only want one, turn off the randomization option to save resources.", MessageType.Warning);
                }
                foreach (UmbraAudioArmyKnife.RandomLoopingAudioClip clip in umbraAudioArmyKnife.loopingClips)
                {
                    if (clip.loop.loopingClip == null)
                    {
                        EditorGUILayout.HelpBox("The UmbraAudioArmyKnife has a three-part looping clip structure without either a main clip to loop or an entrance clip and an exit clip.", MessageType.Warning);
                    }
                }
            }
            else if (umbraAudioArmyKnife.playRandomChoice && !umbraAudioArmyKnife.useLoopingClipStructure)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("clips"), true);
                if (umbraAudioArmyKnife.clips.Length < 2)
                {
                    EditorGUILayout.HelpBox("Your UmbraAudioArmyKnife is set to play a random clip, but there are less than two clips added to the Clips array. If you only want one, turn off the randomization option to save resources.", MessageType.Warning);
                }
                foreach (UmbraAudioArmyKnife.RandomAudioClip clip in umbraAudioArmyKnife.clips)
                {
                    if (clip.audioClip == null)
                    {
                        EditorGUILayout.HelpBox("The UmbraAudioArmyKnife is set to play a random clip, but one of the clips in the array is null.", MessageType.Warning);
                    }
                }
            }
            else if (!umbraAudioArmyKnife.playRandomChoice && umbraAudioArmyKnife.useLoopingClipStructure)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("loopingClip"), true);
                if (umbraAudioArmyKnife.loopingClip == null)
                {
                    EditorGUILayout.HelpBox("Your UmbraAudioArmyKnife is set to play a single looping clip, but there is no looping clip assigned.", MessageType.Warning);
                }
                else if (umbraAudioArmyKnife.loopingClip.loopingClip == null)
                {
                    EditorGUILayout.HelpBox("Your UmbraAudioArmyKnife has a looping clip without any looping clip assigned.", MessageType.Warning);
                }
            }
            else if (!umbraAudioArmyKnife.playRandomChoice && !umbraAudioArmyKnife.useLoopingClipStructure)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("clip"));
                if (umbraAudioArmyKnife.clip == null)
                {
                    EditorGUILayout.HelpBox("Your UmbraAudioArmyKnife is set to play a single clip, but there is no clip assigned.", MessageType.Warning);
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(umbraAudioArmyKnife);
            }
            serializedObject.ApplyModifiedProperties();
        }