private void Gradient(string inspector, string keyword)
    {
        bool toggle = oldKeyWords.Contains(keyword);
        bool ini    = toggle;

        GUIContent effectNameLabel = new GUIContent();

        effectNameLabel.tooltip = keyword + " (C#)";
        effectNameLabel.text    = effectCount + "." + inspector;
        toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);

        effectCount++;
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(keyword);

            EditorGUILayout.BeginVertical(style);
            {
                DrawProperty(143, true);
                MaterialProperty gradIsRadial = matProperties[143];
                if (gradIsRadial.floatValue == 1)
                {
                    targetMat.EnableKeyword("RADIALGRADIENT_ON");
                    DrawProperty(31);
                    DrawProperty(32);
                    DrawProperty(34);
                    DrawProperty(141);
                }
                else
                {
                    targetMat.DisableKeyword("RADIALGRADIENT_ON");
                    bool simpleGradient   = oldKeyWords.Contains("GRADIENT2COL_ON");
                    bool simpleGradToggle = EditorGUILayout.Toggle("2 Color Gradient?", simpleGradient);
                    if (simpleGradient && !simpleGradToggle)
                    {
                        targetMat.DisableKeyword("GRADIENT2COL_ON");
                    }
                    else if (!simpleGradient && simpleGradToggle)
                    {
                        targetMat.EnableKeyword("GRADIENT2COL_ON");
                    }
                    DrawProperty(31);
                    DrawProperty(32);
                    if (!simpleGradToggle)
                    {
                        DrawProperty(33);
                    }
                    DrawProperty(34);
                    if (!simpleGradToggle)
                    {
                        DrawProperty(35);
                    }
                    if (!simpleGradToggle)
                    {
                        DrawProperty(141);
                    }
                    DrawProperty(142);
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(keyword);
        }
        EditorGUILayout.EndToggleGroup();
    }
        private void OnGUIPlacing()
        {
            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.LabelField("Placement", EditorStyles.boldLabel);
            _position = EditorGUILayout.Vector3Field("Center position", _position);
            _sizeX    = EditorGUILayout.FloatField("Size X", _sizeX);
            _sizeZ    = EditorGUILayout.FloatField("Size Z", _sizeZ);
            _rotation = EditorGUILayout.FloatField("Rotation", _rotation);

            EditorGUILayout.Space();

            _createDepthCache = EditorGUILayout.BeginToggleGroup("Create Depth Cache", _createDepthCache);
            _depthCacheLayers = EditorHelpers.EditorHelpers.LayerMaskField("Layers for cache", _depthCacheLayers);
            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.Space();

            _createGerstnerWaves   = EditorGUILayout.BeginToggleGroup("Create Gerstner Waves", _createGerstnerWaves);
            _gerstnerWindDirection = EditorGUILayout.FloatField("Wind direction angle", _gerstnerWindDirection);
            _gerstnerWaveSpectrum  = EditorGUILayout.ObjectField("Wave spectrum", _gerstnerWaveSpectrum, typeof(OceanWaveSpectrum), false) as OceanWaveSpectrum;
            _gerstnerMaterial      = EditorGUILayout.ObjectField("Gerstner material", _gerstnerMaterial, typeof(Material), false) as Material;
            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.Space();

            _createClipArea = EditorGUILayout.BeginToggleGroup("Create Clip Area", _createClipArea);
            _clipMaterial   = EditorGUILayout.ObjectField("Clip material", _clipMaterial, typeof(Material), false) as Material;
            if (_createClipArea)
            {
                EditorGUILayout.HelpBox("Create Clip Surface Data should be enabled on the OceanRnederer component, and the Default Clipping State should be set to Everything Clipped.", MessageType.Info);
            }
            EditorGUILayout.EndToggleGroup();

            if (EditorGUI.EndChangeCheck())
            {
                UpdateProxy();
                SceneView.RepaintAll();
            }

            EditorGUILayout.Space();

            var created = false;

            if (GUILayout.Button("Create"))
            {
                CreateWaterBody();
                created = true;
            }

            if (created || GUILayout.Button("Done"))
            {
                _state = State.Idle;

                // Refresh scene view
                GetWindow <SceneView>();
            }

            EditorGUILayout.EndScrollView();
        }
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();

        EditorGUI.indentLevel = 1;
        var isDirty = false;

        _variation = (DynamicGroupVariation)target;

        if (MasterAudioInspectorResources.logoTexture != null)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.logoTexture);
        }

        EditorGUI.indentLevel = 0;  // Space will handle this for the header

        DynamicSoundGroupCreator creator = null;

        if (_variation.transform.parent != null && _variation.transform.parent.parent != null)
        {
            creator = _variation.transform.parent.parent.GetComponent <DynamicSoundGroupCreator>();
        }

        if (creator == null)
        {
            DTGUIHelper.ShowRedError("This prefab must have DynamicSoundGroupCreator 2 parents up.");
            return;
        }

        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        GUI.contentColor = Color.green;
        if (GUILayout.Button(new GUIContent("Back to Group", "Select Group in Hierarchy"), EditorStyles.toolbarButton, GUILayout.Width(120)))
        {
            Selection.activeObject = _variation.transform.parent.gameObject;
        }
        GUILayout.FlexibleSpace();
        GUI.contentColor = Color.white;

        var buttonPressed = DTGUIHelper.AddDynamicVariationButtons();

        switch (buttonPressed)
        {
        case DTGUIHelper.DTFunctionButtons.Play:
            isDirty = true;
            if (_variation.audLocation == MasterAudio.AudioLocation.ResourceFile)
            {
                creator.PreviewerInstance.Stop();
                creator.PreviewerInstance.PlayOneShot(Resources.Load(_variation.resourceFileName) as AudioClip);
            }
            else
            {
                PlaySound(_variation.audio);
            }
            break;

        case DTGUIHelper.DTFunctionButtons.Stop:
            if (_variation.audLocation == MasterAudio.AudioLocation.ResourceFile)
            {
                creator.PreviewerInstance.Stop();
            }
            else
            {
                StopSound(_variation.audio);
            }
            break;
        }

        EditorGUILayout.EndHorizontal();

        if (!Application.isPlaying)
        {
            DTGUIHelper.ShowColorWarning("*Fading & random settings are ignored by preview in edit mode.");
        }

        var oldLocation = _variation.audLocation;
        var newLocation = (MasterAudio.AudioLocation)EditorGUILayout.EnumPopup("Audio Origin", _variation.audLocation);

        if (newLocation != oldLocation)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation, "change Audio Origin");
            _variation.audLocation = newLocation;
        }

        switch (_variation.audLocation)
        {
        case MasterAudio.AudioLocation.Clip:
            var newClip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", _variation.audio.clip, typeof(AudioClip), false);

            if (newClip != _variation.audio.clip)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation.audio, "assign Audio Clip");
                _variation.audio.clip = newClip;
            }
            break;

        case MasterAudio.AudioLocation.ResourceFile:
            if (oldLocation != _variation.audLocation)
            {
                if (_variation.audio.clip != null)
                {
                    Debug.Log("Audio clip removed to prevent unnecessary memory usage on Resource file Variation.");
                }
                _variation.audio.clip = null;
            }

            EditorGUILayout.BeginVertical();
            var anEvent = Event.current;

            GUI.color = Color.yellow;
            var dragArea = GUILayoutUtility.GetRect(0f, 20f, GUILayout.ExpandWidth(true));
            GUI.Box(dragArea, "Drag Resource Audio clip here to use its name!");
            GUI.color = Color.white;

            var newFilename = string.Empty;

            switch (anEvent.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (!dragArea.Contains(anEvent.mousePosition))
                {
                    break;
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                if (anEvent.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();

                    foreach (var dragged in DragAndDrop.objectReferences)
                    {
                        var aClip = dragged as AudioClip;
                        if (aClip == null)
                        {
                            continue;
                        }

                        newFilename = DTGUIHelper.GetResourcePath(aClip);
                        if (string.IsNullOrEmpty(newFilename))
                        {
                            newFilename = aClip.name;
                        }

                        if (newFilename != _variation.resourceFileName)
                        {
                            UndoHelper.RecordObjectPropertyForUndo(_variation, "change Resource filename");
                            _variation.resourceFileName = aClip.name;
                        }
                        break;
                    }
                }
                Event.current.Use();
                break;
            }
            EditorGUILayout.EndVertical();

            newFilename = EditorGUILayout.TextField("Resource Filename", _variation.resourceFileName);
            if (newFilename != _variation.resourceFileName)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Resource filename");
                _variation.resourceFileName = newFilename;
            }
            break;
        }

        var newVolume = EditorGUILayout.Slider("Volume", _variation.audio.volume, 0f, 1f);

        if (newVolume != _variation.audio.volume)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation.audio, "change Volume");
            _variation.audio.volume = newVolume;
        }

        var newPitch = EditorGUILayout.Slider("Pitch", _variation.audio.pitch, -3f, 3f);

        if (newPitch != _variation.audio.pitch)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation.audio, "change Pitch");
            _variation.audio.pitch = newPitch;
        }

        var newLoop = EditorGUILayout.Toggle("Loop Clip", _variation.audio.loop);

        if (newLoop != _variation.audio.loop)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation.audio, "toggle Loop");
            _variation.audio.loop = newLoop;
        }


        var newWeight = EditorGUILayout.IntSlider("Weight (Instances)", _variation.weight, 0, 100);

        if (newWeight != _variation.weight)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation, "change Weight");
            _variation.weight = newWeight;
        }

        if (_variation.HasActiveFXFilter)
        {
            var newFxTailTime = EditorGUILayout.Slider("FX Tail Time", _variation.fxTailTime, 0f, 10f);
            if (newFxTailTime != _variation.fxTailTime)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change FX Tail Time");
                _variation.fxTailTime = newFxTailTime;
            }
        }

        var newUseRndPitch = EditorGUILayout.BeginToggleGroup("Use Random Pitch", _variation.useRandomPitch);

        if (newUseRndPitch != _variation.useRandomPitch)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation, "toggle Use Random Pitch");
            _variation.useRandomPitch = newUseRndPitch;
        }

        if (_variation.useRandomPitch)
        {
            var newMode = (SoundGroupVariation.RandomPitchMode)EditorGUILayout.EnumPopup("Pitch Compute Mode", _variation.randomPitchMode);
            if (newMode != _variation.randomPitchMode)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Pitch Compute Mode");
                _variation.randomPitchMode = newMode;
            }

            var newPitchMin = EditorGUILayout.Slider("Random Pitch Min", _variation.randomPitchMin, -3f, 3f);
            if (newPitchMin != _variation.randomPitchMin)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Random Pitch Min");
                _variation.randomPitchMin = newPitchMin;
                if (_variation.randomPitchMax <= _variation.randomPitchMin)
                {
                    _variation.randomPitchMax = _variation.randomPitchMin;
                }
            }

            var newPitchMax = EditorGUILayout.Slider("Random Pitch Max", _variation.randomPitchMax, -3f, 3f);
            if (newPitchMax != _variation.randomPitchMax)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Random Pitch Max");
                _variation.randomPitchMax = newPitchMax;
                if (_variation.randomPitchMin > _variation.randomPitchMax)
                {
                    _variation.randomPitchMin = _variation.randomPitchMax;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();

        var newUseRndVol = EditorGUILayout.BeginToggleGroup("Use Random Volume", _variation.useRandomVolume);

        if (newUseRndVol != _variation.useRandomVolume)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation, "toggle Use Random Volume");
            _variation.useRandomVolume = newUseRndVol;
        }

        if (_variation.useRandomVolume)
        {
            var newMode = (SoundGroupVariation.RandomVolumeMode)EditorGUILayout.EnumPopup("Volume Compute Mode", _variation.randomVolumeMode);
            if (newMode != _variation.randomVolumeMode)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Volume Compute Mode");
                _variation.randomVolumeMode = newMode;
            }

            var volMin = 0f;
            if (_variation.randomVolumeMode == SoundGroupVariation.RandomVolumeMode.AddToClipVolume)
            {
                volMin = -1f;
            }

            var newVolMin = EditorGUILayout.Slider("Random Volume Min", _variation.randomVolumeMin, volMin, 1f);
            if (newVolMin != _variation.randomVolumeMin)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Random Volume Min");
                _variation.randomVolumeMin = newVolMin;
                if (_variation.randomVolumeMax <= _variation.randomVolumeMin)
                {
                    _variation.randomVolumeMax = _variation.randomVolumeMin;
                }
            }

            var newVolMax = EditorGUILayout.Slider("Random Volume Max", _variation.randomVolumeMax, volMin, 1f);
            if (newVolMax != _variation.randomVolumeMax)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Random Volume Max");
                _variation.randomVolumeMax = newVolMax;
                if (_variation.randomVolumeMin > _variation.randomVolumeMax)
                {
                    _variation.randomVolumeMin = _variation.randomVolumeMax;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();

        var newSilence = EditorGUILayout.BeginToggleGroup("Use Random Delay", _variation.useIntroSilence);

        if (newSilence != _variation.useIntroSilence)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation, "toggle Use Random Delay");
            _variation.useIntroSilence = newSilence;
        }

        if (_variation.useIntroSilence)
        {
            var newSilenceMin = EditorGUILayout.Slider("Delay Min (sec)", _variation.introSilenceMin, 0f, 100f);
            if (newSilenceMin != _variation.introSilenceMin)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Delay Min (sec)");
                _variation.introSilenceMin = newSilenceMin;
                if (_variation.introSilenceMin > _variation.introSilenceMax)
                {
                    _variation.introSilenceMax = newSilenceMin;
                }
            }

            var newSilenceMax = EditorGUILayout.Slider("Delay Max (sec)", _variation.introSilenceMax, 0f, 100f);
            if (newSilenceMax != _variation.introSilenceMax)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Delay Max (sec)");
                _variation.introSilenceMax = newSilenceMax;
                if (_variation.introSilenceMax < _variation.introSilenceMin)
                {
                    _variation.introSilenceMin = newSilenceMax;
                }
            }
        }
        EditorGUILayout.EndToggleGroup();

        var newUseFades = EditorGUILayout.BeginToggleGroup("Use Custom Fading", _variation.useFades);

        if (newUseFades != _variation.useFades)
        {
            UndoHelper.RecordObjectPropertyForUndo(_variation, "toggle Use Custom Fading");
            _variation.useFades = newUseFades;
        }

        if (_variation.useFades)
        {
            var newFadeIn = EditorGUILayout.Slider("Fade In Time (sec)", _variation.fadeInTime, 0f, 10f);
            if (newFadeIn != _variation.fadeInTime)
            {
                UndoHelper.RecordObjectPropertyForUndo(_variation, "change Fade In Time");
                _variation.fadeInTime = newFadeIn;
            }

            if (_variation.audio.loop)
            {
                DTGUIHelper.ShowColorWarning("*Looped clips cannot have a custom fade out.");
            }
            else
            {
                var newFadeOut = EditorGUILayout.Slider("Fade Out time (sec)", _variation.fadeOutTime, 0f, 10f);
                if (newFadeOut != _variation.fadeOutTime)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_variation, "change Fade Out Time");
                    _variation.fadeOutTime = newFadeOut;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();

        var filterList = new List <string>()
        {
            MasterAudio.NO_GROUP_NAME,
            "Low Pass",
            "High Pass",
            "Distortion",
            "Chorus",
            "Echo",
            "Reverb"
        };

        var newFilterIndex = EditorGUILayout.Popup("Add Filter Effect", 0, filterList.ToArray());

        switch (newFilterIndex)
        {
        case 1:
            AddFilterComponent(typeof(AudioLowPassFilter));
            break;

        case 2:
            AddFilterComponent(typeof(AudioHighPassFilter));
            break;

        case 3:
            AddFilterComponent(typeof(AudioDistortionFilter));
            break;

        case 4:
            AddFilterComponent(typeof(AudioChorusFilter));
            break;

        case 5:
            AddFilterComponent(typeof(AudioEchoFilter));
            break;

        case 6:
            AddFilterComponent(typeof(AudioReverbFilter));
            break;
        }

        if (GUI.changed || isDirty)
        {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
Exemplo n.º 4
0
    public override void OnInspectorGUI()
    {
        paddingStyle1         = new GUIStyle();
        paddingStyle1.padding = new RectOffset(15, 0, 0, 0);
        EasyTouch t = (EasyTouch)target;

        HTGUILayout.FoldOut(ref t.showGeneral, "General properties", false);
        if (t.showGeneral)
        {
            if (t.enable)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enable = EditorGUILayout.Toggle("Enable EasyTouch", t.enable);
            if (t.enableRemote)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enableRemote = EditorGUILayout.Toggle("Enable unity remote", t.enableRemote);


            if (t.useBroadcastMessage)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.useBroadcastMessage = EditorGUILayout.BeginToggleGroup("Broadcast messages", t.useBroadcastMessage);
            GUI.backgroundColor   = Color.white;
            if (t.useBroadcastMessage)
            {
                EditorGUILayout.BeginVertical(paddingStyle1);
                t.receiverObject = (GameObject)EditorGUILayout.ObjectField("Other receiver", t.receiverObject, typeof(GameObject), true);
                if (t.isExtension)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.isExtension       = EditorGUILayout.Toggle("Joysticks & buttons", t.isExtension);
                GUI.backgroundColor = Color.white;
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.Space();

            if (t.enableReservedArea)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enableReservedArea = EditorGUILayout.Toggle("Enable reserved area", t.enableReservedArea);
            EditorGUILayout.Space();
            if (t.enabledNGuiMode)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enabledNGuiMode   = EditorGUILayout.Toggle("Enable NGUI compatibilty", t.enabledNGuiMode);
            GUI.backgroundColor = Color.white;
            if (t.enabledNGuiMode)
            {
                EditorGUILayout.BeginVertical(paddingStyle1);

                // Camera
                serializedObject.Update();
                //EditorGUIUtility.LookLikeInspector();
                SerializedProperty cameras = serializedObject.FindProperty("nGUICameras");
                EditorGUILayout.PropertyField(cameras, true);
                serializedObject.ApplyModifiedProperties();
                EditorGUIUtility.LookLikeControls();

                EditorGUILayout.Space();

                // layers
                serializedObject.Update();
                //EditorGUIUtility.LookLikeInspector();
                SerializedProperty layers = serializedObject.FindProperty("nGUILayers");
                EditorGUILayout.PropertyField(layers, false);
                serializedObject.ApplyModifiedProperties();
                EditorGUIUtility.LookLikeControls();

                EditorGUILayout.EndVertical();
            }
        }

        if (t.enable)
        {
            // Auto select porperties
            HTGUILayout.FoldOut(ref t.showSelect, "Auto-select properties", false);
            if (t.showSelect)
            {
                //	t.touchCameras = (Camera)EditorGUILayout.ObjectField("Camera",t.touchCameras,typeof(Camera),true);
                if (HTGUILayout.Button("Add Camera", Color.green, 100))
                {
                    t.touchCameras.Add(new ECamera(null, false));
                }
                for (int i = 0; i < t.touchCameras.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (HTGUILayout.Button("X", Color.red, 19))
                    {
                        t.touchCameras.RemoveAt(i);
                        i--;
                    }
                    if (i >= 0)
                    {
                        t.touchCameras[i].camera = (Camera)EditorGUILayout.ObjectField("", t.touchCameras[i].camera, typeof(Camera), true);
                        EditorGUILayout.LabelField("Gui", GUILayout.Width(50));
                        t.touchCameras[i].guiCamera = EditorGUILayout.Toggle("", t.touchCameras[i].guiCamera);
                        EditorGUILayout.EndHorizontal();
                    }
                }
                HTGUILayout.DrawSeparatorLine();

                if (t.autoSelect)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.autoSelect        = EditorGUILayout.Toggle("Enable auto-select", t.autoSelect);
                GUI.backgroundColor = Color.white;
                if (t.autoSelect)
                {
                    serializedObject.Update();
                    //EditorGUIUtility.LookLikeInspector();
                    SerializedProperty layers = serializedObject.FindProperty("pickableLayers");
                    EditorGUILayout.PropertyField(layers, true);
                    serializedObject.ApplyModifiedProperties();
                    EditorGUIUtility.LookLikeControls();

                    EditorGUILayout.Space();

                    if (t.enable2D)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    t.enable2D          = EditorGUILayout.Toggle("2D collider", t.enable2D);
                    GUI.backgroundColor = Color.white;
                    if (t.enable2D)
                    {
                        serializedObject.Update();
                        //EditorGUIUtility.LookLikeInspector();
                        layers = serializedObject.FindProperty("pickableLayers2D");
                        EditorGUILayout.PropertyField(layers, true);
                        serializedObject.ApplyModifiedProperties();
                        EditorGUIUtility.LookLikeControls();
                    }
                }
            }

            // General gesture properties
            HTGUILayout.FoldOut(ref t.showGesture, "General gesture properties", false);
            if (t.showGesture)
            {
                t.StationnaryTolerance = EditorGUILayout.FloatField("Stationary tolerance", t.StationnaryTolerance);
                t.longTapTime          = EditorGUILayout.FloatField("Long tap time", t.longTapTime);
                t.swipeTolerance       = EditorGUILayout.FloatField("Swipe tolerance", t.swipeTolerance);
            }

            // Two fingers gesture
            HTGUILayout.FoldOut(ref t.showTwoFinger, "Two fingers gesture properties", false);
            if (t.showTwoFinger)
            {
                if (t.enable2FingersGesture)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.enable2FingersGesture = EditorGUILayout.Toggle("2 fingers gesture", t.enable2FingersGesture);
                GUI.backgroundColor     = Color.white;
                if (t.enable2FingersGesture)
                {
                    EditorGUILayout.Separator();
                    if (t.enablePinch)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    t.enablePinch       = EditorGUILayout.Toggle("Enable Pinch", t.enablePinch);
                    GUI.backgroundColor = Color.white;
                    if (t.enablePinch)
                    {
                        t.minPinchLength = EditorGUILayout.FloatField("Min pinch length", t.minPinchLength);
                    }
                    EditorGUILayout.Separator();
                    if (t.enableTwist)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    t.enableTwist       = EditorGUILayout.Toggle("Enable twist", t.enableTwist);
                    GUI.backgroundColor = Color.white;
                    if (t.enableTwist)
                    {
                        t.minTwistAngle = EditorGUILayout.FloatField("Min twist angle", t.minTwistAngle);
                    }

                    EditorGUILayout.Separator();
                }
            }

            // Second Finger simulation
            HTGUILayout.FoldOut(ref t.showSecondFinger, "Second finger simulation", false);
            if (t.showSecondFinger)
            {
                if (t.secondFingerTexture == null)
                {
                    t.secondFingerTexture = Resources.Load("secondFinger") as Texture;
                }

                t.secondFingerTexture = (Texture)EditorGUILayout.ObjectField("Texture", t.secondFingerTexture, typeof(Texture), true);
                EditorGUILayout.HelpBox("Change the keys settings for a fash compilation, or if you want to change the keys", MessageType.Info);
                t.twistKey = (KeyCode)EditorGUILayout.EnumPopup("Twist & pinch key", t.twistKey);
                t.swipeKey = (KeyCode)EditorGUILayout.EnumPopup("Swipe key", t.swipeKey);
            }
        }
    }
Exemplo n.º 5
0
    public override void OnInspectorGUI()
    {
        MegaPointCache am = (MegaPointCache)target;

        DoAdjustFirst = EditorGUILayout.Toggle("Mapping Adjust", DoAdjustFirst);
        uselastframe  = EditorGUILayout.Toggle("Use Last Frame", uselastframe);

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Import PC2"))
        {
            LoadPC2();
            EditorUtility.SetDirty(target);
        }

        if (GUILayout.Button("Import MDD"))
        {
            LoadMDD();
            EditorUtility.SetDirty(target);
        }

        if (GUILayout.Button("Import MC"))
        {
            LoadMCC();
            EditorUtility.SetDirty(target);
        }

        EditorGUILayout.EndHorizontal();

        // Basic mod stuff
        showmodparams = EditorGUILayout.Foldout(showmodparams, "Modifier Common Params");

        if (showmodparams)
        {
            CommonModParamsBasic(am);
        }

        // Advanced
        showadvanced = EditorGUILayout.Foldout(showadvanced, "Advanced Params");

        if (showadvanced)
        {
            tolerance = EditorGUILayout.FloatField("Map Tolerance", tolerance * 100.0f) / 100.0f;
            if (am.Verts != null && am.Verts.Length > 0)                //[0] != null )
            {
                am.showmapping = EditorGUILayout.BeginToggleGroup("Show Mapping", am.showmapping);
                am.mapStart    = EditorGUILayout.IntSlider("StartVert", am.mapStart, 0, am.Verts.Length);
                am.mapEnd      = EditorGUILayout.IntSlider("endVert", am.mapEnd, 0, am.Verts.Length);
                am.mappingSize = EditorGUILayout.Slider("Size", am.mappingSize, 0.0005f, 10.01f);
                EditorGUILayout.EndToggleGroup();
            }

            //morph.tolerance = EditorGUILayout.Slider("Tolerance", morph.tolerance, 0.0f, 0.01f);
        }

        am.time         = EditorGUILayout.FloatField("Time", am.time);
        am.maxtime      = EditorGUILayout.FloatField("Loop Time", am.maxtime);
        am.animated     = EditorGUILayout.Toggle("Animated", am.animated);
        am.framedelay   = EditorGUILayout.Toggle("Frame Delay", am.framedelay);
        am.ignoreFirst  = EditorGUILayout.Toggle("Ignore First Frame", am.ignoreFirst);
        am.speed        = EditorGUILayout.FloatField("Speed", am.speed);
        am.LoopMode     = (MegaRepeatMode)EditorGUILayout.EnumPopup("Loop Mode", am.LoopMode);
        am.interpMethod = (MegaInterpMethod)EditorGUILayout.EnumPopup("Interp Method", am.interpMethod);

        am.blendMode = (MegaBlendAnimMode)EditorGUILayout.EnumPopup("Blend Mode", am.blendMode);
        if (am.blendMode == MegaBlendAnimMode.Additive)
        {
            am.weight = EditorGUILayout.FloatField("Weight", am.weight);
        }

        if (am.Verts != null && am.Verts.Length > 0)
        {
            int mem = am.Verts.Length * am.Verts[0].points.Length * 12;
            EditorGUILayout.LabelField("Memory: ", (mem / 1024) + "KB");
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Exemplo n.º 6
0
        private void MainGUI()
        {
            var defaultColor = GUI.backgroundColor;

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            EditorGUILayout.LabelField("MODS", new GUIStyle()
            {
                alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold
            });
            EditorGUILayout.BeginVertical(GUI.skin.box);
            foreach (Transform child in GetModsObject().transform)
            {
                var modObject   = child.gameObject;
                var modInfoList = allModInfoListView[avatarName];

                if (!modInfoList.ContainsKey(modObject.GetInstanceID()))
                {
                    var mi = new ModInfo()
                    {
                        isEnabled = true, autoSelectSource = true, isHumanoid = false
                    };
                    if (IsHumanoid(modObject))
                    {
                        mi.isHumanoid = true;
                    }
                    modInfoList.Add(modObject.GetInstanceID(), mi);
                }
                var modInfo = modInfoList[modObject.GetInstanceID()];
                if (Selection.activeGameObject != null && Selection.activeGameObject == modObject)
                {
                    GUI.backgroundColor = new Color(0.5f, 1f, 0.5f);
                }
                else
                {
                    GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f);
                }
                EditorGUILayout.BeginVertical(GUI.skin.box);
                modInfo.isEnabled = EditorGUILayout.BeginToggleGroup(modObject.name, modInfo.isEnabled);
                if (!IsHumanoid(modObject))
                {
                    GUI.enabled = false;
                }
                modInfo.isHumanoid = EditorGUILayout.Toggle(englishMode ? "Is humanoid" : "関節を接続", modInfo.isHumanoid);
                GUI.enabled        = true;
                if (!modInfo.isHumanoid)
                {
                    EditorGUILayout.LabelField("");
                    EditorGUILayout.LabelField(englishMode ? "Object joint settings" : "オブジェクト接続設定", new GUIStyle()
                    {
                        fontStyle = FontStyle.Bold
                    });
                    modInfo.autoSelectSource = EditorGUILayout.Toggle(englishMode ? "Auto select source" : "ソース自動選択", modInfo.autoSelectSource);
                    if (modInfo.autoSelectSource)
                    {
                        GUI.enabled = false;
                        var        bones       = GetAllChildren(GetArmatureObject(avatarObject));
                        GameObject nearestBone = bones.OrderByDescending(b => Vector3.Distance(b.transform.position, modObject.transform.position)).LastOrDefault();
                        if (nearestBone != null)
                        {
                            modInfo.genericSourceObjectID = nearestBone.GetInstanceID();
                        }
                    }
                    var sourceObject      = modInfo.genericSourceObjectID == null ? null : EditorUtility.InstanceIDToObject((int)modInfo.genericSourceObjectID);
                    var inputSourceObject = EditorGUILayout.ObjectField(englishMode ? "Source" : "ソース", sourceObject, typeof(GameObject), true);
                    if (inputSourceObject == null)
                    {
                        modInfo.genericSourceObjectID = null;
                    }
                    else
                    {
                        modInfo.genericSourceObjectID = inputSourceObject.GetInstanceID();
                    }
                    GUI.enabled = true;
                }
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.EndVertical();
            }
            GUI.backgroundColor = defaultColor;
            EditorGUILayout.EndVertical();
            if (GUILayout.Button(englishMode ? "Assembly" : "組み込み実行"))
            {
                Activate();
            }
        }
Exemplo n.º 7
0
    public void OnGUI()
    {
        genClass.OnGUI();

        useTexturing = EditorGUILayout.BeginToggleGroup("Setup textures", useTexturing);

        if (useTexturing)
        {
            if (GUILayout.Button("Clear all textures"))
            {
                List <TTexture> textures = new List <TTexture>();
                TerrainTexturing.GenerateTexture(textures);
            }

            foreach (var texture in texClass)
            {
                texture.OnGUI();
            }

            if (texClass.Count > 0)
            {
                if (GUILayout.Button("Delete last"))
                {
                    texClass.RemoveAt(texClass.Count - 1);
                }
            }

            if (GUILayout.Button("Add texture"))
            {
                texClass.Add(new wbTexturing());
            }

            if (texClass.Count > 0 && texClass[texClass.Count - 1].texture != null)
            {
                if (GUILayout.Button("Assign new textures"))
                {
                    List <TTexture> textures = new List <TTexture>();
                    for (int i = 0; i < texClass.Count; i++)
                    {
                        TTexture TTex = new TTexture();
                        TTex.texture = texClass[i].texture;
                        //TTex.color = texClass[i].color;
                        TTex.useBump = texClass[i].useBump;
                        if (texClass[i].useBump)
                        {
                            TTex.bumpmap = texClass[i].bumpmap;
                        }
                        else
                        {
                            TTex.bumpmap = texClass[i].emptyBump;
                        }
                        TTex.tilesize    = texClass[i].tilesize;
                        TTex.index       = texClass[i].index;
                        TTex.heightCurve = texClass[i].heightCurve;
                        TTex.angleCurve  = texClass[i].angleCurve;
                        textures.Add(TTex);
                    }
                    TerrainTexturing.GenerateTexture(textures);
                }
            }
        }
        EditorGUILayout.EndToggleGroup();

        useFoliage = EditorGUILayout.BeginToggleGroup("Setup foliage", useFoliage);

        if (useFoliage)
        {
            waterCoast   = EditorGUILayout.FloatField("Tree distance from coast", waterCoast);
            maxSteepness = EditorGUILayout.FloatField("Max hill angle for trees", maxSteepness);

            if (GUILayout.Button("Generate trees"))
            {
                TerrainFoliage.maxSteepness = maxSteepness;
                if (GameObject.Find("Water"))
                {
                    TerrainFoliage.waterLevel = GameObject.Find("Water").transform.position.y + waterCoast;
                }
                else
                {
                    TerrainFoliage.waterLevel = 0.0f;
                }
                TerrainFoliage.GenerateFoliage(0.0f);
            }

            if (GUILayout.Button("Remove trees"))
            {
                TerrainFoliage.ClearTrees();
            }

            grassDensity = EditorGUILayout.IntField("Grass density", grassDensity);

            if (GUILayout.Button("Generate grass"))
            {
                TerrainFoliage.GenerateGrass();
            }

            if (GUILayout.Button("Remove grass"))
            {
                TerrainFoliage.ClearGrass();
            }
        }

        EditorGUILayout.EndToggleGroup();
    }
Exemplo n.º 8
0
    // ReSharper disable once FunctionComplexityOverflow
    public override void OnInspectorGUI()
    {
        EditorGUI.indentLevel = 0;
        var isDirty = false;

        _variation = (SoundGroupVariation)target;

        if (MasterAudioInspectorResources.LogoTexture != null)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.LogoTexture);
        }

        var parentGroup = _variation.ParentGroup;

        if (parentGroup == null)
        {
            DTGUIHelper.ShowLargeBarAlert("This file cannot be edited in Project View.");
            return;
        }

        AudioSource previewer;

        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        GUI.contentColor = DTGUIHelper.BrightButtonColor;
        if (GUILayout.Button(new GUIContent("Back to Group", "Select Group in Hierarchy"), EditorStyles.toolbarButton, GUILayout.Width(90)))
        {
            Selection.activeObject = _variation.transform.parent.gameObject;
        }
        GUILayout.FlexibleSpace();

        if (Application.isPlaying)
        {
            // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
            if (_variation.IsPlaying && _variation.VarAudio.clip != null)   // wait for Resource files to load
            {
                GUI.color = Color.green;

                var label = "Playing ({0}%)";

                if (AudioUtil.IsAudioPaused(_variation.VarAudio))
                {
                    GUI.color = Color.yellow;
                    label     = "Paused ({0}%)";
                }

                var percentagePlayed = (int)(_variation.VarAudio.time / _variation.VarAudio.clip.length * 100);

                EditorGUILayout.LabelField(string.Format(label, percentagePlayed),
                                           EditorStyles.miniButtonMid, GUILayout.Height(16), GUILayout.Width(240));

                _variation.frames++;
                isDirty = true;

                GUI.color = DTGUIHelper.BrightButtonColor;
                if (_variation.ObjectToFollow != null || _variation.ObjectToTriggerFrom != null)
                {
                    if (GUILayout.Button("Select Caller", EditorStyles.miniButton, GUILayout.Width(80)))
                    {
                        if (_variation.ObjectToFollow != null)
                        {
                            Selection.activeGameObject = _variation.ObjectToFollow.gameObject;
                        }
                        else
                        {
                            Selection.activeGameObject = _variation.ObjectToTriggerFrom.gameObject;
                        }
                    }
                }
            }
            else
            {
                GUI.color = Color.red;
                EditorGUILayout.LabelField("Not playing", EditorStyles.miniButtonMid, GUILayout.Height(16), GUILayout.Width(240));
            }
        }

        GUI.color        = Color.white;
        GUI.contentColor = Color.white;

        _ma = MasterAudio.Instance;
        var maInScene = _ma != null;

        var canPreview = !DTGUIHelper.IsPrefabInProjectView(_variation);

        if (maInScene)
        {
            var buttonPressed = DTGUIHelper.DTFunctionButtons.None;
            if (canPreview)
            {
                buttonPressed = DTGUIHelper.AddVariationButtons();
            }

            switch (buttonPressed)
            {
            case DTGUIHelper.DTFunctionButtons.Play:
                previewer = MasterAudioInspector.GetPreviewer();

                if (Application.isPlaying)
                {
                    MasterAudio.PlaySound3DAtVector3AndForget(_variation.ParentGroup.name, previewer.transform.position, 1f, null, 0f, _variation.name);
                }
                else
                {
                    isDirty = true;

                    var randPitch = GetRandomPreviewPitch(_variation);
                    var varVol    = GetRandomPreviewVolume(_variation);

                    if (_variation.audLocation != MasterAudio.AudioLocation.FileOnInternet)
                    {
                        if (previewer != null)
                        {
                            MasterAudioInspector.StopPreviewer();
                            previewer.pitch = randPitch;
                        }
                    }

                    var calcVolume = varVol * parentGroup.groupMasterVolume;

                    switch (_variation.audLocation)
                    {
                    case MasterAudio.AudioLocation.ResourceFile:
                        if (previewer != null)
                        {
                            var fileName = AudioResourceOptimizer.GetLocalizedFileName(_variation.useLocalization, _variation.resourceFileName);
                            previewer.PlayOneShot(Resources.Load(fileName) as AudioClip, calcVolume);
                        }
                        break;

                    case MasterAudio.AudioLocation.Clip:
                        if (previewer != null)
                        {
                            previewer.PlayOneShot(_variation.VarAudio.clip, calcVolume);
                        }
                        break;

                    case MasterAudio.AudioLocation.FileOnInternet:
                        if (!string.IsNullOrEmpty(_variation.internetFileUrl))
                        {
                            Application.OpenURL(_variation.internetFileUrl);
                        }
                        break;
                    }
                }
                break;

            case DTGUIHelper.DTFunctionButtons.Stop:
                if (Application.isPlaying)
                {
                    MasterAudio.StopAllOfSound(_variation.transform.parent.name);
                }
                else
                {
                    if (_variation.audLocation != MasterAudio.AudioLocation.FileOnInternet)
                    {
                        MasterAudioInspector.StopPreviewer();
                    }
                }
                break;
            }
        }

        EditorGUILayout.EndHorizontal();

        DTGUIHelper.HelpHeader("http://www.dtdevtools.com/docs/masteraudio/SoundGroupVariations.htm", "http://www.dtdevtools.com/API/masteraudio/class_dark_tonic_1_1_master_audio_1_1_sound_group_variation.html");

        if (maInScene && !Application.isPlaying)
        {
            DTGUIHelper.ShowColorWarning(MasterAudio.PreviewText);
        }

        var oldLocation = _variation.audLocation;

        EditorGUILayout.BeginHorizontal();
        if (!Application.isPlaying)
        {
            var newLocation =
                (MasterAudio.AudioLocation)EditorGUILayout.EnumPopup("Audio Origin", _variation.audLocation);

            if (newLocation != oldLocation)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Audio Origin");
                _variation.audLocation = newLocation;
            }
        }
        else
        {
            EditorGUILayout.LabelField("Audio Origin", _variation.audLocation.ToString());
        }
        DTGUIHelper.AddHelpIcon("http://www.dtdevtools.com/docs/masteraudio/SoundGroupVariations.htm#AudioOrigin");
        EditorGUILayout.EndHorizontal();

        switch (_variation.audLocation)
        {
        case MasterAudio.AudioLocation.Clip:
            var newClip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", _variation.VarAudio.clip, typeof(AudioClip), false);

            if (newClip != _variation.VarAudio.clip)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation.VarAudio, "assign Audio Clip");
                _variation.VarAudio.clip = newClip;
            }
            break;

        case MasterAudio.AudioLocation.FileOnInternet:
            if (oldLocation != _variation.audLocation)
            {
                if (_variation.VarAudio.clip != null)
                {
                    Debug.Log("Audio clip removed to prevent unnecessary memory usage on File On Internet Variation.");
                }
                _variation.VarAudio.clip = null;
            }

            if (!Application.isPlaying)
            {
                var newUrl = EditorGUILayout.TextField("Internet File URL", _variation.internetFileUrl);
                if (newUrl != _variation.internetFileUrl)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Internet File URL");
                    _variation.internetFileUrl = newUrl;
                }
            }
            else
            {
                EditorGUILayout.LabelField("Internet File URL", _variation.internetFileUrl);
                switch (_variation.internetFileLoadStatus)
                {
                case MasterAudio.InternetFileLoadStatus.Loading:
                    DTGUIHelper.ShowLargeBarAlert("Attempting to download.");
                    break;

                case MasterAudio.InternetFileLoadStatus.Loaded:
                    DTGUIHelper.ShowColorWarning("Downloaded and ready to play.");
                    break;

                case MasterAudio.InternetFileLoadStatus.Failed:
                    DTGUIHelper.ShowRedError("Failed Download.");
                    break;
                }
            }

            if (string.IsNullOrEmpty(_variation.internetFileUrl))
            {
                DTGUIHelper.ShowLargeBarAlert("You have not specified a URL for the File On Internet. This Variation will not be available to play without one.");
            }
            break;

        case MasterAudio.AudioLocation.ResourceFile:
            if (oldLocation != _variation.audLocation)
            {
                if (_variation.VarAudio.clip != null)
                {
                    Debug.Log("Audio clip removed to prevent unnecessary memory usage on Resource file Variation.");
                }
                _variation.VarAudio.clip = null;
            }

            EditorGUILayout.BeginVertical();
            var anEvent = Event.current;

            GUI.color = DTGUIHelper.DragAreaColor;
            var dragArea = GUILayoutUtility.GetRect(0f, 20f, GUILayout.ExpandWidth(true));
            GUI.Box(dragArea, "Drag Resource Audio clip here to use its name!");
            GUI.color = Color.white;

            string newFilename;

            switch (anEvent.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (!dragArea.Contains(anEvent.mousePosition))
                {
                    break;
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                if (anEvent.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();

                    foreach (var dragged in DragAndDrop.objectReferences)
                    {
                        // ReSharper disable once ExpressionIsAlwaysNull
                        var aClip = dragged as AudioClip;
                        // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                        if (aClip == null)
                        {
                            continue;
                        }

                        // ReSharper disable HeuristicUnreachableCode
                        var useLocalization = false;
                        newFilename = DTGUIHelper.GetResourcePath(aClip, ref useLocalization);
                        if (string.IsNullOrEmpty(newFilename))
                        {
                            newFilename = aClip.name;
                        }

                        AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Resource filename");
                        _variation.resourceFileName = newFilename;
                        _variation.useLocalization  = useLocalization;
                        break;
                        // ReSharper restore HeuristicUnreachableCode
                    }
                }
                Event.current.Use();
                break;
            }
            EditorGUILayout.EndVertical();

            newFilename = EditorGUILayout.TextField("Resource Filename", _variation.resourceFileName);
            if (newFilename != _variation.resourceFileName)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Resource filename");
                _variation.resourceFileName = newFilename;
            }

            EditorGUI.indentLevel = 1;

            var newLocal = EditorGUILayout.Toggle("Use Localized Folder", _variation.useLocalization);
            if (newLocal != _variation.useLocalization)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Localized Folder");
                _variation.useLocalization = newLocal;
            }

            break;
        }

        EditorGUI.indentLevel = 0;

        var newProbability = EditorGUILayout.IntSlider("Probability to Play (%)", _variation.probabilityToPlay, 0, 100);

        if (newProbability != _variation.probabilityToPlay)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Probability to Play (%)");
            _variation.probabilityToPlay = newProbability;
        }

        if (_variation.probabilityToPlay < 100)
        {
            DTGUIHelper.ShowLargeBarAlert("Since Probability to Play is less than 100%, you will not always hear this Variation when it's selected to play.");
        }

        var newVolume = DTGUIHelper.DisplayVolumeField(_variation.VarAudio.volume, DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true);

        if (newVolume != _variation.VarAudio.volume)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation.VarAudio, "change Volume");
            _variation.VarAudio.volume = newVolume;
        }

        var newPitch = DTGUIHelper.DisplayPitchField(_variation.VarAudio.pitch);

        if (newPitch != _variation.VarAudio.pitch)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation.VarAudio, "change Pitch");
            _variation.VarAudio.pitch = newPitch;
        }

        if (parentGroup.curVariationMode == MasterAudioGroup.VariationMode.LoopedChain)
        {
            DTGUIHelper.ShowLargeBarAlert(MasterAudio.LoopDisabledLoopedChain);
        }
        else if (_variation.useRandomStartTime)
        {
            DTGUIHelper.ShowLargeBarAlert(MasterAudio.LoopDisabledCustomStartEnd);
        }
        else
        {
            var newLoop = EditorGUILayout.Toggle("Loop Clip", _variation.VarAudio.loop);
            if (newLoop != _variation.VarAudio.loop)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation.VarAudio, "toggle Loop");
                _variation.VarAudio.loop = newLoop;
            }
        }

        EditorGUILayout.BeginHorizontal();
        var newWeight = EditorGUILayout.IntSlider("Voices (Weight)", _variation.weight, 0, 100);

        DTGUIHelper.AddHelpIcon("http://www.dtdevtools.com/docs/masteraudio/SoundGroupVariations.htm#Voices");
        EditorGUILayout.EndHorizontal();
        if (newWeight != _variation.weight)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Voices (Weight)");
            _variation.weight = newWeight;
        }

        DTGUIHelper.StartGroupHeader();
        var newUseRndPitch = EditorGUILayout.BeginToggleGroup(" Use Random Pitch", _variation.useRandomPitch);

        if (newUseRndPitch != _variation.useRandomPitch)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Random Pitch");
            _variation.useRandomPitch = newUseRndPitch;
        }

        DTGUIHelper.EndGroupHeader();

        if (_variation.useRandomPitch)
        {
            var newMode = (SoundGroupVariation.RandomPitchMode)EditorGUILayout.EnumPopup("Pitch Compute Mode", _variation.randomPitchMode);
            if (newMode != _variation.randomPitchMode)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Pitch Compute Mode");
                _variation.randomPitchMode = newMode;
            }

            var newPitchMin = DTGUIHelper.DisplayPitchField(_variation.randomPitchMin, "Random Pitch Min");
            if (newPitchMin != _variation.randomPitchMin)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Random Pitch Min");
                _variation.randomPitchMin = newPitchMin;
                if (_variation.randomPitchMax <= _variation.randomPitchMin)
                {
                    _variation.randomPitchMax = _variation.randomPitchMin;
                }
            }

            var newPitchMax = DTGUIHelper.DisplayPitchField(_variation.randomPitchMax, "Random Pitch Max");
            if (newPitchMax != _variation.randomPitchMax)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Random Pitch Max");
                _variation.randomPitchMax = newPitchMax;
                if (_variation.randomPitchMin > _variation.randomPitchMax)
                {
                    _variation.randomPitchMin = _variation.randomPitchMax;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        var newUseRndVol = EditorGUILayout.BeginToggleGroup(" Use Random Volume", _variation.useRandomVolume);

        if (newUseRndVol != _variation.useRandomVolume)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Random Volume");
            _variation.useRandomVolume = newUseRndVol;
        }

        DTGUIHelper.EndGroupHeader();

        if (_variation.useRandomVolume)
        {
            var newMode = (SoundGroupVariation.RandomVolumeMode)EditorGUILayout.EnumPopup("Volume Compute Mode", _variation.randomVolumeMode);
            if (newMode != _variation.randomVolumeMode)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Volume Compute Mode");
                _variation.randomVolumeMode = newMode;
            }

            var volMin = 0f;
            if (_variation.randomVolumeMode == SoundGroupVariation.RandomVolumeMode.AddToClipVolume)
            {
                volMin = -1f;
            }

            var newVolMin = DTGUIHelper.DisplayVolumeField(_variation.randomVolumeMin, DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, volMin, true, "Random Volume Min");
            if (newVolMin != _variation.randomVolumeMin)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Random Volume Min");
                _variation.randomVolumeMin = newVolMin;
                if (_variation.randomVolumeMax <= _variation.randomVolumeMin)
                {
                    _variation.randomVolumeMax = _variation.randomVolumeMin;
                }
            }

            var newVolMax = DTGUIHelper.DisplayVolumeField(_variation.randomVolumeMax, DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, volMin, true, "Random Volume Max");
            if (newVolMax != _variation.randomVolumeMax)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Random Volume Max");
                _variation.randomVolumeMax = newVolMax;
                if (_variation.randomVolumeMin > _variation.randomVolumeMax)
                {
                    _variation.randomVolumeMin = _variation.randomVolumeMax;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        var newSilence = EditorGUILayout.BeginToggleGroup(" Use Random Delay", _variation.useIntroSilence);

        if (newSilence != _variation.useIntroSilence)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Random Delay");
            _variation.useIntroSilence = newSilence;
        }
        DTGUIHelper.EndGroupHeader();

        if (_variation.useIntroSilence)
        {
            var newSilenceMin = EditorGUILayout.Slider("Delay Min (sec)", _variation.introSilenceMin, 0f, 100f);
            if (newSilenceMin != _variation.introSilenceMin)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Delay Min (sec)");
                _variation.introSilenceMin = newSilenceMin;
                if (_variation.introSilenceMin > _variation.introSilenceMax)
                {
                    _variation.introSilenceMax = newSilenceMin;
                }
            }

            var newSilenceMax = EditorGUILayout.Slider("Delay Max (sec)", _variation.introSilenceMax, 0f, 100f);
            if (newSilenceMax != _variation.introSilenceMax)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Delay Max (sec)");
                _variation.introSilenceMax = newSilenceMax;
                if (_variation.introSilenceMax < _variation.introSilenceMin)
                {
                    _variation.introSilenceMin = newSilenceMax;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        var newStart = EditorGUILayout.BeginToggleGroup(" Use Custom Start/End Position", _variation.useRandomStartTime);

        if (newStart != _variation.useRandomStartTime)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Custom Start/End Position");
            _variation.useRandomStartTime = newStart;
        }
        DTGUIHelper.EndGroupHeader();

        if (_variation.useRandomStartTime)
        {
            var newMin = EditorGUILayout.Slider("Start Min (%)", _variation.randomStartMinPercent, 0f, 100f);
            if (newMin != _variation.randomStartMinPercent)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Start Min (%)");
                _variation.randomStartMinPercent = newMin;
                if (_variation.randomStartMaxPercent <= _variation.randomStartMinPercent)
                {
                    _variation.randomStartMaxPercent = _variation.randomStartMinPercent;
                }
            }

            var newMax = EditorGUILayout.Slider("Start Max (%)", _variation.randomStartMaxPercent, 0f, 100f);
            if (newMax != _variation.randomStartMaxPercent)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Start Max (%)");
                _variation.randomStartMaxPercent = newMax;
                if (_variation.randomStartMinPercent > _variation.randomStartMaxPercent)
                {
                    _variation.randomStartMinPercent = _variation.randomStartMaxPercent;
                }
            }

            var newEnd = EditorGUILayout.Slider("End (%)", _variation.randomEndPercent, 0f, 100f);
            if (newEnd != _variation.randomEndPercent || _variation.randomEndPercent < _variation.randomStartMaxPercent)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change End (%)");
                _variation.randomEndPercent = newEnd;
                if (_variation.randomEndPercent < _variation.randomStartMaxPercent)
                {
                    _variation.randomEndPercent = _variation.randomStartMaxPercent;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        if (_variation.VarAudio.loop)
        {
            DTGUIHelper.StartGroupHeader();

            newStart = EditorGUILayout.BeginToggleGroup(" Use Finite Looping", _variation.useCustomLooping);
            if (newStart != _variation.useCustomLooping)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation,
                                                            "toggle Use Finite Looping");
                _variation.useCustomLooping = newStart;
            }
            DTGUIHelper.EndGroupHeader();

            if (_variation.useCustomLooping)
            {
                var newMin = EditorGUILayout.IntSlider("Min Loops", _variation.minCustomLoops, 1, 100);
                if (newMin != _variation.minCustomLoops)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Min Loops");
                    _variation.minCustomLoops = newMin;
                    if (_variation.maxCustomLoops <= _variation.minCustomLoops)
                    {
                        _variation.maxCustomLoops = _variation.minCustomLoops;
                    }
                }

                var newMax = EditorGUILayout.IntSlider("Max Loops", _variation.maxCustomLoops, 1, 100);
                if (newMax != _variation.maxCustomLoops)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Max Loops");
                    _variation.maxCustomLoops = newMax;
                    if (_variation.minCustomLoops > _variation.maxCustomLoops)
                    {
                        _variation.minCustomLoops = _variation.maxCustomLoops;
                    }
                }
            }

            EditorGUILayout.EndToggleGroup();
            DTGUIHelper.AddSpaceForNonU5(2);
        }

        DTGUIHelper.StartGroupHeader();
        var newUseFades = EditorGUILayout.BeginToggleGroup(" Use Custom Fading", _variation.useFades);

        if (newUseFades != _variation.useFades)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "toggle Use Custom Fading");
            _variation.useFades = newUseFades;
        }
        DTGUIHelper.EndGroupHeader();

        if (_variation.useFades)
        {
            var newFadeIn = EditorGUILayout.Slider("Fade In Time (sec)", _variation.fadeInTime, 0f, 10f);
            if (newFadeIn != _variation.fadeInTime)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Fade In Time");
                _variation.fadeInTime = newFadeIn;
            }

            if (_variation.VarAudio.loop)
            {
                DTGUIHelper.ShowColorWarning("Looped clips cannot have a custom fade out.");
            }
            else
            {
                var newFadeOut = EditorGUILayout.Slider("Fade Out time (sec)", _variation.fadeOutTime, 0f, 10f);
                if (newFadeOut != _variation.fadeOutTime)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, _variation, "change Fade Out Time");
                    _variation.fadeOutTime = newFadeOut;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();

        if (GUI.changed || isDirty)
        {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            var adaptiveQuality = (VRTK_AdaptiveQuality)target;

            EditorGUILayout.HelpBox(DontDisableHelpBoxText, adaptiveQuality.enabled ? MessageType.Warning : MessageType.Error);
            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("drawDebugVisualization"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("allowKeyboardShortcuts"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("allowCommandLineArguments"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("msaaLevel"));

            EditorGUILayout.Space();
            serializedObject.FindProperty("scaleRenderViewport").boolValue =
                EditorGUILayout.BeginToggleGroup(VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("scaleRenderViewport"),
                                                 adaptiveQuality.scaleRenderViewport);
            {
                float minimumRenderScale = adaptiveQuality.minimumRenderScale;
                float maximumRenderScale = adaptiveQuality.maximumRenderScale;

                EditorGUILayout.BeginHorizontal();
                {
                    var fieldInfo      = adaptiveQuality.GetType().GetField("minimumRenderScale");
                    var rangeAttribute = (RangeAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(RangeAttribute));

                    EditorGUI.BeginChangeCheck();
                    {
                        float maxFloatWidth = GUI.skin.textField.CalcSize(new GUIContent(1.23f.ToString(CultureInfo.InvariantCulture))).x;
                        minimumRenderScale = EditorGUILayout.FloatField(minimumRenderScale, GUILayout.MaxWidth(maxFloatWidth));

                        EditorGUILayout.MinMaxSlider(
                            ref minimumRenderScale,
                            ref maximumRenderScale,
                            rangeAttribute.min,
                            rangeAttribute.max);

                        maximumRenderScale = EditorGUILayout.FloatField(maximumRenderScale, GUILayout.MaxWidth(maxFloatWidth));
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.FindProperty("minimumRenderScale").floatValue =
                            Mathf.Clamp((float)Math.Round(minimumRenderScale, 2), rangeAttribute.min, rangeAttribute.max);
                        serializedObject.FindProperty("maximumRenderScale").floatValue =
                            Mathf.Clamp((float)Math.Round(maximumRenderScale, 2), rangeAttribute.min, rangeAttribute.max);
                    }
                }
                EditorGUILayout.EndHorizontal();

                if (maximumRenderScale > adaptiveQuality.BiggestAllowedMaximumRenderScale())
                {
                    EditorGUILayout.HelpBox(MaximumRenderScaleTooBigHelpBoxText, MessageType.Error);
                }

                EditorGUILayout.PropertyField(serializedObject.FindProperty("maximumRenderTargetDimension"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("renderScaleFillRateStepSizeInPercent"));

                serializedObject.FindProperty("scaleRenderTargetResolution").boolValue =
                    EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("scaleRenderTargetResolution"),
                                           adaptiveQuality.scaleRenderTargetResolution);
                if (adaptiveQuality.scaleRenderTargetResolution)
                {
                    EditorGUILayout.HelpBox(ScaleRenderTargetResolutionCostlyHelpBoxText, MessageType.Warning);
                }

                int  maxRenderScaleLevel = Mathf.Max(adaptiveQuality.renderScales.Count - 1, 0);
                bool disabled            = maxRenderScaleLevel == 0 || !Application.isPlaying;

                EditorGUI.BeginDisabledGroup(disabled);
                {
                    VRTK_EditorUtilities.AddHeader <VRTK_AdaptiveQuality>("overrideRenderViewportScale");

                    if (disabled)
                    {
                        EditorGUI.EndDisabledGroup();
                        {
                            EditorGUILayout.HelpBox(NoRenderScaleLevelsYetHelpBoxText, MessageType.Info);
                        }
                        EditorGUI.BeginDisabledGroup(true);
                    }

                    adaptiveQuality.overrideRenderViewportScale = EditorGUILayout.Toggle(
                        VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("overrideRenderViewportScale"),
                        adaptiveQuality.overrideRenderViewportScale);

                    EditorGUI.BeginDisabledGroup(!adaptiveQuality.overrideRenderViewportScale);
                    {
                        adaptiveQuality.overrideRenderViewportScaleLevel =
                            EditorGUILayout.IntSlider(
                                VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("overrideRenderViewportScaleLevel"),
                                adaptiveQuality.overrideRenderViewportScaleLevel,
                                0,
                                maxRenderScaleLevel);
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUI.EndDisabledGroup();
            }
            EditorGUILayout.EndToggleGroup();

            if (Application.isPlaying)
            {
                string summary = adaptiveQuality.ToString();
                summary = summary.Substring(summary.IndexOf("\n", StringComparison.Ordinal) + 1);

                VRTK_EditorUtilities.AddHeader("Current State");
                EditorGUILayout.HelpBox(summary, MessageType.None);

                if (GUILayout.RepeatButton("Refresh"))
                {
                    Repaint();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            BaseComponent t = (BaseComponent)target;

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            {
                m_EditorResourceMode.boolValue = EditorGUILayout.BeginToggleGroup("Editor Resource Mode", m_EditorResourceMode.boolValue);
                {
                    EditorGUILayout.HelpBox("Editor resource mode option is only for editor mode. Game Framework will use editor resource files, which you should validate first.", MessageType.Warning);
                    EditorGUILayout.PropertyField(m_EditorLanguage);
                    EditorGUILayout.HelpBox("Editor language option is only use for localization test in editor mode.", MessageType.Info);
                }
                EditorGUILayout.EndToggleGroup();

                EditorGUILayout.BeginVertical("box");
                {
                    EditorGUILayout.LabelField("Global Helpers", EditorStyles.boldLabel);

                    int versionHelperSelectedIndex = EditorGUILayout.Popup("Version Helper", m_VersionHelperTypeNameIndex, m_VersionHelperTypeNames);
                    if (versionHelperSelectedIndex != m_VersionHelperTypeNameIndex)
                    {
                        m_VersionHelperTypeNameIndex        = versionHelperSelectedIndex;
                        m_VersionHelperTypeName.stringValue = versionHelperSelectedIndex <= 0 ? null : m_VersionHelperTypeNames[versionHelperSelectedIndex];
                    }

                    int logHelperSelectedIndex = EditorGUILayout.Popup("Log Helper", m_LogHelperTypeNameIndex, m_LogHelperTypeNames);
                    if (logHelperSelectedIndex != m_LogHelperTypeNameIndex)
                    {
                        m_LogHelperTypeNameIndex        = logHelperSelectedIndex;
                        m_LogHelperTypeName.stringValue = logHelperSelectedIndex <= 0 ? null : m_LogHelperTypeNames[logHelperSelectedIndex];
                    }

                    int zipHelperSelectedIndex = EditorGUILayout.Popup("Zip Helper", m_ZipHelperTypeNameIndex, m_ZipHelperTypeNames);
                    if (zipHelperSelectedIndex != m_ZipHelperTypeNameIndex)
                    {
                        m_ZipHelperTypeNameIndex        = zipHelperSelectedIndex;
                        m_ZipHelperTypeName.stringValue = zipHelperSelectedIndex <= 0 ? null : m_ZipHelperTypeNames[zipHelperSelectedIndex];
                    }

                    int jsonHelperSelectedIndex = EditorGUILayout.Popup("JSON Helper", m_JsonHelperTypeNameIndex, m_JsonHelperTypeNames);
                    if (jsonHelperSelectedIndex != m_JsonHelperTypeNameIndex)
                    {
                        m_JsonHelperTypeNameIndex        = jsonHelperSelectedIndex;
                        m_JsonHelperTypeName.stringValue = jsonHelperSelectedIndex <= 0 ? null : m_JsonHelperTypeNames[jsonHelperSelectedIndex];
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginVertical("box");
            {
                float gameSpeed         = EditorGUILayout.Slider("Game Speed", m_GameSpeed.floatValue, 0f, 8f);
                int   selectedGameSpeed = GUILayout.SelectionGrid(GetSelectedGameSpeed(gameSpeed), GameSpeedForDisplay, 5);
                if (selectedGameSpeed >= 0)
                {
                    gameSpeed = GetGameSpeed(selectedGameSpeed);
                }

                if (gameSpeed != m_GameSpeed.floatValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.GameSpeed = gameSpeed;
                    }
                    else
                    {
                        m_GameSpeed.floatValue = gameSpeed;
                    }
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("box");
            {
                int gameQuality = EditorGUILayout.Popup("Game Quality", m_GameQuality.intValue, QualitySettings.names);
                if (gameQuality != m_GameQuality.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.GameQuality = gameQuality;
                    }
                    else
                    {
                        m_GameQuality.intValue = gameQuality;
                    }
                }

                int frameRate = EditorGUILayout.IntSlider("Frame Rate", m_FrameRate.intValue, 1, 999);
                if (frameRate != m_FrameRate.intValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.FrameRate = frameRate;
                    }
                    else
                    {
                        m_FrameRate.intValue = frameRate;
                    }
                }

                bool runInBackground = EditorGUILayout.Toggle("Run in Background", m_RunInBackground.boolValue);
                if (runInBackground != m_RunInBackground.boolValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.RunInBackground = runInBackground;
                    }
                    else
                    {
                        m_RunInBackground.boolValue = runInBackground;
                    }
                }

                bool neverSleep = EditorGUILayout.Toggle("Never Sleep", m_NeverSleep.boolValue);
                if (neverSleep != m_NeverSleep.boolValue)
                {
                    if (EditorApplication.isPlaying)
                    {
                        t.NeverSleep = neverSleep;
                    }
                    else
                    {
                        m_NeverSleep.boolValue = neverSleep;
                    }
                }
            }
            EditorGUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 11
0
 protected void PropertyFieldToggleGroup(SerializedProperty obj, string label, Runnable0 runnable) {
     obj.boolValue = EditorGUILayout.BeginToggleGroup(label, obj.boolValue);
     
     runnable();
     EditorGUILayout.EndToggleGroup();
 }
    protected override void OnGUI()
    {
        base.OnGUI();

        EditorGUILayout.LabelField("ChangeCheck 框选中代码只有被操作后,判断内逻辑才会被执行,而不是每帧执行");
        EditorGUILayout.Space();
        EditorGUI.BeginChangeCheck();
        go = (GameObject)EditorGUILayout.ObjectField(go, typeof(GameObject), true);

        if (EditorGUI.EndChangeCheck())
        {
            Debug.Log("chanegr");
        }

        ///和上述是等价的。
        using (var changerCheck = new EditorGUI.ChangeCheckScope())
        {
            go = (GameObject)EditorGUILayout.ObjectField(go, typeof(GameObject), true);
            if (changerCheck.changed)
            {
                Debug.Log("use changer");
            }
        }


        EditorGUILayout.LabelField("DisabledGroup");
        EditorGUILayout.Space();
        EditorGUI.BeginDisabledGroup(false);
        EditorGUILayout.LabelField("Disable false");
        EditorGUI.EndDisabledGroup();
        EditorGUI.BeginDisabledGroup(true);
        EditorGUILayout.LabelField("Disable true");
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.LabelField("FadeGroup");
        EditorGUILayout.Space();
        m_ShowExtraFields.target = EditorGUILayout.ToggleLeft("Show extra fields", m_ShowExtraFields.target);
        if (EditorGUILayout.BeginFadeGroup(m_ShowExtraFields.faded))
        {
            EditorGUILayout.LabelField("FadeGroup");
            EditorGUILayout.LabelField("FadeGroup");
            EditorGUILayout.LabelField("FadeGroup");
            GUILayout.Button("Btn");
        }

        EditorGUILayout.EndFadeGroup();

        EditorGUILayout.LabelField("ToogleGroup");
        EditorGUILayout.Space();
        toogle = EditorGUILayout.BeginToggleGroup("ToogleGroup", toogle);

        EditorGUILayout.LabelField("ToogleGroup");
        EditorGUILayout.LabelField("ToogleGroup");
        EditorGUILayout.LabelField("ToogleGroup");
        GUILayout.Button("Btn");
        EditorGUILayout.EndToggleGroup();


        EditorGUILayout.LabelField("BuildTargetSelectionGrouping");
        EditorGUILayout.Space();

        target = EditorGUILayout.BeginBuildTargetSelectionGrouping();
        if (target == BuildTargetGroup.Android)
        {
            EditorGUILayout.LabelField("Android specific things");
        }
        if (target == BuildTargetGroup.Standalone)
        {
            EditorGUILayout.LabelField("Standalone specific things");
        }
        EditorGUILayout.EndBuildTargetSelectionGrouping();
    }
Exemplo n.º 13
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();

        EditorGUI.indentLevel = 0;
        var isDirty = false;

        MasterAudio ma = MasterAudio.Instance;

        if (ma == null)
        {
            isValid = false;
        }

        MasterAudioGroup _group = (MasterAudioGroup)target;

        _group = RescanChildren(_group);

        if (!isValid)
        {
            return;
        }

        var isInProjectView = DTGUIHelper.IsPrefabInProjectView(_group);

        if (MasterAudioInspectorResources.logoTexture != null)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.logoTexture);
        }

        var newVol = EditorGUILayout.Slider("Group Master Volume", _group.groupMasterVolume, 0f, 1f);

        if (newVol != _group.groupMasterVolume)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "change Group Master Volume");
            _group.groupMasterVolume = newVol;
        }

        var newVarSequence = (MasterAudioGroup.VariationSequence)EditorGUILayout.EnumPopup("Variation Sequence", _group.curVariationSequence);

        if (newVarSequence != _group.curVariationSequence)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "change Variation Sequence");
            _group.curVariationSequence = newVarSequence;
        }

        if (_group.curVariationSequence == MasterAudioGroup.VariationSequence.TopToBottom)
        {
            var newUseInactive = EditorGUILayout.BeginToggleGroup("Refill Variation Pool After Inactive Time", _group.useInactivePeriodPoolRefill);
            if (newUseInactive != _group.useInactivePeriodPoolRefill)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Inactive Refill");
                _group.useInactivePeriodPoolRefill = newUseInactive;
            }

            EditorGUI.indentLevel = 1;
            var newInactivePeriod = EditorGUILayout.Slider("Inactive Time (sec)", _group.inactivePeriodSeconds, .2f, 30f);
            if (newInactivePeriod != _group.inactivePeriodSeconds)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Inactive Time");
                _group.inactivePeriodSeconds = newInactivePeriod;
            }

            EditorGUILayout.EndToggleGroup();
        }

        EditorGUI.indentLevel = 0;
        var newVarMode = (MasterAudioGroup.VariationMode)EditorGUILayout.EnumPopup("Variation Mode", _group.curVariationMode);

        if (newVarMode != _group.curVariationMode)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "change Variation Mode");
            _group.curVariationMode = newVarMode;
        }

        EditorGUI.indentLevel = 1;

        switch (_group.curVariationMode)
        {
        case MasterAudioGroup.VariationMode.Normal:
            var newRetrigger = EditorGUILayout.IntSlider("Retrigger Percentage", _group.retriggerPercentage, 0, 100);
            if (newRetrigger != _group.retriggerPercentage)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Retrigger Percentage");
                _group.retriggerPercentage = newRetrigger;
            }

            var newLimitPoly = EditorGUILayout.Toggle("Limit Polyphony", _group.limitPolyphony);
            if (newLimitPoly != _group.limitPolyphony)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Limit Polyphony");
                _group.limitPolyphony = newLimitPoly;
            }
            if (_group.limitPolyphony)
            {
                int maxVoices = 0;
                for (var i = 0; i < _group.groupVariations.Count; i++)
                {
                    var variation = _group.groupVariations[i];
                    maxVoices += variation.weight;
                }

                var newVoiceLimit = EditorGUILayout.IntSlider("Polyphony Voice Limit", _group.voiceLimitCount, 1, maxVoices);
                if (newVoiceLimit != _group.voiceLimitCount)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Polyphony Voice Limit");
                    _group.voiceLimitCount = newVoiceLimit;
                }
            }

            var newLimitMode = (MasterAudioGroup.LimitMode)EditorGUILayout.EnumPopup("Replay Limit Mode", _group.limitMode);
            if (newLimitMode != _group.limitMode)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Replay Limit Mode");
                _group.limitMode = newLimitMode;
            }

            switch (_group.limitMode)
            {
            case MasterAudioGroup.LimitMode.FrameBased:
                var newFrameLimit = EditorGUILayout.IntSlider("Min Frames Between", _group.limitPerXFrames, 1, 120);
                if (newFrameLimit != _group.limitPerXFrames)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Min Frames Between");
                    _group.limitPerXFrames = newFrameLimit;
                }
                break;

            case MasterAudioGroup.LimitMode.TimeBased:
                var newMinTime = EditorGUILayout.Slider("Min Seconds Between", _group.minimumTimeBetween, 0.1f, 10f);
                if (newMinTime != _group.minimumTimeBetween)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Min Seconds Between");
                    _group.minimumTimeBetween = newMinTime;
                }
                break;
            }
            break;

        case MasterAudioGroup.VariationMode.LoopedChain:
            DTGUIHelper.ShowColorWarning("*In this mode, only one Variation can be played at a time.");

            var newLoopMode = (MasterAudioGroup.ChainedLoopLoopMode)EditorGUILayout.EnumPopup("Loop Mode", _group.chainLoopMode);
            if (newLoopMode != _group.chainLoopMode)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Loop Mode");
                _group.chainLoopMode = newLoopMode;
            }

            if (_group.chainLoopMode == MasterAudioGroup.ChainedLoopLoopMode.NumberOfLoops)
            {
                var newLoopCount = EditorGUILayout.IntSlider("Number of Loops", _group.chainLoopNumLoops, 1, 500);
                if (newLoopCount != _group.chainLoopNumLoops)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Number of Loops");
                    _group.chainLoopNumLoops = newLoopCount;
                }
            }

            var newDelayMin = EditorGUILayout.Slider("Clip Change Delay Min", _group.chainLoopDelayMin, 0f, 20f);
            if (newDelayMin != _group.chainLoopDelayMin)
            {
                if (_group.chainLoopDelayMax < newDelayMin)
                {
                    _group.chainLoopDelayMax = newDelayMin;
                }
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Chained Clip Delay Min");
                _group.chainLoopDelayMin = newDelayMin;
            }

            var newDelayMax = EditorGUILayout.Slider("Clip Change Delay Max", _group.chainLoopDelayMax, 0f, 20f);
            if (newDelayMax != _group.chainLoopDelayMax)
            {
                if (newDelayMax < _group.chainLoopDelayMin)
                {
                    newDelayMax = _group.chainLoopDelayMin;
                }
                UndoHelper.RecordObjectPropertyForUndo(_group, "change Chained Clip Delay Max");
                _group.chainLoopDelayMax = newDelayMax;
            }
            break;

        case MasterAudioGroup.VariationMode.Dialog:
            DTGUIHelper.ShowColorWarning("*In this mode, only one Variation can be played at a time.");

            var newUseDialog = EditorGUILayout.Toggle("Dialog Custom Fade?", _group.useDialogFadeOut);
            if (newUseDialog != _group.useDialogFadeOut)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Dialog Custom Fade?");
                _group.useDialogFadeOut = newUseDialog;
            }

            if (_group.useDialogFadeOut)
            {
                var newFadeTime = EditorGUILayout.Slider("Custom Fade Out Time", _group.dialogFadeOutTime, 0.1f, 20f);
                if (newFadeTime != _group.dialogFadeOutTime)
                {
                    UndoHelper.RecordObjectPropertyForUndo(_group, "change Custom Fade Out Time");
                    _group.dialogFadeOutTime = newFadeTime;
                }
            }
            break;
        }

        EditorGUI.indentLevel = 0;
        if (MasterAudio.Instance.prioritizeOnDistance)
        {
            var newContinual = EditorGUILayout.Toggle("Use Clip Age Priority", _group.useClipAgePriority);
            if (newContinual != _group.useClipAgePriority)
            {
                UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Use Clip Age Priority");
                _group.useClipAgePriority = newContinual;
            }
        }

        var newBulkMode = (MasterAudio.AudioLocation)EditorGUILayout.EnumPopup("Variation Create Mode", _group.bulkVariationMode);

        if (newBulkMode != _group.bulkVariationMode)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "change Bulk Variation Mode");
            _group.bulkVariationMode = newBulkMode;
        }
        if (_group.bulkVariationMode == MasterAudio.AudioLocation.ResourceFile)
        {
            DTGUIHelper.ShowColorWarning("*Resource mode: make sure to drag from Resource folders only.");
        }

        var newLog = EditorGUILayout.Toggle("Log Sounds", _group.logSound);

        if (newLog != _group.logSound)
        {
            UndoHelper.RecordObjectPropertyForUndo(_group, "toggle Log Sounds");
            _group.logSound = newLog;
        }

        int?deadChildIndex = null;

        if (!Application.isPlaying)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(4);
            GUILayout.Label("Actions", EditorStyles.wordWrappedLabel, GUILayout.Width(50f));
            GUILayout.Space(96);
            GUI.contentColor = Color.green;
            if (GUILayout.Button(new GUIContent("Equalize Weights", "Reset Weights to one"), EditorStyles.toolbarButton, GUILayout.Width(120)))
            {
                isDirty = true;
                EqualizeWeights(_group);
            }

            GUILayout.Space(10);
            if (GUILayout.Button(new GUIContent("Equalize Variation Volumes"), EditorStyles.toolbarButton, GUILayout.Width(150)))
            {
                EqualizeVariationVolumes(_group.groupVariations);
            }

            GUI.contentColor = Color.white;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Separator();
        }

        if (!Application.isPlaying)
        {
            // new variation settings
            EditorGUILayout.BeginVertical();
            var anEvent = Event.current;

            GUI.color = Color.yellow;

            if (isInProjectView)
            {
                DTGUIHelper.ShowLargeBarAlert("*You are in Project View and cannot create Variations.");
                DTGUIHelper.ShowLargeBarAlert("*Pull this prefab into the Scene to create Variations.");
            }
            else
            {
                var dragArea = GUILayoutUtility.GetRect(0f, 35f, GUILayout.ExpandWidth(true));
                GUI.Box(dragArea, "Drag Audio clips here to create Variations!");

                GUI.color = Color.white;

                switch (anEvent.type)
                {
                case EventType.DragUpdated:
                case EventType.DragPerform:
                    if (!dragArea.Contains(anEvent.mousePosition))
                    {
                        break;
                    }

                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                    if (anEvent.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();

                        foreach (var dragged in DragAndDrop.objectReferences)
                        {
                            var aClip = dragged as AudioClip;
                            if (aClip == null)
                            {
                                continue;
                            }

                            CreateVariation(_group, ma, aClip);
                        }
                    }
                    Event.current.Use();
                    break;
                }
            }
            EditorGUILayout.EndVertical();
            // end new variation settings
        }

        if (_group.groupVariations.Count == 0)
        {
            DTGUIHelper.ShowRedError("You currently have no Variations.");
        }
        else
        {
            _group.groupVariations.Sort(delegate(SoundGroupVariation x, SoundGroupVariation y) {
                return(x.name.CompareTo(y.name));
            });

            for (var i = 0; i < _group.groupVariations.Count; i++)
            {
                var variation = _group.groupVariations[i];
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                EditorGUILayout.LabelField(variation.name, EditorStyles.boldLabel);

                GUILayout.FlexibleSpace();

                if (GUILayout.Button(new GUIContent(MasterAudioInspectorResources.gearTexture, "Click to goto Variation"), EditorStyles.toolbarButton, GUILayout.Width(40)))
                {
                    Selection.activeObject = variation;
                }

                if (!Application.isPlaying)
                {
                    if (GUILayout.Button(new GUIContent(MasterAudioInspectorResources.deleteTexture, "Click to delete this Variation"), EditorStyles.toolbarButton, GUILayout.Width(40)))
                    {
                        deadChildIndex = i;
                        isDirty        = true;
                    }
                }

                var buttonPressed = DTGUIHelper.AddVariationButtons();
                switch (buttonPressed)
                {
                case DTGUIHelper.DTFunctionButtons.Play:
                    if (Application.isPlaying)
                    {
                        MasterAudio.PlaySound(_group.name, 1f, null, 0f, variation.name);
                    }
                    else
                    {
                        if (variation.audLocation == MasterAudio.AudioLocation.ResourceFile)
                        {
                            MasterAudio.PreviewerInstance.Stop();
                            MasterAudio.PreviewerInstance.PlayOneShot(Resources.Load(variation.resourceFileName) as AudioClip);
                        }
                        else
                        {
                            variation.audio.Stop();
                            variation.audio.Play();
                        }
                    }
                    break;

                case DTGUIHelper.DTFunctionButtons.Stop:
                    if (Application.isPlaying)
                    {
                        MasterAudio.StopAllOfSound(_group.name);
                    }
                    else
                    {
                        if (variation.audLocation == MasterAudio.AudioLocation.ResourceFile)
                        {
                            MasterAudio.PreviewerInstance.Stop();
                        }
                        else
                        {
                            variation.audio.Stop();
                        }
                    }
                    break;
                }

                EditorGUILayout.EndHorizontal();

                if (!Application.isPlaying)
                {
                    DTGUIHelper.ShowColorWarning("*Fading & random settings are ignored by preview in edit mode.");
                }
                if (variation.audio == null)
                {
                    DTGUIHelper.ShowRedError(string.Format("The Variation: '{0}' has no Audio Source.", variation.name));
                    break;
                }

                var oldLocation = variation.audLocation;
                var newLocation = (MasterAudio.AudioLocation)EditorGUILayout.EnumPopup("Audio Origin", variation.audLocation);
                if (newLocation != variation.audLocation)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "change Audio Origin");
                    variation.audLocation = newLocation;
                }

                switch (variation.audLocation)
                {
                case MasterAudio.AudioLocation.Clip:
                    var newClip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", variation.audio.clip, typeof(AudioClip), false);
                    if (newClip != variation.audio.clip)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation.audio, "change Audio Clip");
                        variation.audio.clip = newClip;
                    }
                    break;

                case MasterAudio.AudioLocation.ResourceFile:
                    if (oldLocation != variation.audLocation)
                    {
                        if (variation.audio.clip != null)
                        {
                            Debug.Log("Audio clip removed to prevent unnecessary memory usage on Resource file Variation.");
                        }
                        variation.audio.clip = null;
                    }

                    EditorGUILayout.BeginVertical();
                    var anEvent = Event.current;

                    GUI.color = Color.yellow;
                    var dragArea = GUILayoutUtility.GetRect(0f, 20f, GUILayout.ExpandWidth(true));
                    GUI.Box(dragArea, "Drag Resource Audio clip here to use its name!");
                    GUI.color = Color.white;

                    switch (anEvent.type)
                    {
                    case EventType.DragUpdated:
                    case EventType.DragPerform:
                        if (!dragArea.Contains(anEvent.mousePosition))
                        {
                            break;
                        }

                        DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                        if (anEvent.type == EventType.DragPerform)
                        {
                            DragAndDrop.AcceptDrag();

                            foreach (var dragged in DragAndDrop.objectReferences)
                            {
                                var aClip = dragged as AudioClip;
                                if (aClip == null)
                                {
                                    continue;
                                }

                                UndoHelper.RecordObjectPropertyForUndo(variation, "change Resource Filename");
                                var resourceFileName = DTGUIHelper.GetResourcePath(aClip);
                                if (string.IsNullOrEmpty(resourceFileName))
                                {
                                    resourceFileName = aClip.name;
                                }

                                variation.resourceFileName = resourceFileName;
                            }
                        }
                        Event.current.Use();
                        break;
                    }
                    EditorGUILayout.EndVertical();

                    var newFilename = EditorGUILayout.TextField("Resource Filename", variation.resourceFileName);
                    if (newFilename != variation.resourceFileName)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Resource Filename");
                        variation.resourceFileName = newFilename;
                    }
                    break;
                }

                var newVolume = EditorGUILayout.Slider("Volume", variation.audio.volume, 0f, 1f);
                if (newVolume != variation.audio.volume)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation.audio, "change Volume");
                    variation.audio.volume = newVolume;
                }

                var newPitch = EditorGUILayout.Slider("Pitch", variation.audio.pitch, -3f, 3f);
                if (newPitch != variation.audio.pitch)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation.audio, "change Pitch");
                    variation.audio.pitch = newPitch;
                }

                var newLoop = EditorGUILayout.Toggle("Loop Clip", variation.audio.loop);
                if (newLoop != variation.audio.loop)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation.audio, "toggle Loop Clip");
                    variation.audio.loop = newLoop;
                }

                EditorUtility.SetDirty(variation.audio);

                var newWeight = EditorGUILayout.IntSlider("Weight (Instances)", variation.weight, 0, 100);
                if (newWeight != variation.weight)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "change Weight");
                    variation.weight = newWeight;
                }

                if (variation.HasActiveFXFilter)
                {
                    var newFxTailTime = EditorGUILayout.Slider("FX Tail Time", variation.fxTailTime, 0f, 10f);
                    if (newFxTailTime != variation.fxTailTime)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change FX Tail Time");
                        variation.fxTailTime = newFxTailTime;
                    }
                }

                var newUseRndPitch = EditorGUILayout.BeginToggleGroup("Use Random Pitch", variation.useRandomPitch);
                if (newUseRndPitch != variation.useRandomPitch)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "toggle Use Random Pitch");
                    variation.useRandomPitch = newUseRndPitch;
                }

                if (variation.useRandomPitch)
                {
                    var newMode = (SoundGroupVariation.RandomPitchMode)EditorGUILayout.EnumPopup("Pitch Compute Mode", variation.randomPitchMode);
                    if (newMode != variation.randomPitchMode)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Pitch Compute Mode");
                        variation.randomPitchMode = newMode;
                    }

                    var newPitchMin = EditorGUILayout.Slider("Random Pitch Min", variation.randomPitchMin, -3f, 3f);
                    if (newPitchMin != variation.randomPitchMin)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Random Pitch Min");
                        variation.randomPitchMin = newPitchMin;
                        if (variation.randomPitchMax <= variation.randomPitchMin)
                        {
                            variation.randomPitchMax = variation.randomPitchMin;
                        }
                    }

                    var newPitchMax = EditorGUILayout.Slider("Random Pitch Max", variation.randomPitchMax, -3f, 3f);
                    if (newPitchMax != variation.randomPitchMax)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Random Pitch Max");
                        variation.randomPitchMax = newPitchMax;
                        if (variation.randomPitchMin > variation.randomPitchMax)
                        {
                            variation.randomPitchMin = variation.randomPitchMax;
                        }
                    }
                }

                EditorGUILayout.EndToggleGroup();

                var newUseRndVol = EditorGUILayout.BeginToggleGroup("Use Random Volume", variation.useRandomVolume);
                if (newUseRndVol != variation.useRandomVolume)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "toggle Use Random Volume");
                    variation.useRandomVolume = newUseRndVol;
                }

                if (variation.useRandomVolume)
                {
                    var newMode = (SoundGroupVariation.RandomVolumeMode)EditorGUILayout.EnumPopup("Volume Compute Mode", variation.randomVolumeMode);
                    if (newMode != variation.randomVolumeMode)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Volume Compute Mode");
                        variation.randomVolumeMode = newMode;
                    }

                    var volMin = 0f;
                    if (variation.randomVolumeMode == SoundGroupVariation.RandomVolumeMode.AddToClipVolume)
                    {
                        volMin = -1f;
                    }

                    var newVolMin = EditorGUILayout.Slider("Random Volume Min", variation.randomVolumeMin, volMin, 1f);
                    if (newVolMin != variation.randomVolumeMin)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Random Volume Min");
                        variation.randomVolumeMin = newVolMin;
                        if (variation.randomVolumeMax <= variation.randomVolumeMin)
                        {
                            variation.randomVolumeMax = variation.randomVolumeMin;
                        }
                    }

                    var newVolMax = EditorGUILayout.Slider("Random Volume Max", variation.randomVolumeMax, volMin, 1f);
                    if (newVolMax != variation.randomVolumeMax)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Random Volume Max");
                        variation.randomVolumeMax = newVolMax;
                        if (variation.randomVolumeMin > variation.randomVolumeMax)
                        {
                            variation.randomVolumeMin = variation.randomVolumeMax;
                        }
                    }
                }

                EditorGUILayout.EndToggleGroup();

                var newSilence = EditorGUILayout.BeginToggleGroup("Use Random Delay", variation.useIntroSilence);
                if (newSilence != variation.useIntroSilence)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "toggle Use Random Delay");
                    variation.useIntroSilence = newSilence;
                }

                if (variation.useIntroSilence)
                {
                    var newSilenceMin = EditorGUILayout.Slider("Delay Min (sec)", variation.introSilenceMin, 0f, 100f);
                    if (newSilenceMin != variation.introSilenceMin)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Delay Min (sec)");
                        variation.introSilenceMin = newSilenceMin;
                        if (variation.introSilenceMin > variation.introSilenceMax)
                        {
                            variation.introSilenceMax = newSilenceMin;
                        }
                    }

                    var newSilenceMax = EditorGUILayout.Slider("Delay Max (sec)", variation.introSilenceMax, 0f, 100f);
                    if (newSilenceMax != variation.introSilenceMax)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Delay Max (sec)");
                        variation.introSilenceMax = newSilenceMax;
                        if (variation.introSilenceMax < variation.introSilenceMin)
                        {
                            variation.introSilenceMin = newSilenceMax;
                        }
                    }
                }

                EditorGUILayout.EndToggleGroup();

                var newFades = EditorGUILayout.BeginToggleGroup("Use Custom Fading", variation.useFades);
                if (newFades != variation.useFades)
                {
                    UndoHelper.RecordObjectPropertyForUndo(variation, "toggle Use Custom Fading");
                    variation.useFades = newFades;
                }

                if (variation.useFades)
                {
                    var newFadeIn = EditorGUILayout.Slider("Fade In Time (sec)", variation.fadeInTime, 0f, 10f);
                    if (newFadeIn != variation.fadeInTime)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Fade In Time");
                        variation.fadeInTime = newFadeIn;
                    }

                    var newFadeOut = EditorGUILayout.Slider("Fade Out time (sec)", variation.fadeOutTime, 0f, 10f);
                    if (newFadeOut != variation.fadeOutTime)
                    {
                        UndoHelper.RecordObjectPropertyForUndo(variation, "change Fade Out Time");
                        variation.fadeOutTime = newFadeOut;
                    }
                }
                EditorGUILayout.EndToggleGroup();

                EditorGUILayout.Separator();
            }
        }

        if (deadChildIndex.HasValue)
        {
            var deadVar = _group.groupVariations[deadChildIndex.Value];

            if (deadVar != null)
            {
                // delete variation from Hierarchy
                GameObject.DestroyImmediate(deadVar.gameObject);
            }

            // delete group.
            _group.groupVariations.RemoveAt(deadChildIndex.Value);
        }

        if (GUI.changed || isDirty)
        {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
    private void Overlay(string inspector, string keyword)
    {
        bool toggle = oldKeyWords.Contains(keyword);
        bool ini    = toggle;

        GUIContent effectNameLabel = new GUIContent();

        effectNameLabel.tooltip = keyword + " (C#)";
        effectNameLabel.text    = effectCount + "." + inspector;
        toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);

        effectCount++;
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(keyword);
            EditorGUILayout.BeginVertical(style);
            {
                bool multModeOn = oldKeyWords.Contains("OVERLAYMULT_ON");
                bool isMultMode = multModeOn;
                isMultMode = GUILayout.Toggle(isMultMode, new GUIContent("Is overlay multiplicative?"));
                if (multModeOn != isMultMode)
                {
                    if (!Application.isPlaying)
                    {
                        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                    }
                    if (isMultMode)
                    {
                        multModeOn = true;
                        targetMat.EnableKeyword("OVERLAYMULT_ON");
                    }
                    else
                    {
                        targetMat.DisableKeyword("OVERLAYMULT_ON");
                    }
                }
                if (multModeOn)
                {
                    GUILayout.Label("Overlay is set to multiplicative mode", smallLabelStyle);
                }
                else
                {
                    GUILayout.Label("Overlay is set to additive mode", smallLabelStyle);
                }

                for (int i = 165; i <= 168; i++)
                {
                    DrawProperty(i);
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(keyword);
        }
        EditorGUILayout.EndToggleGroup();
    }
Exemplo n.º 15
0
        public override void OnInspectorGUI()
        {
            if (!_isAssimpAsset)
            {
                base.OnInspectorGUI();
                return;
            }
            GUI.enabled = true;
            #pragma warning disable 618
            EditorGUIUtility.LookLikeInspector();
            #pragma warning restore 618
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
            _currentTab = GUILayout.Toggle(_currentTab == 0, "General", "Button") ? 0 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 1, "Meshes", "Button") ? 1 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 2, "Materials", "Button") ? 2 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 3, "Animations", "Button") ? 3 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 4, "Advanced", "Button") ? 4 : _currentTab;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            switch (_currentTab)
            {
            case 0:
                EditorGUILayout.LabelField("General", EditorStyles.boldLabel);
                _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumMaskField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps);
                break;

            case 1:
            {
                EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Scale"));
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("RotationAngles"));
                        #if UNITY_2017_3_OR_NEWER
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Use32BitsIndexFormat"));
                        #endif
                var generateMeshCollidersProperty = _tempSerializedObject.FindProperty("GenerateMeshColliders");
                EditorGUILayout.PropertyField(generateMeshCollidersProperty);
                if (generateMeshCollidersProperty.boolValue)
                {
                    EditorGUI.indentLevel = 1;
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ConvexMeshColliders"));
                    EditorGUI.indentLevel = 0;
                }
            }
            break;

            case 2:
            {
                EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel);
                var dontLoadMaterialsProperty = _tempSerializedObject.FindProperty("DontLoadMaterials");
                EditorGUILayout.PropertyField(dontLoadMaterialsProperty);
                if (!dontLoadMaterialsProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TexturesPathOverride"));
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("MaterialsOverride"), new GUIContent("Material Override"), true);
                }
            }
            break;

            case 3:
            {
                EditorGUILayout.LabelField("Animations", EditorStyles.boldLabel);

                var dontLoadAnimationsProperty = _tempSerializedObject.FindProperty("DontLoadAnimations");
                EditorGUILayout.PropertyField(dontLoadAnimationsProperty);
                if (!dontLoadAnimationsProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AutoPlayAnimations"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimationWrapMode"));
                    var legacyAnimationProperty = _tempSerializedObject.FindProperty("UseLegacyAnimations");
                    EditorGUILayout.PropertyField(legacyAnimationProperty);
                    if (!legacyAnimationProperty.boolValue)
                    {
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimatorController"));
                    }
                }
            }
            break;

            default:
            {
                EditorGUILayout.LabelField("Advanced", EditorStyles.boldLabel);
                var advancedConfigs = _tempSerializedObject.FindProperty("AdvancedConfigs");
                var lastGroup       = string.Empty;
                var groupIndex      = 0;
                foreach (var configKey in AssetAdvancedPropertyMetadata.ConfigKeys)
                {
                    AssetAdvancedConfigType assetAdvancedConfigType;
                    string className;
                    string description;
                    string group;
                    bool   hasDefaultValue;
                    bool   hasMinValue;
                    bool   hasMaxValue;
                    object defaultValue;
                    object minValue;
                    object maxValue;
                    AssetAdvancedPropertyMetadata.GetOptionMetadata(configKey, out assetAdvancedConfigType, out className, out description, out group, out defaultValue, out minValue, out maxValue, out hasDefaultValue, out hasMinValue, out hasMaxValue);
                    SerializedProperty elementSerializedProperty = null;
                    var serializedElementIndex = 0;
                    var recentlyCreated        = false;
                    for (var i = 0; i < _tempAssetLoaderOptions.AdvancedConfigs.Count; i++)
                    {
                        var advancedProperty = _tempAssetLoaderOptions.AdvancedConfigs[i];
                        if (advancedProperty.Key == configKey)
                        {
                            serializedElementIndex    = i;
                            elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(i);
                            break;
                        }
                    }
                    if (group != lastGroup)
                    {
                        lastGroup = group;
                        _groupUnfolded[groupIndex] = EditorGUILayout.Foldout(_groupUnfolded[groupIndex], lastGroup);
                        groupIndex++;
                    }
                    if (_groupUnfolded[groupIndex - 1])
                    {
                        EditorGUILayout.BeginHorizontal();
                        var enableProperty = EditorGUILayout.BeginToggleGroup(new GUIContent(className, description), elementSerializedProperty != null);
                        if (elementSerializedProperty == null && enableProperty)
                        {
                            advancedConfigs.InsertArrayElementAtIndex(advancedConfigs.arraySize);
                            _tempSerializedObject.ApplyModifiedProperties();
                            var elementIndex = Mathf.Max(0, advancedConfigs.arraySize - 1);
                            elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(elementIndex);
                            elementSerializedProperty.FindPropertyRelative("Key").stringValue = configKey;
                            _tempSerializedObject.ApplyModifiedProperties();
                            recentlyCreated = true;
                        }
                        else if (elementSerializedProperty != null && !enableProperty)
                        {
                            advancedConfigs.DeleteArrayElementAtIndex(serializedElementIndex);
                            _tempSerializedObject.ApplyModifiedProperties();
                            return;
                        }
                        SerializedProperty valueSerializedProperty;
                        switch (assetAdvancedConfigType)
                        {
                        case AssetAdvancedConfigType.Bool:
                            var boolDefaultValue = hasDefaultValue && (bool)defaultValue;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.Toggle(boolDefaultValue ? "Enabled" : "Disabled", boolDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("BoolValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.boolValue = boolDefaultValue;
                                }
                                EditorGUILayout.PropertyField(valueSerializedProperty, new GUIContent(valueSerializedProperty.boolValue ? "Enabled" : "Disabled"));
                            }
                            break;

                        case AssetAdvancedConfigType.Integer:
                            var intDefaultValue = hasDefaultValue ? (int)defaultValue : 0;
                            if (hasMinValue && hasMaxValue)
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.IntSlider(intDefaultValue, (int)minValue, (int)maxValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.intValue = intDefaultValue;
                                    }
                                    EditorGUILayout.IntSlider(valueSerializedProperty, (int)minValue, (int)maxValue, GUIContent.none);
                                }
                            }
                            else
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.IntField(intDefaultValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.intValue = intDefaultValue;
                                    }
                                    EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                                }
                            }
                            break;

                        case AssetAdvancedConfigType.Float:
                            var floatDefaultValue = hasDefaultValue ? (float)defaultValue : 0f;
                            if (hasMinValue && hasMaxValue)
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.Slider(floatDefaultValue, (float)minValue, (float)maxValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.floatValue = floatDefaultValue;
                                    }
                                    EditorGUILayout.Slider(valueSerializedProperty, (float)minValue, (float)maxValue, GUIContent.none);
                                }
                            }
                            else
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.FloatField(floatDefaultValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.floatValue = floatDefaultValue;
                                    }
                                    EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                                }
                            }
                            break;

                        case AssetAdvancedConfigType.String:
                            var stringDefaultValue = hasDefaultValue ? (string)defaultValue : string.Empty;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.TextField(stringDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("StringValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.stringValue = stringDefaultValue;
                                }
                                EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiComponent:
                            var aiComponentDefaultValue = hasDefaultValue ? (AiComponent)defaultValue : AiComponent.Animations;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.EnumMaskField(aiComponentDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiComponentDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiPrimitiveType:
                            var aiPrimitiveTypeDefaultValue = hasDefaultValue ? (AiPrimitiveType)defaultValue : AiPrimitiveType.Line;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.EnumMaskField(aiPrimitiveTypeDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiPrimitiveTypeDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiUVTransform:
                            var aiUvTransformDefaultValue = hasDefaultValue ? (AiUVTransform)defaultValue : AiUVTransform.Rotation;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.EnumMaskField(aiUvTransformDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiUvTransformDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiMatrix:
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                GUILayout.BeginVertical();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Translation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.zero);
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Rotation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.zero);
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Scale", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.one);
                                GUILayout.EndHorizontal();
                                GUILayout.EndVertical();
                            }
                            else
                            {
                                GUI.enabled = true;
                                var valueSerializedProperty1 = elementSerializedProperty.FindPropertyRelative("TranslationValue");
                                var valueSerializedProperty2 = elementSerializedProperty.FindPropertyRelative("RotationValue");
                                var valueSerializedProperty3 = elementSerializedProperty.FindPropertyRelative("ScaleValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty1.vector3Value = Vector3.zero;
                                    valueSerializedProperty2.vector3Value = Vector3.zero;
                                    valueSerializedProperty3.vector3Value = Vector3.one;
                                }
                                GUILayout.BeginVertical();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Translation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty1, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Rotation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty2, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Scale", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty3, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.EndVertical();
                            }
                            break;
                        }
                        GUI.enabled = true;
                        EditorGUILayout.EndToggleGroup();
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            break;
            }
            if (EditorGUI.EndChangeCheck())
            {
                _hasChanged = true;
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = _hasChanged;
            if (GUILayout.Button("Revert"))
            {
                DestroyTempObject();
                _tempAssetLoaderOptions = AssetLoaderOptions.CreateInstance();
                SaveChanges();
            }
            if (GUILayout.Button("Apply"))
            {
                _tempSerializedObject.ApplyModifiedProperties();
                SaveChanges();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 16
0
    public void DisplayGUI()
    {
        MegaLoftLayerCloneSimple layer = (MegaLoftLayerCloneSimple)target;

        MegaShapeLoftEditor.PushCols();

        GUI.color           = Color.white;
        GUI.backgroundColor = layer.paramcol;
        GUI.contentColor    = Color.white;

        //MegaShapeLoft loft = layer.GetComponent<MegaShapeLoft>();

        SetLimits(layer.gameObject);
        EditorGUILayout.BeginVertical("TextArea");

        layer.LayerName = EditorGUILayout.TextField(MegaToolTip.LayerName, layer.LayerName);

        layer.LayerEnabled = EditorGUILayout.Toggle(MegaToolTip.Enabled, layer.LayerEnabled);
        layer.paramcol     = EditorGUILayout.ColorField(MegaToolTip.ParamCol, layer.paramcol);

        if (layer.LayerEnabled)
        {
            layer.Lock = EditorGUILayout.Toggle(MegaToolTip.Lock, layer.Lock);

            if (!layer.Lock)
            {
                // TODO: If null use material from main
                layer.material    = (Material)EditorGUILayout.ObjectField(MegaToolTip.Material, layer.material, typeof(Material), true);
                layer.surfaceLoft = (MegaShapeLoft)EditorGUILayout.ObjectField(MegaToolTip.Surface, layer.surfaceLoft, typeof(MegaShapeLoft), true);
                //layer.surfaceLayer = EditorGUILayout.Popup(MegaToolTip.Layer, layer.surfaceLayer + 1, MegaShapeUtils.GetLayersAsContent(layer.surfaceLoft)) - 1;
                int surfaceLayer = MegaShapeUtils.FindLayer(layer.surfaceLoft, layer.surfaceLayer);
                surfaceLayer = EditorGUILayout.Popup("Layer", surfaceLayer + 1, MegaShapeUtils.GetLayers(layer.surfaceLoft)) - 1;
                if (layer.surfaceLoft)
                {
                    for (int i = 0; i < layer.surfaceLoft.Layers.Length; i++)
                    {
                        //if ( layer.surfaceLoft.Layers[i].GetType() == typeof(MegaLoftLayerSimple) )
                        if (layer.surfaceLoft.Layers[i] is MegaLoftLayerSimple)
                        {
                            if (surfaceLayer == 0)
                            {
                                layer.surfaceLayer = i;
                                break;
                            }

                            surfaceLayer--;
                        }
                    }
                }
                else
                {
                    layer.surfaceLayer = surfaceLayer;
                }

                layer.start  = EditorGUILayout.Slider(MegaToolTip.Start, layer.start, sl, sh);
                layer.Length = EditorGUILayout.Slider(MegaToolTip.Length, layer.Length, ll, lh);

                layer.CrossAlpha = EditorGUILayout.Slider("Cross Alpha", layer.CrossAlpha, csl, csh);                   //-1.0f, 2.0f);
                layer.CalcUp     = EditorGUILayout.Toggle("Calc Up", layer.CalcUp);
                if (!layer.CalcUp)
                {
                    layer.RemoveDof = EditorGUILayout.FloatField("UpRight", layer.RemoveDof);
                }

                layer.Offset  = EditorGUILayout.Vector3Field("Offset", layer.Offset);
                layer.rot     = EditorGUILayout.Vector3Field("Rotate", layer.rot);
                layer.tmrot   = EditorGUILayout.Vector3Field("TMRotate", layer.tmrot);
                layer.tangent = EditorGUILayout.FloatField("Tangent", layer.tangent);
                layer.axis    = (MegaAxis)EditorGUILayout.EnumPopup("Axis", layer.axis);

                layer.useTwist = EditorGUILayout.BeginToggleGroup(MegaToolTip.UseTwist, layer.useTwist);
                layer.twist    = EditorGUILayout.FloatField(MegaToolTip.Twist, layer.twist);
                layer.twistCrv = EditorGUILayout.CurveField(MegaToolTip.TwistCrv, layer.twistCrv);
                EditorGUILayout.EndToggleGroup();

                // Advanced
                layer.GlobalScale = EditorGUILayout.FloatField("Scale", layer.GlobalScale);
                layer.useCrossCrv = EditorGUILayout.BeginToggleGroup("Use Cross Crv", layer.useCrossCrv);
                layer.CrossCrv    = EditorGUILayout.CurveField("Cross Crv", layer.CrossCrv);
                EditorGUILayout.EndToggleGroup();

                // Start Info
                //layer.showstartparams = EditorGUILayout.Foldout(layer.showstartparams, "Start Params");
                layer.showstartparams = MegaFoldOut.Start("Start Params", layer.showstartparams, new Color(1.0f, 0.5f, 0.5f));

                if (layer.showstartparams)
                {
                    //EditorGUILayout.BeginVertical("TextArea");
                    layer.StartEnabled = EditorGUILayout.Toggle("Enabled", layer.StartEnabled);
                    Mesh startObj = (Mesh)EditorGUILayout.ObjectField("Mesh", layer.startObj, typeof(Mesh), true);
                    if (startObj != layer.startObj)
                    {
                        layer.SetMesh(startObj, 0);
                    }

                    layer.StartOff   = EditorGUILayout.Vector3Field("Offset", layer.StartOff);
                    layer.StartScale = EditorGUILayout.Vector3Field("Scale", layer.StartScale);
                    layer.StartGap   = EditorGUILayout.FloatField("Gap", layer.StartGap);
                    //EditorGUILayout.EndVertical();
                }
                MegaFoldOut.End(layer.showstartparams);

                // Main Info
                //layer.showmainparams = EditorGUILayout.Foldout(layer.showmainparams, "Main Params");
                layer.showmainparams = MegaFoldOut.Start("Main Params", layer.showmainparams, new Color(0.5f, 1.0f, 0.5f));

                if (layer.showmainparams)
                {
                    //EditorGUILayout.BeginVertical("TextArea");
                    layer.MainEnabled = EditorGUILayout.Toggle("Enabled", layer.MainEnabled);
                    Mesh mainObj = (Mesh)EditorGUILayout.ObjectField("Mesh", layer.mainObj, typeof(Mesh), true);

                    if (mainObj != layer.mainObj)
                    {
                        layer.SetMesh(mainObj, 1);
                    }

                    layer.MainOff   = EditorGUILayout.Vector3Field("Offset", layer.MainOff);
                    layer.MainScale = EditorGUILayout.Vector3Field("Scale", layer.MainScale);
                    layer.Gap       = EditorGUILayout.FloatField("Gap", layer.Gap);
                    //EditorGUILayout.EndVertical();
                }
                MegaFoldOut.End(layer.showmainparams);

                // End Info
                //layer.showendparams = EditorGUILayout.Foldout(layer.showendparams, "End Params");
                layer.showendparams = MegaFoldOut.Start("End Params", layer.showendparams, new Color(0.5f, 0.5f, 1.0f));

                if (layer.showendparams)
                {
                    //EditorGUILayout.BeginVertical("TextArea");
                    layer.EndEnabled = EditorGUILayout.Toggle("Enabled", layer.EndEnabled);
                    Mesh endObj = (Mesh)EditorGUILayout.ObjectField("Mesh", layer.endObj, typeof(Mesh), true);
                    if (endObj != layer.endObj)
                    {
                        layer.SetMesh(endObj, 2);
                    }

                    layer.EndOff   = EditorGUILayout.Vector3Field("Offset", layer.EndOff);
                    layer.EndScale = EditorGUILayout.Vector3Field("Scale", layer.EndScale);
                    layer.EndGap   = EditorGUILayout.FloatField("Gap", layer.EndGap);
                    //EditorGUILayout.EndVertical();
                }
                MegaFoldOut.End(layer.showendparams);
            }

            //EditorGUILayout.EndVertical();
            //MegaShapeLoftEditor.PopCols();
        }
        EditorGUILayout.EndVertical();
        MegaShapeLoftEditor.PopCols();
    }
Exemplo n.º 17
0
    protected void ShaderFeature(string shaderKeywords, string title, string annotation
                                 , string[] propertiesName = null, string[] internalShaderKeywords = null)
    {
        var enable = Array.IndexOf(_targetMat.shaderKeywords, shaderKeywords) != -1;

        enable = EditorGUILayout.BeginToggleGroup(title, enable);
        if (enable)
        {
            _targetMat.EnableKeyword(shaderKeywords);
            GUILayout.Space(10);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            GUI.backgroundColor = Color.yellow;
            EditorGUILayout.HelpBox(annotation, MessageType.Info);
            GUI.backgroundColor = _backgroundColor;

            if (internalShaderKeywords != null && internalShaderKeywords.Length > 0)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                for (int i = 0; i < internalShaderKeywords.Length; i++)
                {
                    var keyword = internalShaderKeywords[i];
                    var state   = Array.IndexOf(_targetMat.shaderKeywords, keyword) != -1;
                    state = EditorGUILayout.BeginToggleGroup(keyword, state);
                    if (state)
                    {
                        _targetMat.EnableKeyword(keyword);
                    }
                    else
                    {
                        _targetMat.DisableKeyword(keyword);
                    }
                    EditorGUILayout.EndToggleGroup();
                }
                EditorGUILayout.EndVertical();
            }

            if (propertiesName != null && propertiesName.Length > 0)
            {
                GUI.backgroundColor = Color.green;
                EditorGUILayout.BeginVertical(GUI.skin.box);
                for (int i = 0; i < propertiesName.Length; i++)
                {
                    var propertyName = propertiesName[i];
                    ShaderProperty(propertyName);
                }
                EditorGUILayout.EndVertical();
                GUI.backgroundColor = _backgroundColor;
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            _targetMat.DisableKeyword(shaderKeywords);
            if (propertiesName != null && propertiesName.Length > 0)
            {
                for (int i = 0; i < propertiesName.Length; i++)
                {
                    var propertyName  = propertiesName[i];
                    var propertyCount = ShaderUtil.GetPropertyCount(_targetShader);
                    var propertyIdx   = -1;
                    for (int j = 0; j < propertyCount; j++)
                    {
                        if (ShaderUtil.GetPropertyName(_targetShader, j) == propertyName)
                        {
                            propertyIdx = j;
                            break;
                        }
                    }
                    if (propertyIdx < 0)
                    {
                        continue;
                    }
                    var propertyType = ShaderUtil.GetPropertyType(_targetShader, propertyIdx);
                    if (propertyType == ShaderUtil.ShaderPropertyType.TexEnv)
                    {
                        _targetMat.SetTexture(propertyName, null);
                    }
                }
            }
            if (internalShaderKeywords != null && internalShaderKeywords.Length > 0)
            {
                for (int i = 0; i < internalShaderKeywords.Length; i++)
                {
                    var keyword = internalShaderKeywords[i];
                    _targetMat.DisableKeyword(keyword);
                }
            }
        }
        EditorGUILayout.EndToggleGroup();
    }
Exemplo n.º 18
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(5);
        serializedObject.Update();
        me.childSpawnPoints = me.transform.GetComponentsInChildren <SpawnPoint>();

        if (debugToggle.boolValue = EditorInspector.ToggleLayout("Debug", debugToggle.boolValue))
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("StartWave"))
            {
                if (Application.isPlaying)
                {
                    me.StartWave();
                }
            }
            if (GUILayout.Button("N.NextWave"))
            {
                if (Application.isPlaying)
                {
                    me.NowNextWave();
                }
            }
            if (GUILayout.Button("T.NextWave"))
            {
                if (Application.isPlaying)
                {
                    me.TimeNextWave(waveDelay.intValue);
                }
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.PropertyField(gizmosColor, new GUIContent("Gizmos Color"));
            EditorGUILayout.PropertyField(gizmosSize, new GUIContent("Gizmos Size"));
        }

        if (settingToggle.boolValue = EditorInspector.ToggleLayout("Setting", settingToggle.boolValue))
        {
            autoStart.boolValue   = EditorGUILayout.ToggleLeft(new GUIContent("Auto Start"), autoStart.boolValue);
            autoProceed.boolValue = EditorGUILayout.BeginToggleGroup(new GUIContent("Auto Proceed"), autoProceed.boolValue);
            EditorGUILayout.PropertyField(waveDelay, new GUIContent("Wave Delay"));
            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.PropertyField(separatedPattern, new GUIContent("Separated Pattern"));
        }

        if (waveEventToggle.boolValue = EditorInspector.ToggleLayout("Wave Event", waveEventToggle.boolValue))
        {
            EditorGUILayout.PropertyField(onWaveStart, new GUIContent("On Wave Start"));
            EditorGUILayout.PropertyField(onWaveFinish, new GUIContent("On Wave Finish"));
            EditorGUILayout.PropertyField(onWaveClear, new GUIContent("On Wave Clear"));
        }

        if (waveProcessingEventToggle.boolValue = EditorInspector.ToggleLayout("Wave Processing Event", waveProcessingEventToggle.boolValue))
        {
            EditorGUILayout.PropertyField(onWaveProceedInt, new GUIContent("On Wave Proceed"));
            EditorGUILayout.PropertyField(onWaveProceedString, new GUIContent("On Wave Proceed"));
        }

        if (sequenceEventToggle.boolValue = EditorInspector.ToggleLayout("Sequence Event", sequenceEventToggle.boolValue))
        {
            EditorGUILayout.PropertyField(onAllWaveClear, new GUIContent("On All Wave Clear"));
        }

        EditorGUILayout.LabelField("Wave State", waveState.enumDisplayNames[waveState.enumValueIndex]);
        EditorGUILayout.LabelField(new GUIContent("Current Wave"), new GUIContent(currentWave.intValue.ToString()));

        if (waveSequence.arraySize > 0)
        {
            DrawWaveManager();
        }
        else
        {
            GUILayout.Space(5f);
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Start New Wave Sequence", GUILayout.Width(180)))
            {
                CreateWaveSequence(null);
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5f);
        }

        EditorUtility.SetDirty(me);
        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 19
0
    void OnGUI()
    {
        //create input form for pointsHolder
        EditorGUILayout.BeginHorizontal();
        pointsHolder = (Transform)EditorGUILayout.ObjectField("Points Holder", pointsHolder, typeof(Transform), true);
        if (GUILayout.Button("X", GUILayout.MaxWidth(20), GUILayout.MaxHeight(15)))
        {
            pointsHolder = null;
        }
        EditorGUILayout.EndHorizontal();

        connectEndPoints = EditorGUILayout.Toggle("Connect End Points", connectEndPoints);

        GUILayout.Space(5);

        //if nothing is assigned in pointsHolder input form make pointA and pointB input forms visible
        if (!pointsHolder)
        {
            pointA = (Transform)EditorGUILayout.ObjectField("PointA", pointA, typeof(Transform), true);
            GUILayout.Space(5);

            pointB = (Transform)EditorGUILayout.ObjectField("PointB", pointB, typeof(Transform), true);
            GUILayout.Space(5);
        }

        //create input form for chainObject
        chainObject = (GameObject)EditorGUILayout.ObjectField("Chain Object", chainObject, typeof(GameObject), true);

        GUILayout.Space(5);

        //create checkboxes for decision to lock first or last chains
        GUILayout.BeginHorizontal();
        lockFirstChain = EditorGUILayout.Toggle("Lock First Chain", lockFirstChain);
        lockLastChain  = EditorGUILayout.Toggle("Lock Last Chain", lockLastChain);
        GUILayout.EndHorizontal();

        if (lockFirstChain)
        {
            connectToA = false;
        }
        if (lockLastChain)
        {
            connectToB = false;
        }

        //create checkboxes for decision to connect to pointA or pointB
        GUILayout.BeginHorizontal();
        connectToA = EditorGUILayout.Toggle("Connect To Point A", connectToA);
        connectToB = EditorGUILayout.Toggle("Connect To Point B", connectToB);
        GUILayout.EndHorizontal();

        if (connectToA)
        {
            lockFirstChain = false;
        }
        if (connectToB)
        {
            lockLastChain = false;
        }

        //create checkbox for decision to hide start and end chains
        hideEndChains = EditorGUILayout.Toggle("Hide End Chains", hideEndChains);
        if (hideEndChains)
        {
            useLineRenderer = false;
        }

        GUILayout.Space(5);

        //create checkbox for decision to use linerenderer
        useLineRenderer = EditorGUILayout.BeginToggleGroup("Use Line Renderer", useLineRenderer);
        if (useLineRenderer)
        {
            hideEndChains = false;
        }

        //create input form for linerenderer's material
        ropeMat = (Material)EditorGUILayout.ObjectField("Material", ropeMat, typeof(Material), true);

        //create input form for linerenderer's width
        EditorGUILayout.BeginHorizontal();
        ropeWidth = EditorGUILayout.FloatField("Width", ropeWidth);
        if (ropeWidth < 0)
        {
            ropeWidth = 0.0f;
        }

        GUILayout.Space(17);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndToggleGroup();

        GUILayout.Space(10);

        //create font style for helpText
        GUIStyle fontStyle = new GUIStyle();

//		fontStyle.normal.textColor = Color.green;
        fontStyle.fontStyle = FontStyle.Bold;
        fontStyle.fontSize  = 12;
        fontStyle.alignment = TextAnchor.MiddleCenter;

        //create label for helpText
        GUILayout.Label(helpText, fontStyle);

        GUILayout.Space(10);

        if (GUILayout.Button("Create", GUILayout.MinHeight(30)))
        {
            //give hints if something isn't correct
            if (!pointA && !pointsHolder)
            {
                helpText = "PointA Isn't Assigned";
                return;
            }

            if (!pointB && !pointsHolder)
            {
                helpText = "PointB Isn't Assigned";
                return;
            }

            if (!chainObject)
            {
                helpText = "Chain Object Isn't Assigned";
                return;
            }

            if (pointA && pointB && pointA.GetInstanceID() == pointB.GetInstanceID())
            {
                helpText = "Same Object Is Assigned For Both PointA and PointB";
                return;
            }

            //if in pointsHolder is assigned, create rope between its children's positions
            if (pointsHolder)
            {
                pointsHolderArray = new List <Transform>();

                //get all children
                foreach (Transform child in pointsHolder)
                {
                    pointsHolderArray.Add(child);
                }

                //set pointA and pointB and create rope
                for (int i = 0; i < pointsHolderArray.Count - 1; i++)
                {
                    pointA = pointsHolderArray[i];
                    pointB = pointsHolderArray[i + 1];

                    Create();
                }

                //if connectEndPoints is set to true, create rope between first and last points
                if (connectEndPoints)
                {
                    pointA = pointsHolderArray[pointsHolderArray.Count - 1];
                    pointB = pointsHolderArray[0];

                    Create();
                }
            }
            else
            {
                Create();
            }

            helpText = "Created";
        }
    }
Exemplo n.º 20
0
    // ReSharper disable once FunctionComplexityOverflow
    public override void OnInspectorGUI()
    {
        EditorGUI.indentLevel = 0;

        var controller = (PlaylistController)target;

        MasterAudio.Instance = null;

        var ma        = MasterAudio.SafeInstance;
        var maInScene = ma != null;

        if (maInScene)
        {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.LogoTexture);
            _customEventNames = ma.CustomEventNames;
        }

        DTGUIHelper.HelpHeader("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/PlaylistControllers.htm", "https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MasterAudio_API/class_dark_tonic_1_1_master_audio_1_1_playlist_controller.html");

        var isDirty = false;

        EditorGUILayout.BeginHorizontal();

        var newVol = DTGUIHelper.DisplayVolumeField(controller._playlistVolume, DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true, "Playlist Volume");

        // ReSharper disable once CompareOfFloatsByEqualityOperator
        if (newVol != controller._playlistVolume)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Playlist Volume");
            controller.PlaylistVolume = newVol;
        }

        var buttonPressed = DTGUIHelper.AddPlaylistControllerGOButtons(controller, "Playlist Controller");

        EditorGUILayout.EndHorizontal();

        switch (buttonPressed)
        {
        case DTGUIHelper.DTFunctionButtons.Mute:
            controller.ToggleMutePlaylist();
            break;
        }

        if (maInScene)
        {
            // ReSharper disable once PossibleNullReferenceException
            var plNames = MasterAudio.Instance.PlaylistNames;

            var existingIndex = plNames.IndexOf(controller.startPlaylistName);

            int?groupIndex = null;

            var noPl    = false;
            var noMatch = false;

            if (existingIndex >= 1)
            {
                groupIndex = EditorGUILayout.Popup("Initial Playlist", existingIndex, plNames.ToArray());
                if (existingIndex == 1)
                {
                    noPl = true;
                }
            }
            else if (existingIndex == -1 && controller.startPlaylistName == MasterAudio.NoGroupName)
            {
                groupIndex = EditorGUILayout.Popup("Initial Playlist", existingIndex, plNames.ToArray());
            }
            else     // non-match
            {
                noMatch = true;
                var newPlaylist = EditorGUILayout.TextField("Initial Playlist", controller.startPlaylistName);
                if (newPlaylist != controller.startPlaylistName)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Initial Playlist");
                    controller.startPlaylistName = newPlaylist;
                }

                var newIndex = EditorGUILayout.Popup("All Playlists", -1, plNames.ToArray());
                if (newIndex >= 0)
                {
                    groupIndex = newIndex;
                }
            }

            if (noPl)
            {
                DTGUIHelper.ShowRedError("Initial Playlist not specified. No music will play.");
            }
            else if (noMatch)
            {
                DTGUIHelper.ShowRedError("Initial Playlist found no match. Type in or choose one from 'All Playlists'.");
            }

            if (groupIndex.HasValue)
            {
                if (existingIndex != groupIndex.Value)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Initial Playlist");
                }
                // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                if (groupIndex.Value == -1)
                {
                    controller.startPlaylistName = MasterAudio.NoGroupName;
                }
                else
                {
                    controller.startPlaylistName = plNames[groupIndex.Value];
                }
            }
        }


        var syncGroupList = new List <string>();

        for (var i = 0; i < 4; i++)
        {
            syncGroupList.Add((i + 1).ToString());
        }
        syncGroupList.Insert(0, MasterAudio.NoGroupName);

        var syncIndex = syncGroupList.IndexOf(controller.syncGroupNum.ToString());

        if (syncIndex == -1)
        {
            syncIndex = 0;
        }
        var newSync = EditorGUILayout.Popup("Controller Sync Group", syncIndex, syncGroupList.ToArray());

        if (newSync != syncIndex)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Controller Sync Group");
            controller.syncGroupNum = newSync;
        }

        EditorGUI.indentLevel = 0;

#if UNITY_5
        var newChan = (AudioMixerGroup)EditorGUILayout.ObjectField("Mixer Group", controller.mixerChannel, typeof(AudioMixerGroup), false);
        if (newChan != controller.mixerChannel)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Unity Mixer Group");
            controller.mixerChannel = newChan;

            if (Application.isPlaying)
            {
                controller.RouteToMixerChannel(newChan);
            }
        }

        if (!maInScene || ma.musicSpatialBlendType == MasterAudio.AllMusicSpatialBlendType.AllowDifferentPerController)
        {
            var newMusicSpatialType = (MasterAudio.ItemSpatialBlendType)EditorGUILayout.EnumPopup("Spatial Blend Rule", controller.spatialBlendType);
            if (newMusicSpatialType != controller.spatialBlendType)
            {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Spatial Blend Rule");
                controller.spatialBlendType = newMusicSpatialType;
                if (Application.isPlaying)
                {
                    controller.SetSpatialBlend();
                }
            }

            switch (controller.spatialBlendType)
            {
            case MasterAudio.ItemSpatialBlendType.ForceToCustom:
                EditorGUI.indentLevel = 1;
                DTGUIHelper.ShowLargeBarAlert(MasterAudioInspector.SpatialBlendSliderText);
                var newMusic3D = EditorGUILayout.Slider("Spatial Blend", controller.spatialBlend, 0f, 1f);
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (newMusic3D != controller.spatialBlend)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Spatial Blend");
                    controller.spatialBlend = newMusic3D;

                    if (Application.isPlaying)
                    {
                        controller.SetSpatialBlend();
                    }
                }
                break;
            }
        }
        else
        {
            DTGUIHelper.ShowLargeBarAlert("Spatial Blend is currently controlled globally in the Master Audio prefab.");
        }
                #endif

        EditorGUI.indentLevel = 0;
        var newAwake = EditorGUILayout.Toggle("Start Playlist on Awake?", controller.startPlaylistOnAwake);
        if (newAwake != controller.startPlaylistOnAwake)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "toggle Start Playlist on Awake");
            controller.startPlaylistOnAwake = newAwake;
        }

        var newShuffle = EditorGUILayout.Toggle("Shuffle Mode", controller.isShuffle);
        if (newShuffle != controller.isShuffle)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "toggle Shuffle Mode");
            controller.isShuffle = newShuffle;
        }

        var newLoop = EditorGUILayout.Toggle("Loop Playlists", controller.loopPlaylist);
        if (newLoop != controller.loopPlaylist)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "toggle Loop Playlists");
            controller.loopPlaylist = newLoop;
        }

        var newAuto = EditorGUILayout.Toggle("Auto advance clips", controller.isAutoAdvance);
        if (newAuto != controller.isAutoAdvance)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "toggle Auto advance clips");
            controller.isAutoAdvance = newAuto;
        }

        DTGUIHelper.ShowColorWarning("Note: auto advance will not advance past a looped track.");

        DTGUIHelper.StartGroupHeader();

        var newUse = EditorGUILayout.BeginToggleGroup(" Initialized Event", controller.initializedEventExpanded);
        if (newUse != controller.initializedEventExpanded)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "toggle expand Initialized Event");
            controller.initializedEventExpanded = newUse;
        }
        DTGUIHelper.EndGroupHeader();

        GUI.color = Color.white;

        if (controller.initializedEventExpanded)
        {
            DTGUIHelper.ShowColorWarning("When this Playlist Controller is done initializing, fire Custom Event below.");

            if (maInScene)
            {
                var existingIndex = _customEventNames.IndexOf(controller.initializedCustomEvent);

                int?customEventIndex = null;

                EditorGUI.indentLevel = 0;

                var noEvent = false;
                var noMatch = false;

                if (existingIndex >= 1)
                {
                    customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                    if (existingIndex == 1)
                    {
                        noEvent = true;
                    }
                }
                else if (existingIndex == -1 && controller.initializedCustomEvent == MasterAudio.NoGroupName)
                {
                    customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                }
                else     // non-match
                {
                    noMatch = true;
                    var newEventName = EditorGUILayout.TextField("Custom Event Name", controller.initializedCustomEvent);
                    if (newEventName != controller.initializedCustomEvent)
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Custom Event Name");
                        controller.initializedCustomEvent = newEventName;
                    }

                    var newIndex = EditorGUILayout.Popup("All Custom Events", -1, _customEventNames.ToArray());
                    if (newIndex >= 0)
                    {
                        customEventIndex = newIndex;
                    }
                }

                if (noEvent)
                {
                    DTGUIHelper.ShowRedError("No Custom Event specified. This section will do nothing.");
                }
                else if (noMatch)
                {
                    DTGUIHelper.ShowRedError("Custom Event found no match. Type in or choose one.");
                }

                if (customEventIndex.HasValue)
                {
                    if (existingIndex != customEventIndex.Value)
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Custom Event");
                    }
                    // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                    if (customEventIndex.Value == -1)
                    {
                        controller.initializedCustomEvent = MasterAudio.NoGroupName;
                    }
                    else
                    {
                        controller.initializedCustomEvent = _customEventNames[customEventIndex.Value];
                    }
                }
            }
            else
            {
                var newCustomEvent = EditorGUILayout.TextField("Custom Event Name", controller.initializedCustomEvent);
                if (newCustomEvent != controller.initializedCustomEvent)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "Custom Event Name");
                    controller.initializedCustomEvent = newCustomEvent;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        newUse = EditorGUILayout.BeginToggleGroup(" Song Changed Event", controller.songChangedEventExpanded);
        if (newUse != controller.songChangedEventExpanded)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "toggle expand Song Changed Event");
            controller.songChangedEventExpanded = newUse;
        }
        DTGUIHelper.EndGroupHeader();

        GUI.color = Color.white;

        if (controller.songChangedEventExpanded)
        {
            DTGUIHelper.ShowColorWarning("When song changes, fire Custom Event below.");

            if (maInScene)
            {
                var existingIndex = _customEventNames.IndexOf(controller.songChangedCustomEvent);

                int?customEventIndex = null;

                EditorGUI.indentLevel = 0;

                var noEvent = false;
                var noMatch = false;

                if (existingIndex >= 1)
                {
                    customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                    if (existingIndex == 1)
                    {
                        noEvent = true;
                    }
                }
                else if (existingIndex == -1 && controller.songChangedCustomEvent == MasterAudio.NoGroupName)
                {
                    customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                }
                else                     // non-match
                {
                    noMatch = true;
                    var newEventName = EditorGUILayout.TextField("Custom Event Name", controller.songChangedCustomEvent);
                    if (newEventName != controller.songChangedCustomEvent)
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Custom Event Name");
                        controller.songChangedCustomEvent = newEventName;
                    }

                    var newIndex = EditorGUILayout.Popup("All Custom Events", -1, _customEventNames.ToArray());
                    if (newIndex >= 0)
                    {
                        customEventIndex = newIndex;
                    }
                }

                if (noEvent)
                {
                    DTGUIHelper.ShowRedError("No Custom Event specified. This section will do nothing.");
                }
                else if (noMatch)
                {
                    DTGUIHelper.ShowRedError("Custom Event found no match. Type in or choose one.");
                }

                if (customEventIndex.HasValue)
                {
                    if (existingIndex != customEventIndex.Value)
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Custom Event");
                    }
                    // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                    if (customEventIndex.Value == -1)
                    {
                        controller.songChangedCustomEvent = MasterAudio.NoGroupName;
                    }
                    else
                    {
                        controller.songChangedCustomEvent = _customEventNames[customEventIndex.Value];
                    }
                }
            }
            else
            {
                var newCustomEvent = EditorGUILayout.TextField("Custom Event Name", controller.songChangedCustomEvent);
                if (newCustomEvent != controller.songChangedCustomEvent)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "Custom Event Name");
                    controller.songChangedCustomEvent = newCustomEvent;
                }
            }
        }

        EditorGUILayout.EndToggleGroup();
        DTGUIHelper.AddSpaceForNonU5(2);

        DTGUIHelper.StartGroupHeader();

        newUse = EditorGUILayout.BeginToggleGroup(" Song Ended Event", controller.songEndedEventExpanded);
        if (newUse != controller.songEndedEventExpanded)
        {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "toggle expand Song Ended Event");
            controller.songEndedEventExpanded = newUse;
        }
        DTGUIHelper.EndGroupHeader();

        GUI.color = Color.white;

        if (controller.songEndedEventExpanded)
        {
            DTGUIHelper.ShowColorWarning("When song ends, fire Custom Event below.");

            if (maInScene)
            {
                var existingIndex = _customEventNames.IndexOf(controller.songEndedCustomEvent);

                int?customEventIndex = null;

                EditorGUI.indentLevel = 0;

                var noEvent = false;
                var noMatch = false;

                if (existingIndex >= 1)
                {
                    customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                    if (existingIndex == 1)
                    {
                        noEvent = true;
                    }
                }
                else if (existingIndex == -1 && controller.songEndedCustomEvent == MasterAudio.NoGroupName)
                {
                    customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                }
                else     // non-match
                {
                    noMatch = true;
                    var newEventName = EditorGUILayout.TextField("Custom Event Name", controller.songEndedCustomEvent);
                    if (newEventName != controller.songEndedCustomEvent)
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Custom Event Name");
                        controller.songEndedCustomEvent = newEventName;
                    }

                    var newIndex = EditorGUILayout.Popup("All Custom Events", -1, _customEventNames.ToArray());
                    if (newIndex >= 0)
                    {
                        customEventIndex = newIndex;
                    }
                }

                if (noEvent)
                {
                    DTGUIHelper.ShowRedError("No Custom Event specified. This section will do nothing.");
                }
                else if (noMatch)
                {
                    DTGUIHelper.ShowRedError("Custom Event found no match. Type in or choose one.");
                }

                if (customEventIndex.HasValue)
                {
                    if (existingIndex != customEventIndex.Value)
                    {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "change Custom Event");
                    }
                    // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                    if (customEventIndex.Value == -1)
                    {
                        controller.songEndedCustomEvent = MasterAudio.NoGroupName;
                    }
                    else
                    {
                        controller.songEndedCustomEvent = _customEventNames[customEventIndex.Value];
                    }
                }
            }
            else
            {
                var newCustomEvent = EditorGUILayout.TextField("Custom Event Name", controller.songEndedCustomEvent);
                if (newCustomEvent != controller.songEndedCustomEvent)
                {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref isDirty, controller, "Custom Event Name");
                    controller.songEndedCustomEvent = newCustomEvent;
                }
            }
        }
        EditorGUILayout.EndToggleGroup();

        if (GUI.changed || isDirty)
        {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim parameters:", EditorStyles.boldLabel);

            character.spriteChild        = (Transform)EditorGUILayout.ObjectField("Sprite child:", character.spriteChild, typeof(Transform), true);
            character.moveSpeedParameter = EditorGUILayout.TextField("Move speed float:", character.moveSpeedParameter);
            character.turnParameter      = EditorGUILayout.TextField("Turn float:", character.turnParameter);
            character.directionParameter = EditorGUILayout.TextField("Direction integer:", character.directionParameter);
            character.angleParameter     = EditorGUILayout.TextField("Angle float:", character.angleParameter);
            character.talkParameter      = EditorGUILayout.TextField("Talk bool:", character.talkParameter);

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    character.phonemeParameter = EditorGUILayout.TextField("Phoneme integer:", character.phonemeParameter);
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }

            if (character.useExpressions)
            {
                character.expressionParameter = EditorGUILayout.TextField("Expression ID integer:", character.expressionParameter);
            }

            character.verticalMovementParameter = EditorGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter);
            character.talkingAnimation          = TalkingAnimation.Standard;
            character.doDirections = true;
            character.doDiagonals  = EditorGUILayout.Toggle("Diagonal sprites?", character.doDiagonals);

            Animator charAnimator = character.GetAnimator();
            if (charAnimator == null || !charAnimator.applyRootMotion)
            {
                character.antiGlideMode = EditorGUILayout.ToggleLeft("Only move when sprite changes?", character.antiGlideMode);
            }

            character.doWallReduction = EditorGUILayout.BeginToggleGroup("Slow movement near wall colliders?", character.doWallReduction);
            character.wallLayer       = EditorGUILayout.TextField("Wall collider layer:", character.wallLayer);
            character.wallDistance    = EditorGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f);
            EditorGUILayout.EndToggleGroup();

            if (KickStarter.settingsManager != null && KickStarter.settingsManager.cameraPerspective != CameraPerspective.TwoD)
            {
                character.rotateSprite3D = (RotateSprite3D)EditorGUILayout.EnumPopup("Rotate sprite to:", character.rotateSprite3D);
            }

            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
        //      public override bool RequiresConstantRepaint()
        //      {
        //          return true;
        //      }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            //DrawDefaultInspector();

            GUILayout.Label("MaryTTS", EditorStyles.boldLabel);

            maryTTSMode = EditorGUILayout.BeginToggleGroup(new GUIContent("MaryTTS Mode", "Enables or disables MaryTTS (default: false)."), script.MaryTTSMode);
            if (maryTTSMode != script.MaryTTSMode)
            {
                serializedObject.FindProperty("MaryTTSMode").boolValue = maryTTSMode;
                Speaker.isMaryMode = maryTTSMode;
                Speaker.ReloadProvider();
            }

            EditorGUI.indentLevel++;

            maryTTSUrl = EditorGUILayout.TextField(new GUIContent("MaryTTS URL", "Server URL for MaryTTS."), script.MaryTTSUrl);
            if (!maryTTSUrl.Equals(script.MaryTTSUrl))
            {
                serializedObject.FindProperty("MaryTTSUrl").stringValue = maryTTSUrl;
            }

            maryTTSPort = EditorGUILayout.IntSlider("MaryTTS Port", script.MaryTTSPort, 0, 65535);
            if (maryTTSPort != script.MaryTTSPort)
            {
                serializedObject.FindProperty("MaryTTSPort").intValue = maryTTSPort;
            }

            maryTTSUser = EditorGUILayout.TextField(new GUIContent("MaryTTS User", "User name for MaryTTS (default: empty)."), script.MaryTTSUser);
            if (!maryTTSUser.Equals(script.MaryTTSUser))
            {
                serializedObject.FindProperty("MaryTTSUser").stringValue = maryTTSUser;
            }

            maryTTSPassword = EditorGUILayout.PasswordField(new GUIContent("MaryTTS Password", "User password for MaryTTS (default: empty)."), script.MaryTTSPassword);
            if (!maryTTSPassword.Equals(script.MaryTTSPassword))
            {
                serializedObject.FindProperty("MaryTTSPassword").stringValue = maryTTSPassword;
            }

            maryTTSType = (Model.Enum.MaryTTSType)EditorGUILayout.EnumPopup(new GUIContent("MaryTTS Type", "Input type for MaryTTS (default: MaryTTSType.RAWMARYXML)."), script.MaryTTSType);
            if (maryTTSType != script.MaryTTSType)
            {
                serializedObject.FindProperty("MaryTTSType").enumValueIndex = (int)maryTTSType;
            }

            EditorGUI.indentLevel--;
            EditorGUILayout.EndToggleGroup();

            GUILayout.Space(8);
            GUILayout.Label("Advanced Settings", EditorStyles.boldLabel);

            autoClearTags = EditorGUILayout.Toggle(new GUIContent("Auto Clear Tags", "Automatically clear tags from speeches depending on the capabilities of the current TTS-system (default: false)."), script.AutoClearTags);
            if (autoClearTags != script.AutoClearTags)
            {
                serializedObject.FindProperty("AutoClearTags").boolValue = autoClearTags;
            }

            GUILayout.Space(8);
            GUILayout.Label("Behaviour Settings", EditorStyles.boldLabel);

            silenceOnDisable = EditorGUILayout.Toggle(new GUIContent("Silence On Disable", "Silence any speeches if this component gets disabled (default: false)."), script.SilenceOnDisable);
            if (silenceOnDisable != script.SilenceOnDisable)
            {
                serializedObject.FindProperty("SilenceOnDisable").boolValue = silenceOnDisable;
            }

            silenceOnFocusLost = EditorGUILayout.Toggle(new GUIContent("Silence On Focus Lost", "Silence any speeches if the application loses the focus (default: true)."), script.SilenceOnFocustLost);
            if (silenceOnFocusLost != script.SilenceOnFocustLost)
            {
                serializedObject.FindProperty("SilenceOnFocustLost").boolValue = silenceOnFocusLost;
            }

            dontDestroy = EditorGUILayout.Toggle(new GUIContent("Dont Destroy", "Don't destroy gameobject during scene switches (default: true)."), script.DontDestroy);
            if (dontDestroy != script.DontDestroy)
            {
                serializedObject.FindProperty("DontDestroy").boolValue = dontDestroy;
            }

            GUILayout.Space(8);

            if (GUILayout.Button(new GUIContent(" Reload", EditorHelper.Icon_Refresh, "Reload the provider.")))
            {
                Speaker.ReloadProvider();
                GAApi.Event(typeof(SpeakerEditor).Name, "Reload the provider");
            }

            EditorHelper.SeparatorUI();

            if (script.isActiveAndEnabled)
            {
                GUILayout.Label("Data", EditorStyles.boldLabel);

                showVoices = EditorGUILayout.Foldout(showVoices, "Voices (" + Speaker.Voices.Count + ")");
                if (showVoices)
                {
                    EditorGUI.indentLevel++;

                    foreach (string voice in Speaker.Voices.CTToString())
                    {
                        EditorGUILayout.SelectableLabel(voice, GUILayout.Height(16), GUILayout.ExpandHeight(false));
                    }

                    EditorGUI.indentLevel--;
                }

                EditorHelper.SeparatorUI();

                if (Speaker.Voices.Count > 0)
                {
                    GUILayout.Label("Test-Drive", EditorStyles.boldLabel);

                    if (Util.Helper.isEditorMode)
                    {
                        if (Speaker.isMaryMode)
                        {
                            EditorGUILayout.HelpBox("Test-Drive is not supported for MaryTTS.", MessageType.Info);
                        }
                        else
                        {
                            voiceIndex = EditorGUILayout.Popup("Voice", voiceIndex, Speaker.Voices.CTToString().ToArray());
                            rate       = EditorGUILayout.Slider("Rate", rate, 0f, 3f);

                            if (Util.Helper.isWindowsPlatform)
                            {
                                pitch = EditorGUILayout.Slider("Pitch", pitch, 0f, 2f);

                                volume = EditorGUILayout.Slider("Volume", volume, 0f, 1f);
                            }

                            GUILayout.Space(8);

                            GUILayout.BeginHorizontal();
                            {
                                if (GUILayout.Button(new GUIContent(" Speak", EditorHelper.Icon_Speak, "Speaks the text with the selected voice and settings.")))
                                {
                                    Speaker.SpeakNativeInEditor("You have selected " + Speaker.Voices[voiceIndex].Name, Speaker.Voices[voiceIndex], rate, pitch, volume);
                                    GAApi.Event(typeof(SpeakerEditor).Name, "Speak");
                                }

                                GUI.enabled = Speaker.isSpeaking;

                                if (GUILayout.Button(new GUIContent(" Silence", EditorHelper.Icon_Silence, "Silence all active speakers.")))
                                {
                                    Speaker.Silence();
                                    GAApi.Event(typeof(SpeakerEditor).Name, "Silence");
                                }

                                GUI.enabled = true;
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Disabled in Play-mode!", MessageType.Info);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("TTS with the current settings is not possible!", MessageType.Error);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Script is disabled!", MessageType.Info);
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim parameters:", EditorStyles.boldLabel);

            character.moveSpeedParameter = EditorGUILayout.TextField("Move speed float:", character.moveSpeedParameter);
            character.turnParameter      = EditorGUILayout.TextField("Turn float:", character.turnParameter);
            character.talkParameter      = EditorGUILayout.TextField("Talk bool:", character.talkParameter);

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
                AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    if (character.GetShapeable())
                    {
                        character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Attach a Shapeable script to show phoneme options", MessageType.Info);
                    }
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }

            if (!character.ikHeadTurning)
            {
                character.headYawParameter   = EditorGUILayout.TextField("Head yaw float:", character.headYawParameter);
                character.headPitchParameter = EditorGUILayout.TextField("Head pitch float:", character.headPitchParameter);
            }

            character.verticalMovementParameter = EditorGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter);
            character.isGroundedParameter       = EditorGUILayout.TextField("'Is grounded' bool:", character.isGroundedParameter);
            if (character is Player)
            {
                Player player = (Player)character;
                player.jumpParameter = EditorGUILayout.TextField("Jump bool:", player.jumpParameter);
            }
            character.talkingAnimation = TalkingAnimation.Standard;

            if (character.useExpressions)
            {
                character.expressionParameter = EditorGUILayout.TextField("Expression ID integer:", character.expressionParameter);
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim settings:", EditorStyles.boldLabel);

            if (SceneSettings.IsTopDown())
            {
                character.spriteChild = (Transform)EditorGUILayout.ObjectField("Animator child:", character.spriteChild, typeof(Transform), true);
            }
            else
            {
                character.spriteChild    = null;
                character.customAnimator = (Animator)EditorGUILayout.ObjectField("Animator (optional):", character.customAnimator, typeof(Animator), true);
            }

            character.headLayer  = EditorGUILayout.IntField("Head layer #:", character.headLayer);
            character.mouthLayer = EditorGUILayout.IntField("Mouth layer #:", character.mouthLayer);

            character.ikHeadTurning = EditorGUILayout.Toggle("IK head-turning?", character.ikHeadTurning);
            if (character.ikHeadTurning)
            {
                                #if UNITY_5 || UNITY_2017_1_OR_NEWER || UNITY_PRO_LICENSE
                EditorGUILayout.HelpBox("'IK Pass' must be enabled for this character's Base layer.", MessageType.Info);
                                #else
                EditorGUILayout.HelpBox("This features is only available with Unity 5 or Unity Pro.", MessageType.Info);
                                #endif
            }

            if (!Application.isPlaying)
            {
                character.ResetAnimator();
            }
            Animator charAnimator = character.GetAnimator();
            if (charAnimator != null && charAnimator.applyRootMotion)
            {
                character.rootTurningFactor = EditorGUILayout.Slider("Root Motion turning:", character.rootTurningFactor, 0f, 1f);
            }
            character.doWallReduction            = EditorGUILayout.BeginToggleGroup("Slow movement near wall colliders?", character.doWallReduction);
            character.wallLayer                  = EditorGUILayout.TextField("Wall collider layer:", character.wallLayer);
            character.wallDistance               = EditorGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f);
            character.wallReductionOnlyParameter = EditorGUILayout.Toggle("Only affects Mecanim parameter?", character.wallReductionOnlyParameter);
            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Bone transforms:", EditorStyles.boldLabel);

            character.neckBone      = (Transform)EditorGUILayout.ObjectField("Neck bone:", character.neckBone, typeof(Transform), true);
            character.leftHandBone  = (Transform)EditorGUILayout.ObjectField("Left hand:", character.leftHandBone, typeof(Transform), true);
            character.rightHandBone = (Transform)EditorGUILayout.ObjectField("Right hand:", character.rightHandBone, typeof(Transform), true);
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
Exemplo n.º 24
0
    override public void OnInspectorGUI()
    {
        Draw script = (Draw)target;

        GUILayout.Space(5);

        GUILayout.Label("Draw Method", EditorStyles.boldLabel);

        script.drawStyle = (Draw.DrawStyle)EditorGUILayout.EnumPopup("Draw Style", script.drawStyle);

        // Style Specific Options
        switch (script.drawStyle)
        {
        case Draw.DrawStyle.Continuous:
            script.samplingRate = EditorGUILayout.FloatField("Sample Rate", script.samplingRate);
            break;

        case Draw.DrawStyle.ContinuousClosingDistance:
            script.samplingRate    = EditorGUILayout.FloatField("Sample Rate", script.samplingRate);
            script.closingDistance = EditorGUILayout.FloatField("Closing Distance", script.closingDistance);
            break;

        case Draw.DrawStyle.PointMaxVertex:
            script.maxVertices = EditorGUILayout.IntField("Max Allowed Vertices", script.maxVertices);
            break;

        case Draw.DrawStyle.PointClosingDistance:
            script.closingDistance = EditorGUILayout.FloatField("Closing Distance", script.closingDistance);
            break;
        }

        script.drawSettings.axis = (Polydraw.Axis)EditorGUILayout.EnumPopup(script.drawSettings.axis);

        script.inputCamera = (Camera)EditorGUILayout.ObjectField(new GUIContent("Input Camera", "The camera that listens for mouse input.  Must be orthographic."), script.inputCamera, typeof(Camera), true);

        GUILayout.Space(5);

        showDrawSettings = EditorGUILayout.Foldout(showDrawSettings, "Drawing Settings");
        if (showDrawSettings)
        {
            script.showPointMarkers = EditorGUILayout.BeginToggleGroup("Show Vertex Markers", script.showPointMarkers);
            script.pointMarker      = (GameObject)EditorGUILayout.ObjectField("Point Marker", script.pointMarker, typeof(GameObject), true);
            EditorGUILayout.EndToggleGroup();

            script.drawMeshInProgress = EditorGUILayout.Toggle("Draw Preview Mesh", script.drawMeshInProgress);

            script.drawLineRenderer = EditorGUILayout.BeginToggleGroup("Draw Line Renderer", script.drawLineRenderer);
            script.lineRenderer     = (LineRenderer)EditorGUILayout.ObjectField(new GUIContent("Trail Renderer", "If left null, a default trail renderer will be applied automatically."), script.lineRenderer, typeof(LineRenderer), true);
            if (script.lineRenderer == null)
            {
                script.lineWidth = EditorGUILayout.FloatField("Trail Renderer Width", script.lineWidth);
            }
            EditorGUILayout.EndToggleGroup();

            script.drawSettings.requireMinimumArea = EditorGUILayout.BeginToggleGroup(new GUIContent("Require Minimum Area to Draw Object", "If true, the drawn polygon must have an area greater than this value in order to be generated.  Perfect for use with Drawing Style Continuous."), script.drawSettings.requireMinimumArea);
            script.drawSettings.minimumAreaToDraw  = EditorGUILayout.FloatField("Minimum Area", script.drawSettings.minimumAreaToDraw);
            EditorGUILayout.EndToggleGroup();

            script.useDistanceCheck = EditorGUILayout.BeginToggleGroup(new GUIContent("Use Distance Check", "If final user set point is greater than `x` distance from origin point, polygon will not be drawn"), script.useDistanceCheck);
            script.maxDistance      = EditorGUILayout.FloatField("Max Distance from Origin", script.maxDistance);
            EditorGUILayout.EndToggleGroup();
        }

        showMeshSettings = EditorGUILayout.Foldout(showMeshSettings, "Mesh Settings");
        if (showMeshSettings)
        {
            script.drawSettings.meshName = EditorGUILayout.TextField("Mesh Name", script.drawSettings.meshName);

            script.drawSettings.frontMaterial = (Material)EditorGUILayout.ObjectField("Material", script.drawSettings.frontMaterial, typeof(Material), false);

            script.drawSettings.anchor = (Draw.Anchor)EditorGUILayout.EnumPopup("Mesh Anchor", script.drawSettings.anchor);

            script.drawSettings.zPosition = EditorGUILayout.FloatField("Z Origin", script.drawSettings.zPosition);

            script.drawSettings.faceOffset = EditorGUILayout.FloatField(new GUIContent("Z Offset", "Allows for custom offsets.  See docs for details."), script.drawSettings.faceOffset);

            script.drawSettings.generateBackFace = EditorGUILayout.Toggle("Generate Back", script.drawSettings.generateBackFace);

            script.drawSettings.generateSide = EditorGUILayout.BeginToggleGroup("Generate Sides", script.drawSettings.generateSide);

            script.drawSettings.sideLength   = EditorGUILayout.FloatField("Side Length", script.drawSettings.sideLength);
            script.drawSettings.sideMaterial = (Material)EditorGUILayout.ObjectField("Side Material", script.drawSettings.sideMaterial, typeof(Material), false);

            EditorGUILayout.EndToggleGroup();

            script.drawSettings.drawEdgePlanes = EditorGUILayout.BeginToggleGroup("Draw Edge Planes", script.drawSettings.drawEdgePlanes);

            script.drawSettings.edgeMaterial       = (Material)EditorGUILayout.ObjectField("Edge Material", script.drawSettings.edgeMaterial, typeof(Material), false);
            script.drawSettings.edgeLengthModifier = EditorGUILayout.FloatField(new GUIContent("Edge Length Modifier", "Multiply the length of the plane by this amount.  1 = no change, 1.3 = 33% longer."), script.drawSettings.edgeLengthModifier);
            script.drawSettings.edgeHeight         = EditorGUILayout.FloatField(new GUIContent("Edge Height", "Absolute value; how tall to make edge planes."), script.drawSettings.edgeHeight);
            script.drawSettings.minLengthToDraw    = EditorGUILayout.FloatField(new GUIContent("Minimum Edge Length", "Edges with a length less than this amount will not be drawn."), script.drawSettings.minLengthToDraw);
            script.drawSettings.edgeOffset         = EditorGUILayout.FloatField(new GUIContent("Edge Z Offset", "Value to scoot mesh + or - from Z Position."), script.drawSettings.edgeOffset);
            script.drawSettings.maxAngle           = EditorGUILayout.FloatField(new GUIContent("Maximum Slope", "Edge Z rotation must be less than this amount to be drawn.  Set to 180 to draw a complete loop, or leave at 45 to only draw up facing planes."), script.drawSettings.maxAngle);
            script.drawSettings.areaRelativeHeight = EditorGUILayout.Toggle(new GUIContent("Area Relative Height", "If true, the height of each plane will be modified by how large the finalized mesh is."), script.drawSettings.areaRelativeHeight);
            if (script.drawSettings.areaRelativeHeight)
            {
                script.drawSettings.minEdgeHeight = EditorGUILayout.FloatField("Minimum Edge Height", script.drawSettings.minEdgeHeight);
                script.drawSettings.maxEdgeHeight = EditorGUILayout.FloatField("Maximum Edge Height", script.drawSettings.maxEdgeHeight);
            }

            EditorGUILayout.EndToggleGroup();

            script.drawSettings.uvScale = EditorGUILayout.Vector2Field("UV Scale", script.drawSettings.uvScale);
        }

        showGameObjectSettings = EditorGUILayout.Foldout(showGameObjectSettings, "GameObject Settings");
        if (showGameObjectSettings)
        {
            script.drawSettings.useTag = EditorGUILayout.BeginToggleGroup(new GUIContent("Apply Tag", "Tag must exist prior to assignment."), script.drawSettings.useTag);
            script.drawSettings.tagVal = EditorGUILayout.TextField("Tag", script.drawSettings.tagVal);
            EditorGUILayout.EndToggleGroup();

            script.maxAllowedObjects = EditorGUILayout.IntField("Max Drawn Objects Allowed", script.maxAllowedObjects);
        }

        showCollisionSettings = EditorGUILayout.Foldout(showCollisionSettings, "Physics Settings");
        if (showCollisionSettings)
        {
            script.drawSettings.colliderType = (Draw.ColliderType)EditorGUILayout.EnumPopup(new GUIContent("Collison", "If set to mesh, a Mesh Collider will be applied.  If set to Box, a series of thin box colliders will be generated bordering the edges, allowing for concave interactions.  None means no collider will be applied."), script.drawSettings.colliderType);

            if (script.drawSettings.colliderType == Draw.ColliderType.BoxCollider)
            {
                if (!script.drawSettings.manualColliderDepth)
                {
                    script.drawSettings.colDepth = script.drawSettings.sideLength;
                }

                script.drawSettings.manualColliderDepth = EditorGUILayout.BeginToggleGroup(new GUIContent("Manual Collider Depth", "If false, the side length will be used as the depth value."), script.drawSettings.manualColliderDepth);

                script.drawSettings.colDepth = EditorGUILayout.FloatField("Collider Depth", script.drawSettings.colDepth);

                EditorGUILayout.EndToggleGroup();
            }

            switch (script.drawSettings.colliderType)
            {
            case Draw.ColliderType.BoxCollider:
                break;

            case Draw.ColliderType.MeshCollider:
                script.drawSettings.forceConvex = EditorGUILayout.Toggle("Force Convex", script.drawSettings.forceConvex);
                break;

            case Draw.ColliderType.None:
                break;
            }

            script.drawSettings.applyRigidbody = EditorGUILayout.BeginToggleGroup("Apply Rigidbody", script.drawSettings.applyRigidbody);

            script.drawSettings.useGravity = EditorGUILayout.Toggle("Use Gravity", script.drawSettings.useGravity);

            script.drawSettings.isKinematic = EditorGUILayout.Toggle("Is Kinematic", script.drawSettings.isKinematic);

            script.drawSettings.areaRelativeMass = EditorGUILayout.Toggle("Area Relative Mass", script.drawSettings.areaRelativeMass);
            if (script.drawSettings.areaRelativeMass)
            {
                script.drawSettings.massModifier = EditorGUILayout.FloatField("Mass Modifier", script.drawSettings.massModifier);
            }
            else
            {
                script.drawSettings.mass = EditorGUILayout.FloatField("Mass", script.drawSettings.mass);
            }
            EditorGUILayout.EndToggleGroup();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(script);
        }
    }
Exemplo n.º 25
0
    private void OnGUI()
    {
        GUILayout.Label("Language Editor", EditorStyles.boldLabel);

        if (localizationMaster)
        {
            GUILayout.Label("Localization Master Found In Resources Folder.", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            var saveContent = new GUIContent("Save active language", "Save active language");
            var LoadContent = new GUIContent("Load active language", "Load active language");

            if (GUILayout.Button(saveContent))
            {
                localizationMaster.Save();
            }

            if (GUILayout.Button(LoadContent))
            {
                localizationMaster.Load();
            }

            EditorGUILayout.EndHorizontal();
            ShowAvailableLanguages = EditorGUILayout.Toggle("Show Available Languages", ShowAvailableLanguages);

            if (ShowAvailableLanguages)
            {
                EditAvailableLanguages = EditorGUILayout.BeginToggleGroup("Show Available Languages", EditAvailableLanguages);

                for (var i = 0; i < localizationMaster.AvailableLanguages.Count; i++)
                {
                    if (localizationMaster.AvailableLanguages[i] == LocalizationMaster.englishID)
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(20));
                        GUILayout.Label(localizationMaster.AvailableLanguages[i]);
                        var setContent = new GUIContent("Set English to active language", "Set _en to Active Language");

                        if (localizationMaster.LangIndex != i)
                        {
                            if (GUILayout.Button(setContent))
                            {
                                localizationMaster.SetLang(i);
                            }
                        }
                        else
                        {
                            GUILayout.Label("Active", GUILayout.Width(100));
                        }
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(20));
                        localizationMaster.AvailableLanguages[i] = EditorGUILayout.TextArea(localizationMaster.AvailableLanguages[i]);
                        var setContent = new GUIContent("Set Active", string.Format("Set {0} to Active Language", localizationMaster.AvailableLanguages[i]));

                        if (localizationMaster.LangIndex != i)
                        {
                            if (GUILayout.Button(setContent, GUILayout.Width(100)))
                            {
                                localizationMaster.SetLang(i);
                            }
                        }
                        else
                        {
                            GUILayout.Label("Active", GUILayout.Width(100));
                        }

                        var resetContent = new GUIContent("Reset Language", "Reset Entries to Key only");

                        if (GUILayout.Button(resetContent, GUILayout.Width(100)))
                        {
                            ResetLanguage(i);
                        }

                        var deleteContent = new GUIContent("X", "Delete Entry");

                        if (GUILayout.Button(deleteContent, GUILayout.Width(25)))
                        {
                            localizationMaster.AvailableLanguages.RemoveAt(i);
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.BeginHorizontal();
                NewLangString = EditorGUILayout.TextArea(NewLangString);

                if (GUILayout.Button("Add New Language"))
                {
                    NewLanguage();
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndToggleGroup();
            }

            ShowLanguageEntries = EditorGUILayout.Toggle("Entries in the language Database. Show?", ShowLanguageEntries);

            if (ShowLanguageEntries)
            {
                for (var i = 0; i < localizationMaster.DictionaryData.Data.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(20));

                    localizationMaster.DictionaryData.Data[i] = new LocalizationDictionaryEntry(EditorGUILayout.TextArea(localizationMaster.DictionaryData.Data[i].Key, GUILayout.Width(position.width * 0.2f)),
                                                                                                EditorGUILayout.TextArea(localizationMaster.DictionaryData.Data[i].Data));

                    var copyContent = new GUIContent("C", "Copy Entry");

                    if (GUILayout.Button(copyContent, GUILayout.Width(25)))
                    {
                        CopyPaste.Copy(localizationMaster.DictionaryData.Data[i]);
                    }

                    var pasteContent = new GUIContent("P", "Paste Entry");

                    if (GUILayout.Button(pasteContent, GUILayout.Width(25)))
                    {
                        localizationMaster.DictionaryData.Data[i] = CopyPaste.Paste <LocalizationDictionaryEntry>();
                    }

                    var deleteContent = new GUIContent("X", "Delete Entry");

                    if (GUILayout.Button(deleteContent, GUILayout.Width(25)))
                    {
                        localizationMaster.DictionaryData.Data.RemoveAt(i);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                if (GUILayout.Button("Add New Entry"))
                {
                    localizationMaster.DictionaryData.Data.Add(new LocalizationDictionaryEntry("newKey", "newData"));
                }
            }
        }
        else
        {
            GUILayout.Label("WARNING \n Localization Master NOT Found In Resources Folder.", EditorStyles.boldLabel);
            localizationMaster = Resources.Load(LocalizationMaster.DefaultLocation) as LocalizationMaster;
        }

        //groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
        //myBool = EditorGUILayout.Toggle("Toggle", myBool);
        //myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);
        //EditorGUILayout.EndToggleGroup();
    }
Exemplo n.º 26
0
    private void OnGUI()
    {
        GUILayout.Label("Base Setting", EditorStyles.boldLabel);

        savePath = EditorGUILayout.TextField("Save Path", savePath);

        EditorGUILayout.HelpBox("Use esta ventana para mezclar canales de texturas, ¿por qué hacerlo?: " +
                                "\n - sirve para ahorrar memoria" +
                                "\n - Use texturas en formato PNG" +
                                "\n - hace mas manejable el proyecto al usar menos texturas" +
                                "\n - Uselo en texturas en escala de grises" +
                                "\n - tamaño mayor o igual a 512", MessageType.Info);

        if (GUILayout.Button("ChR: " + channelRString))
        {
            channelRString = EditorUtility.OpenFilePanel("Open Channel R Texture", "", "png");
        }
        if (GUILayout.Button("ChG: " + channelGString))
        {
            channelGString = EditorUtility.OpenFilePanel("Open Channel G Texture", "", "png");
        }
        if (GUILayout.Button("ChB: " + channelBString))
        {
            channelBString = EditorUtility.OpenFilePanel("Open Channel B Texture", "", "png");
        }
        if (GUILayout.Button("ChA: " + channelAString))
        {
            channelAString = EditorUtility.OpenFilePanel("Open Channel A Texture", "", "png");
        }

        optionals    = (channelGString != "" || channelGString != "" || channelGString != "");
        groupEnabled = channelRString != "" && optionals && savePath != "";

        EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);

        sizes = (Sizes)EditorGUILayout.EnumPopup("Select Size", sizes);
        if (GUILayout.Button("Apply Combination"))
        {
            if (channelRString != "" && channelBString != "" && savePath != "")
            {
                List <byte[]> dataBytes = new List <byte[]>
                {
                    File.ReadAllBytes(channelRString),
                    File.ReadAllBytes(channelGString),
                    File.ReadAllBytes(channelBString),
                    File.ReadAllBytes(channelAString)
                };


                int size = 512;

                switch (sizes)
                {
                case Sizes.x512:
                    size = 512;
                    break;

                case Sizes.x1024:
                    size = 1024;
                    break;

                case Sizes.x2048:
                    size = 2048;
                    break;

                case Sizes.x4096:
                    size = 4096;
                    break;

                case Sizes.x8192:
                    size = 8192;
                    break;
                }
                TextureChannelCombinator.ApplyCombination(dataBytes, savePath, size);
            }
            else
            {
                Debug.LogWarning("Please fill data correctly");
            }
        }
    }
Exemplo n.º 27
0
    public override void OnInspectorGUI()
    {
        GameCamera2D _target = (GameCamera2D)target;

        EditorGUILayout.BeginVertical("Button");
        EditorGUILayout.LabelField("Horizontal movement", EditorStyles.boldLabel);

        _target.lockHorizontal = EditorGUILayout.Toggle("Lock?", _target.lockHorizontal);
        if (!_target.GetComponent <Camera>().orthographic || !_target.lockHorizontal)
        {
            _target.afterOffset.x = EditorGUILayout.FloatField("Offset:", _target.afterOffset.x);
        }

        if (!_target.lockHorizontal)
        {
            _target.freedom.x            = EditorGUILayout.FloatField("Track freedom:", _target.freedom.x);
            _target.directionInfluence.x = EditorGUILayout.FloatField("Target direction fac.:", _target.directionInfluence.x);
            _target.limitHorizontal      = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitHorizontal);

            EditorGUILayout.BeginVertical("Button");
            _target.constrainHorizontal[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainHorizontal[0]);
            _target.constrainHorizontal[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainHorizontal[1]);
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndToggleGroup();
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("Button");
        EditorGUILayout.LabelField("Vertical movement", EditorStyles.boldLabel);

        _target.lockVertical = EditorGUILayout.Toggle("Lock?", _target.lockVertical);
        if (!_target.GetComponent <Camera>().orthographic || !_target.lockVertical)
        {
            _target.afterOffset.y = EditorGUILayout.FloatField("Offset:", _target.afterOffset.y);
        }

        if (!_target.lockVertical)
        {
            _target.freedom.y            = EditorGUILayout.FloatField("Track freedom:", _target.freedom.y);
            _target.directionInfluence.y = EditorGUILayout.FloatField("Target direction fac.:", _target.directionInfluence.y);
            _target.limitVertical        = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitVertical);

            EditorGUILayout.BeginVertical("Button");
            _target.constrainVertical[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainVertical[0]);
            _target.constrainVertical[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainVertical[1]);
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndToggleGroup();
        }
        EditorGUILayout.EndVertical();

        if (!_target.lockHorizontal || !_target.lockVertical)
        {
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Target object to control camera movement", EditorStyles.boldLabel);

            _target.targetIsPlayer = EditorGUILayout.Toggle("Target is player?", _target.targetIsPlayer);

            if (!_target.targetIsPlayer)
            {
                _target.target = (Transform)EditorGUILayout.ObjectField("Target:", _target.target, typeof(Transform), true);
            }

            _target.dampSpeed = EditorGUILayout.FloatField("Follow speed", _target.dampSpeed);
            EditorGUILayout.EndVertical();
        }

        if (!_target.IsCorrectRotation())
        {
            if (GUILayout.Button("Set correct rotation"))
            {
                Undo.RecordObject(_target, "Clear " + _target.name + " rotation");
                _target.SetCorrectRotation();
            }
        }

        if (!Application.isPlaying)
        {
            _target.GetComponent <Camera>().ResetProjectionMatrix();
            if (!_target.GetComponent <Camera>().orthographic)
            {
                _target.SetCameraComponent();
                _target.SnapToOffset();
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(_target);
        }
    }
    private void OnGUI()
    {
        #region ScrollView
        scrollPosition = GUILayout.BeginScrollView(scrollPosition);
        GUILayout.Space(space);

        if (GUILayout.Button("Create new level", GUILayout.Height(buttonHeight), GUILayout.Width(buttonWidth)))
        {
            newSceneIndex = FindAppropriateIndex();

            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                // Create new scene
                EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);

                // Add new scene to build settings
                AddNewSceneToBuildSetting(newSceneIndex);

                // Add prefabs to new scene
                AddPrefabsToNewScene();

                // Add background to new scene
                AddBackgroundToNewScene();

                // Save scene after adding everything
                SaveScene();
            }
            return;
        }

        GUILayout.Space(space);

        GUILayout.BeginHorizontal();
        GUILayout.Label("Frame type", GUILayout.Width(labelWidth));
        // Popup (it's a dropdown)
        popupIndex = EditorGUILayout.Popup(popupIndex, levelEditorSO.frameType, GUILayout.Height(dropdownHeight), GUILayout.Width(dropdownWidth));
        GUILayout.EndHorizontal();

        GUILayout.Space(space);

        GUILayout.BeginHorizontal();
        GUILayout.Label("Scene Folder", GUILayout.Width(labelWidth));
        GUI.SetNextControlName("dropdownFolderName");
        folderIndex = EditorGUILayout.Popup(folderIndex, levelEditorSO.sceneFolderName, GUILayout.Height(dropdownHeight), GUILayout.Width(dropdownWidth));
        GUILayout.EndHorizontal();

        GUI.enabled = true;

        #region Edit existing level


        #region Textfield && Arrows
        EditorGUILayout.BeginHorizontal();
        GUIStyle gUIStyleButton = new GUIStyle(GUI.skin.button);
        gUIStyleButton.fontSize = 20;

        // Left arrow
        if (GUILayout.Button("↤", gUIStyleButton, GUILayout.Height(buttonHeight), GUILayout.Width(50)))
        {
            int newNumber = (int.Parse(textFieldNumber) - 1);
            if (newNumber >= 1)
            {
                textFieldNumber = newNumber.ToString();
                //ShowYesNoPopup();
                ChangeImage();
                GUI.FocusControl("dropdownFolderName");
            }
        }

        // Textfield
        GUIStyle gUIStyle = new GUIStyle(GUI.skin.textField);
        gUIStyle.alignment = TextAnchor.MiddleLeft;
        textFieldNumber    = EditorGUILayout.TextField(textFieldNumber, gUIStyle, GUILayout.Height(buttonHeight), GUILayout.Width(100));

        // Right arrow
        if (GUILayout.Button("↦", gUIStyleButton, GUILayout.Height(buttonHeight), GUILayout.Width(50)))
        {
            int newNumber = (int.Parse(textFieldNumber) + 1);
            textFieldNumber = newNumber.ToString();
            //ShowYesNoPopup();
            ChangeImage();
            GUI.FocusControl("dropdownFolderName");
        }
        EditorGUILayout.EndHorizontal();
        #endregion

        GUILayout.Space(space / 2);


        if (GUILayout.Button($"Open Level {textFieldNumber}", GUILayout.Height(buttonHeight), GUILayout.Width(buttonWidth)))
        {
            if (int.TryParse(textFieldNumber, out int i))
            {
                ShowUnSavePopup();
                ChangeImage();
            }
        }
        deleteScene = EditorGUILayout.BeginToggleGroup("Delete current scene", deleteScene);
        GUILayout.Space(space / 2);
        if (GUILayout.Button("Delete", GUILayout.Height(buttonHeight), GUILayout.Width(buttonWidth)))
        {
            string sceneName = EditorSceneManager.GetActiveScene().name;
            string filePath  = $"Assets/_Main/_Scenes/{levelEditorSO.sceneFolderName[folderIndex]}/{sceneName}.unity";
            if (File.Exists(filePath))
            {
                if (EditorUtility.DisplayDialog($"Delete Level{textFieldNumber} scene", $"Do you want to delete {sceneName} scene?", "Yes", "No"))
                {
                    File.Delete(filePath);
#if UNITY_EDITOR
                    AssetDatabase.Refresh();
                    UpdateSceneAmountInScriptableObject(false);
#endif

                    EditorBuildSettingsScene[] originalSettingScenes = EditorBuildSettings.scenes;
                    EditorBuildSettingsScene   sceneToRemove         = new EditorBuildSettingsScene($"Assets/_Main/_Scenes/{levelEditorSO.sceneFolderName[folderIndex]}/{sceneName}.unity", true);
                    EditorBuildSettingsScene[] newSettings           = new EditorBuildSettingsScene[originalSettingScenes.Length - 1];
                    for (int i = 0, j = 0; i < originalSettingScenes.Length; i++)
                    {
                        if (originalSettingScenes[i].path != sceneToRemove.path)
                        {
                            newSettings[j++] = originalSettingScenes[i];
                        }
                    }
                    EditorBuildSettings.scenes = newSettings;

                    EditorSceneManager.OpenScene(EditorBuildSettings.scenes[EditorBuildSettings.scenes.Length - 1].path);

                    EditorUtility.DisplayDialog("Message", $"{sceneName} has been deleted from project folder and build settings", "OK");
                }
            }
            else
            {
                EditorUtility.DisplayDialog("File not found", $"Can not find IntroScene in folder {filePath}", "OK");
            }
        }
        EditorGUILayout.EndToggleGroup();
        #endregion

        #region Intro, Menu, Menu Select Scene
        int minus = 30;
        GUILayout.Space(space);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button($"Open {levelEditorSO.sceneFolderName[folderIndex]} Select Level", GUILayout.Width(buttonWidth - minus), GUILayout.Height(buttonHeight)))
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                try
                {
                    EditorSceneManager.OpenScene($"Assets/_Main/_Scenes/{levelEditorSO.sceneFolderName[folderIndex]}/MenuSelectLevel{folderIndex + 1}.unity");
                }
                catch (Exception)
                {
                    EditorUtility.DisplayDialog("File not found", $"Can not find MenuSelectLevel{folderIndex + 1} in folder Assets/_Main/_Scenes/{levelEditorSO.sceneFolderName[folderIndex]}", "OK");
                }
            }
        }

        if (GUILayout.Button("Open Intro Scene", GUILayout.Width(buttonWidth - minus), GUILayout.Height(buttonHeight)))
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                try
                {
                    EditorSceneManager.OpenScene("Assets/_Main/_Scenes/IntroScene.unity");
                }
                catch (Exception)
                {
                    EditorUtility.DisplayDialog("File not found", "Can not find IntroScene in folder Assets/_Main/_Scenes/", "OK");
                }
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(space);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Open Menu Scene", GUILayout.Width(buttonWidth - minus), GUILayout.Height(buttonHeight)))
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                try
                {
                    EditorSceneManager.OpenScene("Assets/_Main/_Scenes/MenuScene.unity");
                }
                catch (Exception)
                {
                    EditorUtility.DisplayDialog("File not found", "Can not find MenuScene in folder Assets/_Main/_Scenes/", "OK");
                }
            }
        }

        if (GUILayout.Button("Open Menu Select Episode", GUILayout.Width(buttonWidth - minus), GUILayout.Height(buttonHeight)))
        {
            if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                try
                {
                    EditorSceneManager.OpenScene("Assets/_Main/_Scenes/MenuSelectEpisode.unity");
                }
                catch (Exception)
                {
                    EditorUtility.DisplayDialog("File not found", "Can not find MenuSelectEpisode in folder Assets/_Main/_Scenes/", "OK");
                }
            }
        }
        GUILayout.EndHorizontal();
        #endregion

        #region Scene Image
        GUI.enabled = true;
        GUILayout.Space(space / 2);
        if (!imageExist)
        {
            GUILayout.Label("Image does not exists in folder");
        }
        else
        {
            GUILayout.Label(imageOfLevel, GUILayout.Width(Screen.width - 25));
        }
        #endregion

        GUILayout.EndScrollView();
        #endregion end ScrollView
    }
    protected override void OnBaseInspectorGUI()
    {
        // update serialized object
        serializedObject.Update();

        // cache serialized properties
        SerializedProperty _pPlayerCamera      = serializedObject.FindProperty("PlayerCamera");
        SerializedProperty _pPlayerController  = serializedObject.FindProperty("PlayerController");
        SerializedProperty _pRotationReference = serializedObject.FindProperty("RotationReference");
        SerializedProperty _pUpdateMode        = serializedObject.FindProperty("UpdateMode");

        SerializedProperty _pUseRadar              = serializedObject.FindProperty("useRadar");
        SerializedProperty _pRadarMode             = serializedObject.FindProperty("radarMode");
        SerializedProperty _pRadarZoom             = serializedObject.FindProperty("radarZoom");
        SerializedProperty _pRadarRadius           = serializedObject.FindProperty("radarRadius");
        SerializedProperty _pRadarMaxRadius        = serializedObject.FindProperty("radarMaxRadius");
        SerializedProperty _pUseRadarHeightSystem  = serializedObject.FindProperty("useRadarHeightSystem");
        SerializedProperty _pRadarDistanceAbove    = serializedObject.FindProperty("radarDistanceAbove");
        SerializedProperty _pRadarDistanceBelow    = serializedObject.FindProperty("radarDistanceBelow");
        SerializedProperty _pShowRadarHeightGizmos = serializedObject.FindProperty("showRadarHeightGizmos");
        SerializedProperty _pRadarHeightGizmoSize  = serializedObject.FindProperty("radarHeightGizmoSize");
        SerializedProperty _pRadarHeightGizmoColor = serializedObject.FindProperty("radarHeightGizmoColor");

        SerializedProperty _pUseCompassBar    = serializedObject.FindProperty("useCompassBar");
        SerializedProperty _pCompassBarRadius = serializedObject.FindProperty("compassBarRadius");

        SerializedProperty _pUseIndicators            = serializedObject.FindProperty("useIndicators");
        SerializedProperty _pIndicatorRadius          = serializedObject.FindProperty("indicatorRadius");
        SerializedProperty _pIndicatorHideDistance    = serializedObject.FindProperty("indicatorHideDistance");
        SerializedProperty _pUseOffscreenIndicators   = serializedObject.FindProperty("useOffscreenIndicators");
        SerializedProperty _pIndicatorOffscreenBorder = serializedObject.FindProperty("indicatorOffscreenBorder");
        SerializedProperty _pUseIndicatorScaling      = serializedObject.FindProperty("useIndicatorScaling");
        SerializedProperty _pIndicatorScaleRadius     = serializedObject.FindProperty("indicatorScaleRadius");
        SerializedProperty _pIndicatorMinScale        = serializedObject.FindProperty("indicatorMinScale");
        SerializedProperty _pUseIndicatorFading       = serializedObject.FindProperty("useIndicatorFading");
        SerializedProperty _pIndicatorFadeRadius      = serializedObject.FindProperty("indicatorFadeRadius");
        SerializedProperty _pIndicatorMinFade         = serializedObject.FindProperty("indicatorMinFade");

        SerializedProperty _pUseMinimap              = serializedObject.FindProperty("useMinimap");
        SerializedProperty _pMinimapProfile          = serializedObject.FindProperty("minimapProfile");
        SerializedProperty _pMinimapMode             = serializedObject.FindProperty("minimapMode");
        SerializedProperty _pMinimapScale            = serializedObject.FindProperty("minimapScale");
        SerializedProperty _pMinimapRadius           = serializedObject.FindProperty("minimapRadius");
        SerializedProperty _pShowMinimapBounds       = serializedObject.FindProperty("showMinimapBounds");
        SerializedProperty _pMinimapBoundsGizmoColor = serializedObject.FindProperty("minimapBoundsGizmoColor");
        SerializedProperty _pUseMinimapHeightSystem  = serializedObject.FindProperty("useMinimapHeightSystem");
        SerializedProperty _pMinimapDistanceAbove    = serializedObject.FindProperty("minimapDistanceAbove");
        SerializedProperty _pMinimapDistanceBelow    = serializedObject.FindProperty("minimapDistanceBelow");
        SerializedProperty _pShowMinimapHeightGizmos = serializedObject.FindProperty("showMinimapHeightGizmos");
        SerializedProperty _pMinimapHeightGizmoSize  = serializedObject.FindProperty("minimapHeightGizmoSize");
        SerializedProperty _pMinimapHeightGizmoColor = serializedObject.FindProperty("minimapHeightGizmoColor");

        // REFERENCES
        EditorGUILayout.BeginVertical();
        EditorGUILayout.PropertyField(_pPlayerCamera);
        EditorGUILayout.PropertyField(_pPlayerController);
        GUILayout.Space(8);          // SPACE
        EditorGUILayout.PropertyField(_pRotationReference, new GUIContent("Rotation Reference", "The transform you want to use as rotation reference."));
        EditorGUILayout.PropertyField(_pUpdateMode, new GUIContent("Update Mode", "Change, if indicators are not positioned correctly on fast character/camera movements."));
        EditorGUILayout.EndVertical();

        // FEATURES
        GUILayout.Space(8);          // SPACE
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(_pUseRadar, new GUIContent("Radar Feature"));
        EditorGUILayout.LabelField((hudTarget.useRadar) ? "ENABLED" : "DISABLED", (hudTarget.useRadar) ? enabledStyle : disabledStyle, GUILayout.Width(100));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(_pUseCompassBar, new GUIContent("Compass Bar Feature"));
        EditorGUILayout.LabelField((hudTarget.useCompassBar) ? "ENABLED" : "DISABLED", (hudTarget.useCompassBar) ? enabledStyle : disabledStyle, GUILayout.Width(100));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(_pUseIndicators, new GUIContent("Indicator Feature"));
        EditorGUILayout.LabelField((hudTarget.useIndicators) ? "ENABLED" : "DISABLED", (hudTarget.useIndicators) ? enabledStyle : disabledStyle, GUILayout.Width(100));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(_pUseMinimap, new GUIContent("Minimap Feature"));
        EditorGUILayout.LabelField((hudTarget.useMinimap) ? "ENABLED" : "DISABLED", (hudTarget.useMinimap) ? enabledStyle : disabledStyle, GUILayout.Width(100));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(8);          // SPACE

        // RADAR SETTINGS
        if (hudTarget.useRadar)
        {
            EditorGUILayout.BeginVertical(boxStyle);
            _radar_ = EditorGUILayout.BeginToggleGroup("Radar Settings", _radar_);
            if (_radar_)
            {
                GUILayout.Space(4);                  // SPACE
                // CONTENT BEGIN
                EditorGUILayout.PropertyField(_pRadarMode);
                EditorGUILayout.Slider(_pRadarZoom, .1f, 5f, "Radar Zoom");
                EditorGUILayout.Slider(_pRadarRadius, 1f, 500f, "Radar Radius");
                EditorGUILayout.Slider(_pRadarMaxRadius, 1f, 500f, "Radar Radius (Border)");
                if (_pRadarMaxRadius.floatValue < _pRadarRadius.floatValue)
                {
                    _pRadarMaxRadius.floatValue = _pRadarRadius.floatValue;
                }

                // height system settings
                GUILayout.Space(4);                  // SPACE
                EditorGUILayout.BeginVertical(boxStyle);
                _pUseRadarHeightSystem.boolValue = EditorGUILayout.ToggleLeft("Enable Height System", _pUseRadarHeightSystem.boolValue, subHeaderStyle);
                if (hudTarget.useRadarHeightSystem)
                {
                    GUILayout.Space(4);                      // SPACE
                    EditorGUILayout.Slider(_pRadarDistanceAbove, 1f, 100f, new GUIContent("Min. Distance Above"));
                    EditorGUILayout.Slider(_pRadarDistanceBelow, 1f, 100f, new GUIContent("Min. Distance Below"));
                    EditorGUILayout.PropertyField(_pShowRadarHeightGizmos, new GUIContent("Show Debug Gizmos"));
                    if (hudTarget.showRadarHeightGizmos)
                    {
                        EditorGUILayout.PropertyField(_pRadarHeightGizmoSize, new GUIContent("> Gizmo Size"));
                        EditorGUILayout.PropertyField(_pRadarHeightGizmoColor, new GUIContent("> Gizmo Color"));
                    }
                }
                EditorGUILayout.EndVertical();
                // CONTENT ENDOF
            }
            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.EndVertical();
        }

        // COMPASS BAR SETTINGS
        if (hudTarget.useCompassBar)
        {
            EditorGUILayout.BeginVertical(boxStyle);
            _compassBar_ = EditorGUILayout.BeginToggleGroup("Compass Bar Settings", _compassBar_);
            if (_compassBar_)
            {
                GUILayout.Space(4);                  // SPACE
                // CONTENT BEGIN
                EditorGUILayout.Slider(_pCompassBarRadius, 1f, 500f, "Compass Bar Radius");
                // CONTENT ENDOF
            }
            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.EndVertical();
        }

        // INDICATOR SETTINGS
        if (hudTarget.useIndicators)
        {
            EditorGUILayout.BeginVertical(boxStyle);
            _indicator_ = EditorGUILayout.BeginToggleGroup("Indicator Settings", _indicator_);
            if (_indicator_)
            {
                GUILayout.Space(4);                  // SPACE
                // CONTENT BEGIN
                EditorGUILayout.Slider(_pIndicatorRadius, 1f, 500f, "Indicator Radius");
                EditorGUILayout.Slider(_pIndicatorHideDistance, 0f, 50f, "Indicator Hide Distance");

                // off-screen indicator settings
                GUILayout.Space(4);                  // SPACE
                EditorGUILayout.BeginVertical(boxStyle);
                _pUseOffscreenIndicators.boolValue = EditorGUILayout.ToggleLeft("Enable Offscreen Indicators", _pUseOffscreenIndicators.boolValue, subHeaderStyle);
                if (hudTarget.useOffscreenIndicators)
                {
                    GUILayout.Space(4);                      // SPACE
                    EditorGUILayout.Slider(_pIndicatorOffscreenBorder, 0f, 1f, "Screen Border");
                }
                EditorGUILayout.EndVertical();

                // indicator scaling settings
                GUILayout.Space(4);                  // SPACE
                EditorGUILayout.BeginVertical(boxStyle);
                _pUseIndicatorScaling.boolValue = EditorGUILayout.ToggleLeft("Enable Distance Scaling", _pUseIndicatorScaling.boolValue, subHeaderStyle);
                if (hudTarget.useIndicatorScaling)
                {
                    GUILayout.Space(4);                      // SPACE
                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.Slider(_pIndicatorScaleRadius, 1f, 500f, "Scale Radius");
                    if (hudTarget.indicatorScaleRadius > hudTarget.indicatorRadius)
                    {
                        hudTarget.indicatorScaleRadius = hudTarget.indicatorRadius;
                    }
                    EditorGUILayout.Slider(_pIndicatorMinScale, .1f, 1f, "Minimum Scale");
                    if (showHelpboxes)
                    {
                        EditorGUILayout.HelpBox("Indicator will be scaled by distance within the defined radius.", MessageType.Info);
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();

                // indicator fading settings
                GUILayout.Space(4);                  // SPACE
                EditorGUILayout.BeginVertical(boxStyle);
                _pUseIndicatorFading.boolValue = EditorGUILayout.ToggleLeft("Enable Distance Fading", _pUseIndicatorFading.boolValue, subHeaderStyle);
                if (hudTarget.useIndicatorFading)
                {
                    GUILayout.Space(4);                      // SPACE
                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.Slider(_pIndicatorFadeRadius, 1f, 500f, "Fade Radius");
                    if (hudTarget.indicatorFadeRadius > hudTarget.indicatorRadius)
                    {
                        hudTarget.indicatorFadeRadius = hudTarget.indicatorRadius;
                    }
                    EditorGUILayout.Slider(_pIndicatorMinFade, 0f, 1f, "Minimum Opacity");
                    if (showHelpboxes)
                    {
                        EditorGUILayout.HelpBox("Indicator will be faded by distance within the defined radius.", MessageType.Info);
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
                // CONTENT ENDOF
            }
            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.EndVertical();
        }

        // MINIMAP SETTINGS
        if (hudTarget.useMinimap)
        {
            EditorGUILayout.BeginVertical(boxStyle);
            _minimap_ = EditorGUILayout.BeginToggleGroup("Minimap Settings", _minimap_);
            if (_minimap_)
            {
                GUILayout.Space(4);                  // SPACE
                // CONTENT BEGIN
                EditorGUILayout.PropertyField(_pMinimapProfile, new GUIContent("Minimap Profile"));
                if (hudTarget.minimapProfile != null)
                {
                    EditorGUILayout.PropertyField(_pMinimapMode);
                    EditorGUILayout.Slider(_pMinimapScale, .01f, 1f, "Minimap Scale");
                    EditorGUILayout.Slider(_pMinimapRadius, 1f, 500f, "Minimap Radius");
                    EditorGUILayout.PropertyField(_pShowMinimapBounds, new GUIContent("Show Minimap Bounds"));
                    if (hudTarget.showMinimapBounds)
                    {
                        EditorGUILayout.PropertyField(_pMinimapBoundsGizmoColor, new GUIContent("> Gizmo Color"));
                    }

                    // height system settings
                    GUILayout.Space(4);                      // SPACE
                    EditorGUILayout.BeginVertical(boxStyle);
                    _pUseMinimapHeightSystem.boolValue = EditorGUILayout.ToggleLeft("Enable Height System", _pUseMinimapHeightSystem.boolValue, subHeaderStyle);
                    if (hudTarget.useMinimapHeightSystem)
                    {
                        GUILayout.Space(4);                          // SPACE
                        EditorGUILayout.Slider(_pMinimapDistanceAbove, 1f, 100f, new GUIContent("Min. Distance Above"));
                        EditorGUILayout.Slider(_pMinimapDistanceBelow, 1f, 100f, new GUIContent("Min. Distance Below"));
                        EditorGUILayout.PropertyField(_pShowMinimapHeightGizmos, new GUIContent("Show Debug Gizmos"));
                        if (hudTarget.showMinimapHeightGizmos)
                        {
                            EditorGUILayout.PropertyField(_pMinimapHeightGizmoSize, new GUIContent("> Gizmo Size"));
                            EditorGUILayout.PropertyField(_pMinimapHeightGizmoColor, new GUIContent("> Gizmo Color"));
                        }
                    }
                    EditorGUILayout.EndVertical();
                }

                GUILayout.Space(4);                  // SPACE

                if (hudTarget.minimapProfile == null)
                {
                    // create profile button
                    if (GUILayout.Button("Create New Profile", GUILayout.Height(20)))
                    {
                        GameObject textureCreatorGO = new GameObject("HNS TextureCreator");
                        textureCreatorGO.transform.position = Vector3.zero;
                        textureCreatorGO.AddComponent <HNSTextureCreator> ();
                        Selection.activeGameObject = textureCreatorGO;
                    }
                }
                // CONTENT ENDOF
            }
            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.EndVertical();
        }

        // show/hide expand button
        showExpandButton = hudTarget.useRadar || hudTarget.useCompassBar || hudTarget.useIndicators || hudTarget.useMinimap;

        // apply modified properties
        serializedObject.ApplyModifiedProperties();
    }
    private void ColorChange(string inspector, string keyword)
    {
        bool toggle = oldKeyWords.Contains(keyword);
        bool ini    = toggle;

        GUIContent effectNameLabel = new GUIContent();

        effectNameLabel.tooltip = keyword + " (C#)";
        effectNameLabel.text    = effectCount + "." + inspector;
        toggle = EditorGUILayout.BeginToggleGroup(effectNameLabel, toggle);

        effectCount++;
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("CHANGECOLOR_ON");
            EditorGUILayout.BeginVertical(style);
            {
                for (int i = 123; i < 127; i++)
                {
                    DrawProperty(i);
                }

                EditorGUILayout.Separator();
                ini = oldKeyWords.Contains("CHANGECOLOR2_ON");
                bool toggle2 = ini;
                toggle2 = EditorGUILayout.Toggle("Use Color 2", ini);
                if (ini != toggle2 && !Application.isPlaying)
                {
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                }
                if (toggle2)
                {
                    targetMat.EnableKeyword("CHANGECOLOR2_ON");
                    for (int i = 146; i < 149; i++)
                    {
                        DrawProperty(i);
                    }
                }
                else
                {
                    targetMat.DisableKeyword("CHANGECOLOR2_ON");
                }

                EditorGUILayout.Separator();
                ini     = oldKeyWords.Contains("CHANGECOLOR3_ON");
                toggle2 = ini;
                toggle2 = EditorGUILayout.Toggle("Use Color 3", toggle2);
                if (ini != toggle2 && !Application.isPlaying)
                {
                    EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                }
                if (toggle2)
                {
                    targetMat.EnableKeyword("CHANGECOLOR3_ON");
                    for (int i = 149; i < 152; i++)
                    {
                        DrawProperty(i);
                    }
                }
                else
                {
                    targetMat.DisableKeyword("CHANGECOLOR3_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("CHANGECOLOR_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }