public override void OnInspectorGUI()
        {
            SetAnimBools(false);

            serializedObject.Update();
            // Once we have a reliable way to know if the object changed, only re-cache in that case.
            CalculateCachedValues();

            EditorGUILayout.PropertyField(m_Content);

            EditorGUILayout.PropertyField(m_Horizontal);
            EditorGUILayout.PropertyField(m_Vertical);

            EditorGUILayout.PropertyField(m_MovementType);
            if (EditorGUILayout.BeginFadeGroup(m_ShowElasticity.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_Elasticity);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.PropertyField(m_Inertia);
            if (EditorGUILayout.BeginFadeGroup(m_ShowDecelerationRate.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_DecelerationRate);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.PropertyField(m_ScrollSensitivity);

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(m_Viewport);

            EditorGUILayout.PropertyField(m_HorizontalScrollbar);
            if (m_HorizontalScrollbar.objectReferenceValue && !m_HorizontalScrollbar.hasMultipleDifferentValues)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_HorizontalScrollbarVisibility, EditorGUIUtility.TrTextContent("Visibility"));

                if ((ScrollRect.ScrollbarVisibility)m_HorizontalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport &&
                    !m_HorizontalScrollbarVisibility.hasMultipleDifferentValues)
                {
                    if (m_ViewportIsNotChild || m_HScrollbarIsNotChild)
                    {
                        EditorGUILayout.HelpBox(s_HError, MessageType.Error);
                    }
                    EditorGUILayout.PropertyField(m_HorizontalScrollbarSpacing, EditorGUIUtility.TrTextContent("Spacing"));
                }

                EditorGUI.indentLevel--;
            }

            EditorGUILayout.PropertyField(m_VerticalScrollbar);
            if (m_VerticalScrollbar.objectReferenceValue && !m_VerticalScrollbar.hasMultipleDifferentValues)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_VerticalScrollbarVisibility, EditorGUIUtility.TrTextContent("Visibility"));

                if ((ScrollRect.ScrollbarVisibility)m_VerticalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport &&
                    !m_VerticalScrollbarVisibility.hasMultipleDifferentValues)
                {
                    if (m_ViewportIsNotChild || m_VScrollbarIsNotChild)
                    {
                        EditorGUILayout.HelpBox(s_VError, MessageType.Error);
                    }
                    EditorGUILayout.PropertyField(m_VerticalScrollbarSpacing, EditorGUIUtility.TrTextContent("Spacing"));
                }

                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(m_OnValueChanged);

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

        EditorGUILayout.PropertyField(m_InteractableProperty);

        var trans = GetTransition(m_TransitionProperty);

        var graphic = m_TargetGraphicProperty.objectReferenceValue as Graphic;

        if (graphic == null)
        {
            graphic = (target as Unselectable).GetComponent <Graphic>();
        }

        var animator = (target as Unselectable).GetComponent <Animator>();

        m_ShowColorTint.target       = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Unselectable.Transition.ColorTint);
        m_ShowSpriteTrasition.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Unselectable.Transition.SpriteSwap);
        m_ShowAnimTransition.target  = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Unselectable.Transition.Animation);

        EditorGUILayout.PropertyField(m_TransitionProperty);

        ++EditorGUI.indentLevel;
        {
            if (trans == Unselectable.Transition.ColorTint || trans == Unselectable.Transition.SpriteSwap)
            {
                EditorGUILayout.PropertyField(m_TargetGraphicProperty);
            }

            switch (trans)
            {
            case Unselectable.Transition.ColorTint:
                if (graphic == null)
                {
                    EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning);
                }
                break;

            case Unselectable.Transition.SpriteSwap:
                if (graphic as Image == null)
                {
                    EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Warning);
                }
                break;
            }

            if (EditorGUILayout.BeginFadeGroup(m_ShowColorTint.faded))
            {
                EditorGUILayout.PropertyField(m_ColorBlockProperty);
            }
            EditorGUILayout.EndFadeGroup();

            if (EditorGUILayout.BeginFadeGroup(m_ShowSpriteTrasition.faded))
            {
                EditorGUILayout.PropertyField(m_SpriteStateProperty);
            }
            EditorGUILayout.EndFadeGroup();

            if (EditorGUILayout.BeginFadeGroup(m_ShowAnimTransition.faded))
            {
                EditorGUILayout.PropertyField(m_AnimTriggerProperty);

                if (animator == null || animator.runtimeAnimatorController == null)
                {
                    Rect buttonRect = EditorGUILayout.GetControlRect();
                    buttonRect.xMin += EditorGUIUtility.labelWidth;
                    if (GUI.Button(buttonRect, "Auto Generate Animation", EditorStyles.miniButton))
                    {
                        var controller = GenerateSelectableAnimatorContoller((target as Unselectable).animationTriggers, target as Unselectable);
                        if (controller != null)
                        {
                            if (animator == null)
                            {
                                animator = (target as Unselectable).gameObject.AddComponent <Animator>();
                            }

                            // Animations.AnimatorController.SetAnimatorController(animator, controller);
                        }
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();
        }
        --EditorGUI.indentLevel;

        EditorGUILayout.Space();


        EditorGUI.BeginChangeCheck();
        Rect toggleRect = EditorGUILayout.GetControlRect();

        toggleRect.xMin += EditorGUIUtility.labelWidth;
        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }

        // We do this here to avoid requiring the user to also write a Editor for their Unselectable-derived classes.
        // This way if we are on a derived class we dont draw anything else, otherwise draw the remaining properties.
        ChildClassPropertiesGUI();

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

            UpdateAnimBoolTargets();

            EditorGUILayout.LabelField("Simulates camera lens defocus", EditorStyles.miniLabel);

            GUILayout.Label("Focal Settings");
            EditorGUILayout.PropertyField(visualizeFocus, new GUIContent(" Visualize"));
            EditorGUILayout.PropertyField(focalTransform, new GUIContent(" Focus on Transform"));

            if (EditorGUILayout.BeginFadeGroup(showFocalDistance.faded))
            {
                EditorGUILayout.PropertyField(focalLength, new GUIContent(" Focal Distance"));
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.Slider(focalSize, 0.0f, 2.0f, new GUIContent(" Focal Size"));
            EditorGUILayout.Slider(aperture, 0.0f, 1.0f, new GUIContent(" Aperture"));

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(blurType, new GUIContent("Defocus Type"));

            if (!(target as DepthOfField).Dx11Support() && blurType.enumValueIndex > 0)
            {
                EditorGUILayout.HelpBox("DX11 mode not supported (need shader model 5)", MessageType.Info);
            }

            if (EditorGUILayout.BeginFadeGroup(showDiscBlurSettings.faded))
            {
                EditorGUILayout.PropertyField(blurSampleCount, new GUIContent(" Sample Count"));
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.Slider(maxBlurSize, 0.1f, 2.0f, new GUIContent(" Max Blur Distance"));
            EditorGUILayout.PropertyField(highResolution, new GUIContent(" High Resolution"));

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(nearBlur, new GUIContent("Near Blur"));
            if (EditorGUILayout.BeginFadeGroup(showNearBlurOverlapSize.faded))
            {
                EditorGUILayout.Slider(foregroundOverlap, 0.1f, 2.0f, new GUIContent("  Overlap Size"));
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.Separator();

            if (EditorGUILayout.BeginFadeGroup(showDX11BlurSettings.faded))
            {
                GUILayout.Label("DX11 Bokeh Settings");
                EditorGUILayout.PropertyField(dx11BokehTexture, new GUIContent(" Bokeh Texture"));
                EditorGUILayout.Slider(dx11BokehScale, 0.0f, 50.0f, new GUIContent(" Bokeh Scale"));
                EditorGUILayout.Slider(dx11BokehIntensity, 0.0f, 100.0f, new GUIContent(" Bokeh Intensity"));
                EditorGUILayout.Slider(dx11BokehThreshold, 0.0f, 1.0f, new GUIContent(" Min Luminance"));
                EditorGUILayout.Slider(dx11SpawnHeuristic, 0.01f, 1.0f, new GUIContent(" Spawn Heuristic"));
            }
            EditorGUILayout.EndFadeGroup();

            serObj.ApplyModifiedProperties();
        }
Beispiel #4
0
    /*
     * For more information on the OnInspectorGUI and adding your own variables
     * in the UltimateStatusBarController.cs script and displaying them in this script,
     * see the EditorGUILayout section in the Unity Documentation to help out.
     */
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        UltimateStatusBarController usbController = ( UltimateStatusBarController )target;

        EditorGUILayout.Space();

        #region ASSIGNED VARIABLES
        /* ---------------------------------------- > ASSIGNED VARIABLES < ---------------------------------------- */
        DisplayHeader("Assigned Variables", "UUI_Variables", AssignedVariables);
        if (EditorGUILayout.BeginFadeGroup(AssignedVariables.faded))
        {
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(statusBarText, new GUIContent("Status Bar Text", "The main text of the status bar. Commonly showing the name or function."));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            if (usbController.statusBarText == null)
            {
                EditorGUILayout.HelpBox("Status Bar Name variable needs to be assigned in order for the UpdateStatusBarName() function to work.", MessageType.Warning);
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                statusBarName = EditorGUILayout.TextField("Status Bar Name", statusBarName);
                if (EditorGUI.EndChangeCheck())
                {
                    usbController.statusBarText.enabled = false;
                    usbController.UpdateStatusBarName(statusBarName);
                    usbController.statusBarText.enabled = true;
                }
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(statusBarIcon, new GUIContent("Status Bar Icon", "The icon of the status bar."));
            if (usbController.statusBarIcon == null)
            {
                EditorGUILayout.HelpBox("Status Bar Icon variable needs to be assigned in order for the UpdateStatusBarIcon() function to work.", MessageType.Warning);
            }
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* -------------------------------------- > END ASSIGNED VARIABLES < -------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region SIZE AND PLACEMENT
        /* ---------------------------------------- > SIZE AND PLACEMENT < ---------------------------------------- */
        DisplayHeader("Size and Placement", "UUI_SizeAndPlacement", SizeAndPlacement);
        if (EditorGUILayout.BeginFadeGroup(SizeAndPlacement.faded))
        {
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(positioningOption, new GUIContent("Positioning"));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();

                PosOpScreenSpace.target = usbController.positioningOption == UltimateStatusBarController.PositioningOption.ScreenSpace ? true : false;
                PosOpFollowCam.target   = usbController.positioningOption == UltimateStatusBarController.PositioningOption.FollowCameraRotation ? true : false;
                PosOpDisabled.target    = usbController.positioningOption == UltimateStatusBarController.PositioningOption.Disabled ? true : false;
            }

            if (EditorGUILayout.BeginFadeGroup(PosOpScreenSpace.faded))
            {
                if (CanvasErrors() == true)
                {
                    if (parentCanvas.renderMode != RenderMode.ScreenSpaceOverlay)
                    {
                        EditorGUILayout.LabelField("Canvas", EditorStyles.boldLabel);
                        EditorGUILayout.HelpBox("The parent Canvas needs to be set to 'Screen Space - Overlay' in order for the Ultimate Status Bar to function correctly.", MessageType.Error);
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Space(5);
                        if (GUILayout.Button("Update Canvas"))
                        {
                            parentCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
                        }
                        GUILayout.Space(5);
                        if (GUILayout.Button("Update Status Bar"))
                        {
                            UltimateStatusBarCreator.RequestCanvas(Selection.activeGameObject);
                            parentCanvas = GetParentCanvas();
                        }
                        GUILayout.Space(5);
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.Space();
                    }
                    if (parentCanvas.GetComponent <CanvasScaler>())
                    {
                        if (parentCanvas.GetComponent <CanvasScaler>().uiScaleMode != CanvasScaler.ScaleMode.ConstantPixelSize)
                        {
                            EditorGUILayout.LabelField("Canvas Scaler", EditorStyles.boldLabel);
                            EditorGUILayout.HelpBox("The Canvas Scaler component located on the parent Canvas needs to be set to 'Constant Pixel Size' in order for the Ultimate Status Bar to function correctly.", MessageType.Error);
                            EditorGUILayout.BeginHorizontal();
                            GUILayout.Space(5);
                            if (GUILayout.Button("Update Canvas"))
                            {
                                parentCanvas.GetComponent <CanvasScaler>().uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize;
                            }
                            GUILayout.Space(5);
                            if (GUILayout.Button("Update Status Bar"))
                            {
                                UltimateStatusBarCreator.RequestCanvas(Selection.activeGameObject);
                                parentCanvas = GetParentCanvas();
                            }
                            GUILayout.Space(5);
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.Space();
                        }
                    }
                }
                else
                {
                    GUILayout.Space(5);

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(scalingAxis, new GUIContent("Scaling Axis", "Should the Ultimate Status Bar be sized according to screen Height or Width?"));
                    EditorGUILayout.Slider(statusBarSize, 0.0f, 10.0f, new GUIContent("Status Bar Size", "Determines the overall size of the status bar."));
                    EditorGUILayout.PropertyField(preserveAspect, new GUIContent("Preserve Aspect", "Should the Ultimate Status Bar preserve the aspect ratio of the targeted image?"));
                    EditorGUI.BeginDisabledGroup(usbController.preserveAspect == false);
                    EditorGUI.indentLevel = 1;
                    EditorGUILayout.PropertyField(targetImage, new GUIContent("Target Image", "The targeted image to preserve the aspect ratio of."));
                    if (usbController.preserveAspect == true && usbController.targetImage == null)
                    {
                        EditorGUILayout.HelpBox("Target Image needs to be assigned for the Preserve Aspect option to work.", MessageType.Error);
                    }
                    EditorGUI.indentLevel = 0;
                    EditorGUI.EndDisabledGroup();
                    if (EditorGUILayout.BeginFadeGroup(customAspectRatio.faded))
                    {
                        EditorGUI.indentLevel = 1;
                        EditorGUILayout.Slider(xRatio, 0.0f, 1.0f, new GUIContent("X Ratio", "The desired width of the image."));
                        EditorGUILayout.Slider(yRatio, 0.0f, 1.0f, new GUIContent("Y Ratio", "The desired height of the image."));
                        EditorGUI.indentLevel = 0;
                    }
                    if (SizeAndPlacement.faded == 1 && PosOpScreenSpace.faded == 1)
                    {
                        EditorGUILayout.EndFadeGroup();
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                        customAspectRatio.target = usbController.preserveAspect == true ? false : true;
                    }

                    EditorGUILayout.Space();

                    EditorGUILayout.BeginVertical("Box");
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Status Bar Position", EditorStyles.boldLabel);
                    GUILayout.EndHorizontal();
                    EditorGUI.indentLevel = 1;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.Slider(spacingX, 0.0f, 100.0f, new GUIContent("X Position", "The horizontal position of the image."));
                    EditorGUILayout.Slider(spacingY, 0.0f, 100.0f, new GUIContent("Y Position", "The vertical position of the image."));
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                    }

                    GUILayout.Space(1);

                    EditorGUI.indentLevel = 0;
                    EditorGUILayout.EndVertical();
                }
            }
            if (SizeAndPlacement.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }

            if (EditorGUILayout.BeginFadeGroup(PosOpFollowCam.faded))
            {
                GUILayout.Space(5);

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(findBy);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                EditorGUI.BeginChangeCheck();
                if (usbController.findBy == UltimateStatusBarController.FindBy.Camera)
                {
                    EditorGUILayout.PropertyField(cameraTransform);
                }
                else if (usbController.findBy == UltimateStatusBarController.FindBy.Name)
                {
                    EditorGUILayout.PropertyField(targetName);
                }
                else
                {
                    EditorGUILayout.PropertyField(targetTag);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
            if (SizeAndPlacement.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* -------------------------------------- > END SIZE AND PLACEMENT < -------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region STYLE AND OPTIONS
        /* ----------------------------------------- > STYLE AND OPTIONS < ----------------------------------------- */
        DisplayHeader("Style and Options", "UUI_StyleAndOptions", StyleAndOptions);
        if (EditorGUILayout.BeginFadeGroup(StyleAndOptions.faded))
        {
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(initialState, new GUIContent("Initial State", "Determines if the Ultimate Status Bar Controller should be enabled or disabled from start."));
            EditorGUILayout.PropertyField(timeoutOption, new GUIContent("Timeout Option", "Should the Ultimate Status Bar be disabled visually after being idle for a designated time?"));
            EditorGUI.indentLevel = 1;
            if (usbController.timeoutOption == UltimateStatusBarController.TimeoutOption.Fade)
            {
                EditorGUILayout.PropertyField(idleSeconds, new GUIContent("Idle Seconds", "Time in seconds after being idle for the status bar to be disabled."));
                EditorGUILayout.PropertyField(enabledDuration, new GUIContent("Enabled Duration", "The duration in which to fade in."));
                EditorGUILayout.PropertyField(disabledDuration, new GUIContent("Disabled Duration", "The duration in which to fade out."));
            }
            else if (usbController.timeoutOption == UltimateStatusBarController.TimeoutOption.Animation)
            {
                EditorGUILayout.PropertyField(idleSeconds, new GUIContent("Idle Seconds", "Time in seconds after being idle for the status bar to be disabled."));
                EditorGUILayout.PropertyField(statusBarAnimator, new GUIContent("Animator", "The Animator to be used for enabling and disabling the Ultimate Status Bar."));

                if (usbController.statusBarAnimator == null)
                {
                    EditorGUILayout.HelpBox("The Animator component is not assigned. Please make sure to assign the Animator before continuing.", MessageType.Error);
                }
            }
            EditorGUI.indentLevel = 0;
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* --------------------------------------- > END STYLE AND OPTIONS < --------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region SCRIPT REFERENCE
        /* ----------------------------------------- > SCRIPT REFERENCE < ----------------------------------------- */
        DisplayHeader("Script Reference", "UUI_ScriptReference", ScriptReference);
        if (EditorGUILayout.BeginFadeGroup(ScriptReference.faded))
        {
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(controllerName, new GUIContent("Controller Name", "The name to be used for reference from scripts."));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();

                nameUnassigned.target = usbController.controllerName == string.Empty ? true : false;
                nameAssigned.target   = usbController.controllerName != string.Empty ? true : false;
            }

            if (EditorGUILayout.BeginFadeGroup(nameUnassigned.faded))
            {
                EditorGUILayout.HelpBox("Please make sure to assign a name so that this controller can be referenced from your scripts.", MessageType.Warning);
            }
            if (ScriptReference.faded == 1.0f)
            {
                EditorGUILayout.EndFadeGroup();
            }

            if (EditorGUILayout.BeginFadeGroup(nameAssigned.faded))
            {
                EditorGUILayout.BeginVertical("Box");
                GUILayout.Space(1);
                scriptCast = ( ScriptCast )EditorGUILayout.EnumPopup("Script Use: ", scriptCast);
                if (scriptCast == ScriptCast.UpdatePositioning)
                {
                    EditorGUILayout.TextField("UltimateStatusBarController.UpdatePositioning( \"" + usbController.controllerName + "\" );");
                }
                else if (scriptCast == ScriptCast.UpdateName)
                {
                    EditorGUILayout.TextField("UltimateStatusBarController.UpdateStatusBarName( \"" + usbController.controllerName + "\", targetName );");
                }
                else if (scriptCast == ScriptCast.UpdateIcon)
                {
                    EditorGUILayout.TextField("UltimateStatusBarController.UpdateStatusBarIcon( \"" + usbController.controllerName + "\", targetIcon );");
                }
                else if (scriptCast == ScriptCast.ShowStatusBar)
                {
                    EditorGUILayout.TextField("UltimateStatusBarController.ShowStatusBar( \"" + usbController.controllerName + "\" );");
                }
                else if (scriptCast == ScriptCast.HideStatusBar)
                {
                    EditorGUILayout.TextField("UltimateStatusBarController.HideStatusBar( \"" + usbController.controllerName + "\" );");
                }
                GUILayout.Space(1);
                EditorGUILayout.EndVertical();
            }
            if (ScriptReference.faded == 1.0f)
            {
                EditorGUILayout.EndFadeGroup();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* --------------------------------------- > END SCRIPT REFERENCE < --------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region DEBUGGING
        /* --------------------------------------- > ULTIMATE STATUS BARS < --------------------------------------- */
        DisplayHeader("Debugging", "UUI_ExtraOption_01", UltimateStatusBars);
        if (EditorGUILayout.BeginFadeGroup(UltimateStatusBars.faded))
        {
            EditorGUILayout.Space();

            if (myStatusBars.Length == 0)
            {
                EditorGUILayout.HelpBox("There are no Ultimate Status Bar scripts attached to any children of this object. " +
                                        "Please be sure there is at least one Ultimate Status Bar before attempting to make changes in this section.", MessageType.Warning);
            }
            else
            {
                bool hasDuplicates = false;
                EditorGUI.indentLevel = 0;
                for (int i = 0; i < myStatusBars.Length; i++)
                {
                    for (int eachStatus = 0; eachStatus < myStatusBars.Length; eachStatus++)
                    {
                        if (myStatusBars[i] != myStatusBars[eachStatus] && myStatusBars[i].statusBarName == myStatusBars[eachStatus].statusBarName)
                        {
                            hasDuplicates = true;
                        }
                    }
                }
                if (hasDuplicates == true)
                {
                    EditorGUILayout.HelpBox("Some statusBarName references are the same. Please be sure to make every Ultimate Status Bar name unique.", MessageType.Error);
                }

                for (int i = 0; i < myStatusBars.Length; i++)
                {
                    EditorGUILayout.BeginVertical("Box");

                    GUILayout.Space(1);

                    if (GUILayout.Button(myStatusBars[i].gameObject.name))
                    {
                        Selection.activeGameObject = myStatusBars[i].gameObject;
                    }

                    GUILayout.Space(5);

                    EditorGUI.BeginChangeCheck();
                    myStatusBars[i].statusBarName = EditorGUILayout.TextField(new GUIContent("Status Name:"), myStatusBars[i].statusBarName);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorUtility.SetDirty(myStatusBars[i]);
                    }

                    EditorGUI.BeginChangeCheck();
                    testValues[i] = EditorGUILayout.Slider("Test Value", testValues[i], 0.0f, 1.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        myStatusBars[i].statusBar.enabled = false;
                        myStatusBars[i].UpdateStatusBar(testValues[i], 1.0f);
                        myStatusBars[i].statusBar.enabled = true;
                    }
                    GUILayout.Space(1);
                    EditorGUILayout.EndVertical();

                    if (i != (myStatusBars.Length - 1))
                    {
                        GUILayout.Space(5);
                    }
                }
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* ------------------------------------- > END ULTIMATE STATUS BARS < ------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        Repaint();
    }
        void drawSelectedAnimation()
        {
            var selectedProp = _reorderableAnimationList.serializedProperty.GetArrayElementAtIndex(_selectedIndex);

            serializedObject.Update();

            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical();

            if (GUILayout.Button(selectedProp.FindPropertyRelative("name").stringValue, EditorStyles.toolbarButton))
            {
                _framesListAnimBool.target = !_framesListAnimBool.target;
            }

            if (EditorGUILayout.BeginFadeGroup(_framesListAnimBool.faded))
            {
                GUILayout.Space(10);
                GUI.backgroundColor = Color.white;

                EditorGUILayout.PropertyField(selectedProp.FindPropertyRelative("fps"), new GUIContent("FPS"));
                EditorGUILayout.PropertyField(selectedProp.FindPropertyRelative("completionBehavior"), new GUIContent("Completion Behavior"));
                EditorGUILayout.PropertyField(selectedProp.FindPropertyRelative("loop"), new GUIContent("Loop"));
                EditorGUILayout.PropertyField(selectedProp.FindPropertyRelative("pingPong"), new GUIContent("Ping-Pong"));
                EditorGUILayout.PropertyField(selectedProp.FindPropertyRelative("delay"), new GUIContent("Delay"));

                EditorGUILayout.Space();

                _reorderableFrameList.DoLayoutList();
                dropAreaGUI();

                GUILayout.Space(20);
            }

            EditorGUILayout.Space();

            // triggers
            if (GUILayout.Button("Animation Triggers", EditorStyles.toolbarButton))
            {
                _triggerListAnimBool.target = !_triggerListAnimBool.target;
            }

            if (EditorGUILayout.BeginFadeGroup(_triggerListAnimBool.faded))
            {
                var totalAnimationFrames = selectedProp.FindPropertyRelative("frames").arraySize - 1;
                var triggersProp         = selectedProp.FindPropertyRelative("triggers");
                for (var i = triggersProp.arraySize - 1; i >= 0; i--)
                {
                    EditorGUILayout.BeginVertical(i % 2 == 0 ? triggerStyleOdd : triggerStyleEven);

                    var triggerEle = triggersProp.GetArrayElementAtIndex(i);
                    EditorGUILayout.IntSlider(triggerEle.FindPropertyRelative("frame"), 0, totalAnimationFrames);
                    EditorGUILayout.PropertyField(triggerEle.FindPropertyRelative("onEnteredFrame"));

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Remove Trigger"))
                    {
                        triggersProp.DeleteArrayElementAtIndex(i);
                    }
                    GUILayout.EndHorizontal();

                    EditorGUILayout.EndVertical();
                }

                EditorGUILayout.Space();

                if (GUILayout.Button("Add New Animation Trigger"))
                {
                    triggersProp.InsertArrayElementAtIndex(triggersProp.arraySize);
                }

                EditorGUILayout.Space();
            }
            EditorGUILayout.EndFadeGroup();


            serializedObject.ApplyModifiedProperties();

            GUILayout.Space(10);
            if (GUILayout.Button("Done Editing"))
            {
                _selectedIndex = -1;
            }

            EditorGUILayout.EndVertical();
        }
Beispiel #6
0
    override public void OnInspectorGUI()
    {
        serializedObject.Update();
        SkeletonDataAsset asset = (SkeletonDataAsset)target;

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(atlasAsset);
        EditorGUILayout.PropertyField(skeletonJSON);
        EditorGUILayout.PropertyField(scale);
        if (EditorGUI.EndChangeCheck())
        {
            if (m_previewUtility != null)
            {
                m_previewUtility.Cleanup();
                m_previewUtility = null;
            }
        }

        SkeletonData skeletonData = asset.GetSkeletonData(asset.atlasAsset == null || asset.skeletonJSON == null);

        if (skeletonData != null)
        {
            showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
            if (showAnimationStateData)
            {
                EditorGUILayout.PropertyField(defaultMix);

                // Animation names
                String[] animations = new String[skeletonData.Animations.Count];
                for (int i = 0; i < animations.Length; i++)
                {
                    animations[i] = skeletonData.Animations[i].Name;
                }

                for (int i = 0; i < fromAnimation.arraySize; i++)
                {
                    SerializedProperty from         = fromAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty to           = toAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty durationProp = duration.GetArrayElementAtIndex(i);
                    EditorGUILayout.BeginHorizontal();
                    from.stringValue        = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)];
                    to.stringValue          = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)];
                    durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue);
                    if (GUILayout.Button("Delete"))
                    {
                        duration.DeleteArrayElementAtIndex(i);
                        toAnimation.DeleteArrayElementAtIndex(i);
                        fromAnimation.DeleteArrayElementAtIndex(i);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("Add Mix"))
                {
                    duration.arraySize++;
                    toAnimation.arraySize++;
                    fromAnimation.arraySize++;
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button(new GUIContent("Setup Pose", SpineEditorUtilities.Icons.skeleton), GUILayout.Width(105), GUILayout.Height(18)))
            {
                StopAnimation();
                m_skeletonAnimation.skeleton.SetToSetupPose();
                m_requireRefresh = true;
            }

                        #if UNITY_4_3
            m_showAnimationList = EditorGUILayout.Foldout(m_showAnimationList, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot));
            if (m_showAnimationList)
            {
                        #else
            m_showAnimationList.target = EditorGUILayout.Foldout(m_showAnimationList.target, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot));
            if (EditorGUILayout.BeginFadeGroup(m_showAnimationList.faded))
            {
                                #endif



                EditorGUILayout.LabelField("Name", "Duration");
                foreach (Spine.Animation a in skeletonData.Animations)
                {
                    GUILayout.BeginHorizontal();

                    if (m_skeletonAnimation != null && m_skeletonAnimation.state != null)
                    {
                        if (m_skeletonAnimation.state.GetCurrent(0) != null && m_skeletonAnimation.state.GetCurrent(0).Animation == a)
                        {
                            GUI.contentColor = Color.black;
                            if (GUILayout.Button("\u25BA", GUILayout.Width(24)))
                            {
                                StopAnimation();
                            }
                            GUI.contentColor = Color.white;
                        }
                        else
                        {
                            if (GUILayout.Button("\u25BA", GUILayout.Width(24)))
                            {
                                PlayAnimation(a.Name, true);
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("?", GUILayout.Width(24));
                    }
                    EditorGUILayout.LabelField(new GUIContent(a.Name, SpineEditorUtilities.Icons.animation), new GUIContent(a.Duration.ToString("f3") + "s" + ("(" + (Mathf.RoundToInt(a.Duration * 30)) + ")").PadLeft(12, ' ')));
                    GUILayout.EndHorizontal();
                }
            }
                        #if !UNITY_4_3
            EditorGUILayout.EndFadeGroup();
                        #endif
        }

        if (!Application.isPlaying)
        {
            if (serializedObject.ApplyModifiedProperties() ||
                (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
                )
            {
                asset.Reset();
            }
        }
    }
        public override void OnInspectorGUI()
        {
            if (settingsStyle == null)
            {
                settingsStyle = GetStyle("IN TitleText");
            }

            if (boldLabelStyle == null)
            {
                boldLabelStyle = GetStyle("boldLabel");
            }

            if (labelStyle == null)
            {
                labelStyle = GetStyle("label");
            }

            serializedObject.Update();
            EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins);
            EditorGUILayout.PropertyField(title);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Bundle Id");
#if UNITY_5_6_OR_NEWER
            var content = new GUIContent(PlayerSettings.applicationIdentifier + ".");
#else
            var content = new GUIContent(PlayerSettings.bundleIdentifier + ".");
#endif
            EditorGUILayout.LabelField(content.text, labelStyle, GUILayout.Width(labelStyle.CalcSize(content).x));
            EditorGUILayout.PropertyField(bundleId, GUIContent.none);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("Bundle Version", PlayerSettings.bundleVersion);
            EditorGUILayout.LabelField("Build Number", PlayerSettings.iOS.buildNumber);

            EditorGUILayout.PropertyField(automaticSigning);
            automaticSigningAnimated.target = !automaticSigning.boolValue;

            if (EditorGUILayout.BeginFadeGroup(automaticSigningAnimated.faded))
            {
                EditorGUI.BeginDisabledGroup(automaticSigning.boolValue);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(provisioningProfile);
                EditorGUILayout.PropertyField(provisioningProfileSpecifier);
                EditorGUI.indentLevel--;
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndFadeGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            if (BeginSettingsBox(0, new GUIContent("Icons")))
            {
                DrawIcons();
            }
            EndSettingsBox();

            if (BeginSettingsBox(1, new GUIContent("Stickers")))
            {
                EditorGUILayout.PropertyField(size);
                list.DoLayoutList();
            }
            EndSettingsBox();
            serializedObject.ApplyModifiedProperties();
        }
        private void DrawDetails()
        {
            EditorGUILayout.BeginFadeGroup(1);

            EditorGUILayout.LabelField("Action Details", headerLabelStyle);

            EditorGUILayout.Space();


            EditorGUILayout.LabelField("Full Action Path:");
            if (selectedActionIndex != -1)
            {
                EditorGUILayout.LabelField(selectedAction.name);
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Name:");
            if (selectedActionIndex != -1)
            {
                string newName = EditorGUILayout.TextField(selectedAction.shortName);

                if (newName != selectedAction.shortName)
                {
                    selectedAction.name = selectedAction.path + newName;
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Type:");
            if (selectedActionIndex != -1)
            {
                bool directionIn = selectedAction.path.IndexOf("/in/", StringComparison.CurrentCultureIgnoreCase) != -1;

                string[] list;

                if (directionIn)
                {
                    list = SteamVR_Input_ActionFile_ActionTypes.listIn;
                }
                else
                {
                    list = SteamVR_Input_ActionFile_ActionTypes.listOut;
                }


                int selectedType = Array.IndexOf(list, selectedAction.type);

                int newSelectedType = EditorGUILayout.Popup(selectedType, list);

                if (selectedType == -1 && newSelectedType == -1)
                {
                    newSelectedType = 0;
                }

                if (selectedType != newSelectedType && newSelectedType != -1)
                {
                    selectedAction.type = list[newSelectedType];
                }

                if (selectedAction.type == SteamVR_Input_ActionFile_ActionTypes.skeleton)
                {
                    string currentSkeletonPath = selectedAction.skeleton;
                    if (string.IsNullOrEmpty(currentSkeletonPath) == false)
                    {
                        currentSkeletonPath = currentSkeletonPath.Replace("/", "\\");
                    }

                    int selectedSkeletonType    = Array.IndexOf(SteamVR_Input_ActionFile_ActionTypes.listSkeletons, currentSkeletonPath);
                    int newSelectedSkeletonType = EditorGUILayout.Popup(selectedSkeletonType, SteamVR_Input_ActionFile_ActionTypes.listSkeletons);

                    if (selectedSkeletonType == -1)
                    {
                        selectedSkeletonType = 0;
                    }

                    if (selectedSkeletonType != newSelectedSkeletonType && newSelectedSkeletonType != -1)
                    {
                        selectedAction.skeleton = SteamVR_Input_ActionFile_ActionTypes.listSkeletons[newSelectedSkeletonType].Replace("\\", "/");
                    }
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Required:");
            if (selectedActionIndex != -1)
            {
                int oldRequirement = (int)selectedAction.requirementEnum;
                int newRequirement = GUILayout.SelectionGrid(oldRequirement, SteamVR_Input_ActionFile_Action.requirementValues, 1, EditorStyles.radioButton);

                if (oldRequirement != newRequirement)
                {
                    selectedAction.requirementEnum = (SteamVR_Input_ActionFile_Action_Requirements)newRequirement;
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Localization:");
            localizationList.DoLayoutList();

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Localized String:");
            if (selectedLocalizationIndex != -1)
            {
                Dictionary <string, string> localizationItems = SteamVR_Input.actionFile.localizationHelperList[selectedLocalizationIndex].items;
                string oldValue = "";

                if (localizationItems.ContainsKey(selectedAction.name))
                {
                    oldValue = localizationItems[selectedAction.name];
                }

                string newValue = EditorGUILayout.TextField(oldValue);

                if (string.IsNullOrEmpty(newValue))
                {
                    localizationItems.Remove(selectedAction.name);
                }
                else if (oldValue != newValue)
                {
                    if (localizationItems.ContainsKey(selectedAction.name) == false)
                    {
                        localizationItems.Add(selectedAction.name, newValue);
                    }
                    else
                    {
                        localizationItems[selectedAction.name] = newValue;
                    }
                }
            }


            EditorGUILayout.EndFadeGroup();
        }
Beispiel #9
0
        /// <summary>
        /// Draw the object reference's binding info (path and link to object)
        /// </summary>
        /// <param name="aClipInfo">AnimationClipInfo associated to the BindingInfo to draw</param>
        /// <param name="aBindingInfo">BindingInfo to draw</param>
        private void DrawObjectReference(EditorBindingInfo aBindingInfo, bool aIsInitialDraw)
        {
            GameObject objectReference = FindObjectInRoot(aBindingInfo.Path);

            // Cleanup references when drawing them for the first time (or switching which animation clip is being drawn)
            if (aIsInitialDraw)
            {
                aBindingInfo.ShowAssociatedBindings = false;
            }

            if (aBindingInfo.HasPendingChanges)
            {
                GUI.color = Color.yellow;
            }
            else if (objectReference == null)
            {
                GUI.color = Color.red;
            }

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            GUI.color = defaultColor;

            GUIContent label = new GUIContent(" Path: /" + aBindingInfo.Path, "/" + aBindingInfo.Path);

            GUILayout.Label(label, GUILayout.Width(150.0f));

            if (aBindingInfo.HasPendingChanges)
            {
                objectReference = FindObjectInRoot(aBindingInfo.NewPath);
            }

            // Draw the object field with the latest information and color it based on status. Red = invalid object (null), Yellow = pending change, Green = valid object
            GameObject newObjectReference = EditorGUILayout.ObjectField(objectReference, typeof(GameObject), true) as GameObject;

            // Update binding info's pending change data with new object reference
            if (newObjectReference != objectReference)
            {
                string newPath = GetPath(newObjectReference);

                if (aBindingInfo.ClipInfo.ContainsBinding(newPath))
                {
                    Debug.LogWarningFormat("[{0}] already has the binding with path [{1}] or has it in a pending change!", aBindingInfo.ClipInfo.Clip.name, newPath);
                }
                else
                {
                    if (aBindingInfo.HasPendingChanges == false)
                    {
                        pendingChanges++;
                    }

                    aBindingInfo.SetPendingUpdate(newPath);
                }
            }

            GUI.enabled = aBindingInfo.HasPendingChanges;

            // Draw apply button
            if (GUILayout.Button("Apply", EditorStyles.miniButtonLeft))
            {
                // Setup list of bindings to update base on the curently selected one as well as the current one's associated bindings
                List <EditorBindingInfo> bindings = new List <EditorBindingInfo>()
                {
                    aBindingInfo
                };
                foreach (EditorBindingInfo associatedBindingInfo in aBindingInfo.AssociatedBindings)
                {
                    if (associatedBindingInfo.HasPendingChanges && associatedBindingInfo.NewPath.Equals(aBindingInfo.NewPath))
                    {
                        bindings.Add(associatedBindingInfo);
                    }
                }

                ApplyPendingChanges(bindings.ToArray());
            }

            // Draw clear changes button
            if (GUILayout.Button("Clear", EditorStyles.miniButtonMid))
            {
                ClearPendingChanges(aBindingInfo);
            }

            GUI.enabled = (aBindingInfo.AssociatedBindings.Count > 0);

            // Diplay the show associated bindings button
            string     arrowUnicode  = (aBindingInfo.ShowAssociatedBindings) ? upArrowUnicode : downArrowUnicode;
            GUIContent expandContent = new GUIContent(arrowUnicode, "Expand to show associated bindings among the other animation clips on this animator");

            // Draw show associated bindings
            if (GUILayout.Button(expandContent, EditorStyles.miniButtonRight))
            {
                aBindingInfo.ShowAssociatedBindings = !aBindingInfo.ShowAssociatedBindings;
            }

            GUI.enabled = true;

            GUILayout.EndHorizontal();

            // Draw associated bindings
            if (EditorGUILayout.BeginFadeGroup(aBindingInfo.ShowAssociatedBindingsValue))
            {
                if (aBindingInfo.HasPendingChanges == false)
                {
                    EditorGUILayout.HelpBox("Can't modify associated bindings if the current one is not being modified.", MessageType.Info);
                }
                else
                {
                    EditorGUILayout.HelpBox("List of animations with this same binding. Check to associate changes across animations.", MessageType.Info);

                    foreach (EditorBindingInfo associatedBindingInfo in aBindingInfo.AssociatedBindings)
                    {
                        DrawAssociatedObjectReference(aBindingInfo, associatedBindingInfo);
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();
        }
Beispiel #10
0
    private void SectionEffects() {
        GUILayout.Label("Effects", "HeaderLabel");
        using (MadGUI.Indent()) {
            FieldSmoothEffect();

            burnEffectAnimBool.target = effectBurn.boolValue;
            MadGUI.PropertyField(effectBurn, "Burn");
            if (EditorGUILayout.BeginFadeGroup(burnEffectAnimBool.faded)) {
                MadGUI.Indent(() => {
                    FieldSprite(effectBurnSprite, "Bar Texture");
                    MadGUI.PropertyField(effectBurnSprite.FindPropertyRelative("material"), "Material");

                    MadGUI.PropertyFieldEnumPopup(effectBurnDirection, "Direction");
                    if (effectBurnDirection.enumValueIndex != (int) EnergyBarBase.BurnDirection.OnlyWhenDecreasing &&
                        !effectSmoothChange.boolValue) {
                        if (
                            MadGUI.WarningFix(
                                "Burning when increasing will be visible only if the Smooth effect is enabled.",
                                "Enable Smooth Effect")) {
                            effectSmoothChange.boolValue = true;
                        }
                    }
                    MadGUI.PropertyField(effectSmoothChangeSpeed, "Speed");
                });
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndFadeGroup();

            blinkEffectAnimBool.target = effectBlink.boolValue;
            MadGUI.PropertyField(effectBlink, "Blink");
            if (EditorGUILayout.BeginFadeGroup(blinkEffectAnimBool.faded)) {
                MadGUI.Indent(() => {
                    MadGUI.PropertyFieldEnumPopup(effectBlinkOperator, "Operator");
                    MadGUI.PropertyField(effectBlinkValue, "Value");
                    MadGUI.PropertyField(effectBlinkRatePerSecond, "Rate (per second)");
                    MadGUI.PropertyField(effectBlinkColor, "Color");
                });
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndFadeGroup();

            tiledEffectAnimBool.target = effectTiled.boolValue;
            MadGUI.PropertyField(effectTiled, "Tiled");
            if (EditorGUILayout.BeginFadeGroup(tiledEffectAnimBool.faded)) {
                MadGUI.Indent(() => {
                    EditorGUILayout.BeginHorizontal();
                    MadGUI.PropertyField(effectTiledSprite, "Sprite", MadGUI.ObjectIsSet);
                    EditorGUILayout.PropertyField(effectTiledTint, new GUIContent(""), GUILayout.Width(90));
                    EditorGUILayout.EndHorizontal();

                    EnsureSpriteRepeated(effectTiledSprite);

                    MadGUI.PropertyFieldVector2(effectTiledTiling, "Tiling");
                    MadGUI.PropertyFieldVector2(effectTiledStartOffset, "Start Offset");
                    MadGUI.PropertyFieldVector2(effectTiledOffsetChangeSpeed, "Speed");
                });
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndFadeGroup();

            followEffectAnimBool.target = effectFollow.boolValue;
            MadGUI.PropertyField(effectFollow, "Follow");
            if (EditorGUILayout.BeginFadeGroup(followEffectAnimBool.faded)) {
                using (MadGUI.Indent()) {
                    if (!GrowDirectionSupportedByFollowEffect()) {
                        MadGUI.Error("This effect cannot be used with selected grow direction. "
                                     + "Please read manual for more information.");
                    }

                    MadGUI.PropertyField(effectFollowObject, "GameObject");
                    MadGUI.PropertyField(effectFollowOffset, "Position Offset");

                    EditorGUILayout.Space();

                    MadGUI.PropertyField(effectFollowColor, "Color");
                    MadGUI.PropertyField(effectFollowRotation, "Rotation");
                    if (MadGUI.Foldout("Scale", false)) {
                        MadGUI.Indent(() => {
                            MadGUI.PropertyField(effectFollowScaleX, "X");
                            MadGUI.PropertyField(effectFollowScaleY, "Y");
                            MadGUI.PropertyField(effectFollowScaleZ, "Z");
                        });
                    }
                }
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndFadeGroup();
        }
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        m_tabAdd.Clear();

        var skinEnabled = serializedObject.FindProperty("SkinSettings.Enabled");

        if (skinEnabled.boolValue && !skinEnabled.hasMultipleDifferentValues)
        {
            bool removed;
            m_skinGroup.target = m_tabGroup.TabArea("Skin Scattering", s_scatterColor, true, out removed,
                                                    c_skinTabName);

            if (EditorGUILayout.BeginFadeGroup(m_skinGroup.faded))
            {
                var prop = serializedObject.FindProperty("SkinSettings");
                prop.Next(true); //skip flag
                prop.Next(true); //skip enabled

                DrawRemainingProp(prop);
            }

            EditorGUILayout.EndFadeGroup();

            if (removed)
            {
                skinEnabled.boolValue = false;
            }
        }
        else
        {
            m_tabAdd.Add(new AlloyTabAdd {
                Color  = s_scatterColor,
                Name   = "Skin Scattering",
                Enable = EnableSkin
            });
        }

        var transEnabled = serializedObject.FindProperty("TransmissionSettings.Enabled");

        if (transEnabled.boolValue && !transEnabled.hasMultipleDifferentValues)
        {
            bool removed;
            m_transmissionGroup.target = m_tabGroup.TabArea("Transmission", s_transmissionColor, true, out removed,
                                                            c_transmissionTabName);

            if (EditorGUILayout.BeginFadeGroup(m_transmissionGroup.faded))
            {
                var prop = serializedObject.FindProperty("TransmissionSettings");
                prop.Next(true); //skip flag
                prop.Next(true); //skip enabled
                DrawRemainingProp(prop);
            }

            EditorGUILayout.EndFadeGroup();

            if (removed)
            {
                transEnabled.boolValue = false;
            }
        }
        else
        {
            m_tabAdd.Add(new AlloyTabAdd {
                Color  = s_transmissionColor,
                Name   = "Transmission",
                Enable = EnableTransmission
            });
        }

        if (m_skinGroup.isAnimating || m_transmissionGroup.isAnimating)
        {
            Repaint();
        }

        AlloyEditor.DrawAddTabGUI(m_tabAdd);
        serializedObject.ApplyModifiedProperties();

        if (GUI.changed)
        {
            var deferredRendererPlus = serializedObject.targetObject as AlloyEffectsManager;

            if (deferredRendererPlus != null)
            {
                deferredRendererPlus.Refresh();
            }
        }
    }
Beispiel #12
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            serializedObject.Update();

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(m_TextComponent);

            if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null)
            {
                UIText text = m_TextComponent.objectReferenceValue as UIText;
                // if (text.supportRichText)
                // {
                //     EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning);
                // }
            }

            using (new EditorGUI.DisabledScope(m_TextComponent == null || m_TextComponent.objectReferenceValue == null))
            {
                EditorGUILayout.PropertyField(m_Text);
                EditorGUILayout.PropertyField(m_CharacterLimit);

                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_ContentType);
                if (!m_ContentType.hasMultipleDifferentValues)
                {
                    EditorGUI.indentLevel++;

                    if (m_ContentType.enumValueIndex == (int)UIInputField.ContentType.Standard ||
                        m_ContentType.enumValueIndex == (int)UIInputField.ContentType.Autocorrected ||
                        m_ContentType.enumValueIndex == (int)UIInputField.ContentType.Custom)
                    {
                        EditorGUILayout.PropertyField(m_LineType);
                    }

                    if (m_ContentType.enumValueIndex == (int)UIInputField.ContentType.Custom)
                    {
                        EditorGUILayout.PropertyField(m_InputType);
                        EditorGUILayout.PropertyField(m_KeyboardType);
                        EditorGUILayout.PropertyField(m_CharacterValidation);
                    }

                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_Placeholder);
                EditorGUILayout.PropertyField(m_CaretBlinkRate);
                EditorGUILayout.PropertyField(m_CaretWidth);

                EditorGUILayout.PropertyField(m_CustomCaretColor);

                m_CustomColor.target = m_CustomCaretColor.boolValue;

                if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded))
                {
                    EditorGUILayout.PropertyField(m_CaretColor);
                }
                EditorGUILayout.EndFadeGroup();

                EditorGUILayout.PropertyField(m_SelectionColor);
                EditorGUILayout.PropertyField(m_HideMobileInput);
                EditorGUILayout.PropertyField(m_ReadOnly);

                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_OnValueChanged);
                EditorGUILayout.PropertyField(m_OnEndEdit);
            }

            serializedObject.ApplyModifiedProperties();

            //base.OnInspectorGUI();
        }
        public override void OnInspectorGUI()
        {
            SetAnimBools(false);

            serializedObject.Update();
            // Once we have a reliable way to know if the object changed, only re-cache in that case.
            CalculateCachedValues();

            EditorGUILayout.PropertyField(m_Content);
            EditorGUILayout.PropertyField(m_CeilBar);
            EditorGUILayout.PropertyField(m_FloorBar);
            LoopScrollRectEditor.PropertyFieldChooseMono(m_Templates);
            GUILayout.Space(10);
            GUILayout.Label(new GUIContent("____________________________________________________________________________________________________"), GUILayout.MaxWidth(500));
            EditorGUILayout.PropertyField(m_PageSize);
            EditorGUILayout.PropertyField(m_Padding);
            // EditorGUILayout.PropertyField(m_Columns);
            EditorGUILayout.PropertyField(m_RenderPerFrames);
            EditorGUILayout.PropertyField(m_DragOffsetShow);

            // EditorGUILayout.PropertyField(m_Horizontal);
            // EditorGUILayout.PropertyField(m_Vertical);
            // EditorGUILayout.PropertyField(m_MovementType);

            if (EditorGUILayout.BeginFadeGroup(m_ShowElasticity.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_Elasticity);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.PropertyField(m_Inertia);
            if (EditorGUILayout.BeginFadeGroup(m_ShowDecelerationRate.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_DecelerationRate);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.PropertyField(m_ScrollSensitivity);

            EditorGUILayout.Space();

            // EditorGUILayout.PropertyField(m_Viewport);

            EditorGUILayout.PropertyField(m_VerticalScrollbar);
            if (m_VerticalScrollbar.objectReferenceValue && !m_VerticalScrollbar.hasMultipleDifferentValues)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_VerticalScrollbarVisibility, EditorGUIUtility.TrTextContent("Visibility"));

                if ((ScrollRect.ScrollbarVisibility)m_VerticalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport &&
                    !m_VerticalScrollbarVisibility.hasMultipleDifferentValues)
                {
                    if (m_ViewportIsNotChild || m_VScrollbarIsNotChild)
                    {
                        EditorGUILayout.HelpBox(s_VError, MessageType.Error);
                    }
                    EditorGUILayout.PropertyField(m_VerticalScrollbarSpacing, EditorGUIUtility.TrTextContent("Spacing"));
                }

                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(m_PointerClickEvent);
            EditorGUILayout.PropertyField(m_OnBeginDragChanged);
            EditorGUILayout.PropertyField(m_OnDragChanged);
            EditorGUILayout.PropertyField(m_OnEndDragChanged);

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #14
0
        void OnModuleWindowCB(int id)
        {
            // something happened in the meantime?
            if (id >= Modules.Count || mModuleCount != Modules.Count)
            {
                return;
            }
            CGModule mod = Modules[id];

            //if (LMB && Sel.SelectedModules.Count<=1)
            if (EV.type == EventType.MouseUp && !Sel.SelectedModules.Contains(mod))
            {
                Sel.Select(Modules[id]);
            }

            Rect winRect = mod.Properties.Dimensions;

            // Draw Title Buttons
            // Enabled
            EditorGUI.BeginChangeCheck();
            mod.Active = GUI.Toggle(new Rect(2, 2, 16, 16), mod.Active, "");
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(Generator);
            }

            //Edit Title & Color
            if (editTitleModule == mod)
            {
                GUI.SetNextControlName("editTitle" + id);
                mod.ModuleName = GUI.TextField(new Rect(30, 5, winRect.width - 120, 16), mod.ModuleName);
                mod.Properties.BackgroundColor = EditorGUI.ColorField(new Rect(winRect.width - 70, 5, 32, 16), mod.Properties.BackgroundColor);
            }


            if (GUI.Button(new Rect(winRect.width - 32, 6, 16, 16), new GUIContent(CurvyStyles.EditTexture, "Rename"), CurvyStyles.BorderlessButton))
            {
                editTitleModule = mod;
                Sel.Select(mod);
                EditorGUI.FocusTextInControl("editTitle" + id);
            }

            // Help
            if (GUI.Button(new Rect(winRect.width - 16, 6, 16, 16), new GUIContent(CurvyStyles.HelpTexture, "Help"), CurvyStyles.BorderlessButton))
            {
                var url = DTUtility.GetHelpUrl(mod);
                if (!string.IsNullOrEmpty(url))
                {
                    Application.OpenURL(url);
                }
            }



            // Check errors
            if (mod.CircularReferenceError)
            {
                EditorGUILayout.HelpBox("Circular Reference", MessageType.Error);
            }
            // Draw Slots
            DTGUI.PushColor(mod.Properties.BackgroundColor.SkinAwareColor(true));
            EditorGUILayout.BeginVertical(CurvyStyles.ModuleWindowSlotBackground);
            DTGUI.PopColor();
            OnModuleWindowSlotGUI(mod);
            EditorGUILayout.EndVertical();

            var ed = GetModuleEditor(mod);

            if (ed && ed.target != null)
            {
                if (EditorGUILayout.BeginFadeGroup(mShowDebug.faded))
                {
                    ed.OnInspectorDebugGUIINTERNAL(Repaint);
                }
                EditorGUILayout.EndFadeGroup();

                // Draw Module Options

                mod.Properties.Expanded.valueChanged.RemoveListener(Repaint);
                mod.Properties.Expanded.valueChanged.AddListener(Repaint);

                if (!CurvyProject.Instance.CGAutoModuleDetails)
                {
                    mod.Properties.Expanded.target = GUILayout.Toggle(mod.Properties.Expanded.target, new GUIContent(mod.Properties.Expanded.target ? CurvyStyles.CollapseTexture : CurvyStyles.ExpandTexture, "Show Details"), EditorStyles.toolbarButton);
                }

                // === Module Details ===
                // Handle Auto-Folding
                if (DTGUI.IsLayout && CurvyProject.Instance.CGAutoModuleDetails)
                {
                    mod.Properties.Expanded.target = (mod == Sel.SelectedModule);
                }

                if (EditorGUILayout.BeginFadeGroup(mod.Properties.Expanded.faded))
                {
                    EditorGUIUtility.labelWidth = (mod.Properties.LabelWidth);
                    // Draw Inspectors using Modules Background color
                    DTGUI.PushColor(ed.Target.Properties.BackgroundColor.SkinAwareColor(true));
                    EditorGUILayout.BeginVertical(CurvyStyles.ModuleWindowBackground);
                    DTGUI.PopColor();

                    ed.RenderGUI(true);
                    if (ed.NeedRepaint)
                    {
                        mDoRepaint = true;
                    }
                    GUILayout.Space(2);
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndFadeGroup();
            }

            // Make it dragable
            GUI.DragWindow(new Rect(0, 0, winRect.width, CurvyStyles.ModuleWindowTitleHeight));
        }
Beispiel #15
0
        public override void OnInspectorGUI()
        {
            //SCPE_GUI.DrawDocumentationHeader(docUrl);

            if (RenderSettings.fog)
            {
                EditorGUILayout.BeginVertical();
                {
                    EditorGUILayout.HelpBox("Fog is currently enabled in the active scene, resulting in an overlapping fog effect", MessageType.Warning);
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        if (GUILayout.Button("Disable scene fog"))
                        {
                            RenderSettings.fog = false;
                        }
                        GUILayout.FlexibleSpace();
                    }
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();
            }
            PropertyField(useSceneSettings);
            EditorGUILayout.Space();

            m_showControls.target = !useSceneSettings.value.boolValue;
            if (EditorGUILayout.BeginFadeGroup(m_showControls.faded))
            {
                PropertyField(fogMode);
                PropertyField(fogStartDistance);
                if (fogMode.value.intValue == 1)
                {
                    PropertyField(fogEndDistance);
                }
                else
                {
                    PropertyField(fogDensity);
                }

                PropertyField(colorMode);
                if (colorMode.value.intValue == 0)
                {
                    PropertyField(fogColor);
                }
                else if (colorMode.value.intValue == 1)
                {
                    PropertyField(fogColorGradient);
                    if (fogColorGradient.value.objectReferenceValue)
                    {
                        //Gradient preview
                        //Rect rect = GUILayoutUtility.GetRect(1, 12, "TextField");
                        //EditorGUI.DrawPreviewTexture(rect, fogColorGradient.value.objectReferenceValue as Texture2D);

                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUI.BeginDisabledGroup(gradientUseFarClipPlane.value.boolValue);
                            {
                                PropertyField(gradientDistance, new GUIContent("Distance"));
                            }
                            EditorGUI.EndDisabledGroup();
                            gradientUseFarClipPlane.overrideState.boolValue = true;
                            gradientUseFarClipPlane.value.boolValue         = GUILayout.Toggle(gradientUseFarClipPlane.value.boolValue, "Automatic", EditorStyles.miniButton);
                        }
                        EditorGUILayout.EndHorizontal();

                        //gradientUseFarClipPlane.value.boolValue = (gradientDistance.overrideState.boolValue) ? false : true;

                        //EditorGUILayout.HelpBox("In scene view, the gradient will appear to look different due to the camera's different far clipping value", MessageType.None);
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();

            PropertyField(distanceFog);
            if (distanceFog.value.boolValue)
            {
                PropertyField(useRadialDistance, new GUIContent("Radial"));
                PropertyField(distanceDensity);
            }

            //Always exclude skybox for skybox color mode
            if (colorMode.value.intValue != 2)
            {
                PropertyField(excludeSkybox, new GUIContent("Exclude"));
            }

            PropertyField(heightFog);
            m_showHeight.target = heightFog.value.boolValue;
            if (EditorGUILayout.BeginFadeGroup(m_showHeight.faded))
            {
                if (RuntimeUtilities.isSinglePassStereoSelected)
                {
                    EditorGUILayout.HelpBox("Currently bugged in VR", MessageType.Warning);
                }
                PropertyField(height);
                PropertyField(heightDensity);

                PropertyField(heightFogNoise);
                if (heightFogNoise.value.boolValue)
                {
#if UNITY_2018_1_OR_NEWER
                    //EditorGUILayout.HelpBox("Fog noise is currently bugged when using the Post Processing installed through the Package Manager.", MessageType.Warning);
#endif
                    PropertyField(heightNoiseTex);
                    if (heightNoiseTex.value.objectReferenceValue)
                    {
                        PropertyField(heightNoiseSize);
                        PropertyField(heightNoiseStrength);
                        PropertyField(heightNoiseSpeed);
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();

            PropertyField(lightScattering);
            m_showScattering.target = lightScattering.value.boolValue;
            if (EditorGUILayout.BeginFadeGroup(m_showScattering.faded))
            {
                PropertyField(scatterIntensity);
                PropertyField(scatterThreshold);
                PropertyField(scatterDiffusion);
                PropertyField(scatterSoftKnee);
            }
            EditorGUILayout.EndFadeGroup();
        }
Beispiel #16
0
        protected void DrawMeshConstructTool()
        {
            string buttonStr = string.Empty;

            EditorGUILayout.BeginVertical();
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                animBool_vertex.target = EditorGUILayout.BeginToggleGroup("顶点相关", animBool_vertex.target);
                if (EditorGUILayout.BeginFadeGroup(animBool_vertex.faded))
                {
                    buttonStr = vertexEditorMode ? "生成Camera顶点<Ctrl +Q>" : "生成Camera顶点";
                    if (GUILayout.Button(new GUIContent(buttonStr, "<顶点>编辑模式下,激活快捷键<Ctrl + Q>")))
                    {
                        GeneralVertex <TVertex>();
                    }

                    if (GUILayout.Button("选中所有顶点"))
                    {
                        var tCameraVertexs = GameObject.FindObjectsOfType <TVertex>();

                        var gobjs = new List <Object>();
                        for (int i = 0; i < tCameraVertexs.Length; i++)
                        {
                            gobjs.Add(tCameraVertexs[i].gameObject);
                        }

                        Selection.objects = gobjs.ToArray();
                    }
                }

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

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                animBool_trangle.target = EditorGUILayout.BeginToggleGroup("三角形相关", animBool_trangle.target);

                if (EditorGUILayout.BeginFadeGroup(animBool_trangle.faded))
                {
                    if (GUILayout.Button("将所有三角形Gobj移动至重心"))
                    {
                        MoveAllTrangleGobjToCentroid();
                    }

                    if (GUILayout.Button("将三角形加入网格"))
                    {
                        if (Selection.gameObjects.Length <= 0)
                        {
                            EditorUtility.DisplayDialog("提醒", "请选择至少1个三角形", "知道了");
                            return;
                        }
                        var tCameraTrangles = new List <TTrangle>();
                        for (int i = 0; i < Selection.gameObjects.Length; i++)
                        {
                            var gobj   = Selection.gameObjects[i];
                            var vertex = gobj.GetComponent <TTrangle>();
                            if (vertex == null)
                            {
                                continue;
                            }

                            tCameraTrangles.Add(vertex);
                        }

                        Mesh tCamearMesh = null;

                        if (!util.TryGetCameraMesh(out tCamearMesh))
                        {
                            return;
                        }

                        UnityEditor.Undo.RecordObject(tCamearMesh, "Add Trangle");

                        for (int i = 0; i < tCameraTrangles.Count; i++)
                        {
                            var trangle = tCameraTrangles[i];
                            if (!tCamearMesh.AddTrangle(trangle))
                            {
                                continue;
                            }
                        }
                        EditorUtility.SetDirty(tCamearMesh);
                    }

                    if (GUILayout.Button("选中所有三角形"))
                    {
                        var objs = GameObject.FindObjectsOfType <Trangle>();

                        var gobjs = new List <Object>();
                        for (int i = 0; i < objs.Length; i++)
                        {
                            gobjs.Add(objs[i].gameObject);
                        }

                        Selection.objects = gobjs.ToArray();
                    }
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                animBool_editor.target = EditorGUILayout.BeginToggleGroup("编辑模式", animBool_editor.target);

                if (EditorGUILayout.BeginFadeGroup(animBool_editor.faded))
                {
                    GUI.color = vertexEditorMode ? new Color(0f, 0.95f, 0.95f, 1f) : Color.white;
                    buttonStr = vertexEditorMode ? "关闭<顶点>编辑模式" : "开启<顶点>编辑模式";
                    if (GUILayout.Button(new GUIContent(buttonStr, "<顶点>编辑模式下,框选只会选择到<顶点>,而且激活生成顶点快捷键<Ctrl + Q> 和顶 点合并快捷键<Ctrl + X>")))
                    {
                        vertexEditorMode = !vertexEditorMode;
                    }
                    GUI.color = Color.white;

                    GUI.color = trangleEditorMode ? new Color(0f, 0.95f, 0.95f, 1f) : Color.white;
                    buttonStr = trangleEditorMode ? "关闭<三角形>编辑模式" : "开启<三角形>编辑模式";
                    if (GUILayout.Button(new GUIContent(buttonStr, "开启后只会框选到<三角形>")))
                    {
                        trangleEditorMode = !trangleEditorMode;
                    }
                    GUI.color = Color.white;
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.EndVertical();
            }

            buttonStr = vertexEditorMode ? "合并顶点成三角形<Ctrl +X>" : "合并顶点成三角形";
            if (GUILayout.Button(new GUIContent(buttonStr, "<顶点>编辑模式下,激活快捷键<Ctrl +X>")))
            {
                CombineVerticesToTrangle();
            }

            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
        }
Beispiel #17
0
        public override void OnInspectorGUI()
        {
            if (target is RuntimeBehaviourExecutor exe)
            {
                if (PrefabUtility.IsPartOfAnyPrefab(exe))
                {
                    EditorGUILayout.HelpBox("不能在预制件使用RuntimeBehaviourExecutor", MessageType.Error);
                    return;
                }
                else
                {
                    EditorGUILayout.HelpBox("只在本场景生效,若要制作预制件,请使用BehaviourExecutor", MessageType.Info);
                }
            }
            serializedObject.UpdateIfRequiredOrScript();
            EditorGUI.BeginChangeCheck();
            var hasTreeBef = behaviour.objectReferenceValue;

            if (target is not RuntimeBehaviourExecutor)
            {
                bool shouldDisable = Application.isPlaying && !PrefabUtility.IsPartOfAnyPrefab(target);
                EditorGUI.BeginDisabledGroup(shouldDisable);
                if (shouldDisable)
                {
                    EditorGUILayout.PropertyField(behaviour, new GUIContent("行为树"));
                }
                else
                {
                    treeDrawer.DoLayoutDraw();
                }
                EditorGUI.EndDisabledGroup();
            }
            if (behaviour.objectReferenceValue != hasTreeBef)
            {
                InitTree();
            }
            if (behaviour.objectReferenceValue)
            {
                if (GUILayout.Button("编辑"))
                {
                    BehaviourTreeEditor.CreateWindow(target as BehaviourExecutor);
                }
                serializedTree.UpdateIfRequiredOrScript();
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(serializedTree.FindProperty("_name"));
                EditorGUILayout.PropertyField(serializedTree.FindProperty("description"));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedTree.ApplyModifiedProperties();
                }
            }
            else
            {
                if (GUILayout.Button("新建"))
                {
                    BehaviourTree tree = ZetanUtility.Editor.SaveFilePanel(CreateInstance <BehaviourTree>, "new behaviour tree");
                    if (tree)
                    {
                        behaviour.objectReferenceValue = tree;
                        InitTree();
                        treeDrawer = new ObjectSelectionDrawer <BehaviourTree>(behaviour, string.Empty, string.Empty, "行为树");
                        EditorApplication.delayCall += delegate { BehaviourTreeEditor.CreateWindow(target as BehaviourExecutor); };
                    }
                }
            }
            EditorGUILayout.PropertyField(frequency, new GUIContent("执行频率"));
            if (frequency.enumValueIndex == (int)BehaviourExecutor.Frequency.FixedTime)
            {
                EditorGUILayout.PropertyField(interval, new GUIContent("间隔(秒)"));
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(startOnStart, new GUIContent("开始时执行"));
            EditorGUILayout.PropertyField(restartOnComplete, new GUIContent("完成时重启"));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(resetOnRestart, new GUIContent("重启时重置"));
            EditorGUILayout.PropertyField(gizmos, new GUIContent("显示Gizmos"));
            EditorGUILayout.EndHorizontal();
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            if (behaviour.objectReferenceValue)
            {
                serializedTree.UpdateIfRequiredOrScript();
                showList.target = EditorGUILayout.Foldout(serializedVariables.isExpanded, "行为树共享变量", true);
                if (EditorGUILayout.BeginFadeGroup(showList.faded))
                {
                    variableList.DoLayoutList();
                }
                EditorGUILayout.EndFadeGroup();
                if (target is not RuntimeBehaviourExecutor && !Application.isPlaying && !ZetanUtility.IsPrefab((target as BehaviourExecutor).gameObject))
                {
                    showPreset.target = EditorGUILayout.Foldout(presetVariables.isExpanded, "变量预设列表", true);
                    if (EditorGUILayout.BeginFadeGroup(showPreset.faded))
                    {
                        presetVariableList.DoLayoutList();
                    }
                    EditorGUILayout.EndFadeGroup();
                }
                serializedTree.ApplyModifiedProperties();
            }
        }
Beispiel #18
0
        protected void DrawOtherTool()
        {
            //其他
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                animBool_other.target = EditorGUILayout.BeginToggleGroup("其他", animBool_other.target);

                if (EditorGUILayout.BeginFadeGroup(animBool_other.faded))
                {
                    if (GUILayout.Button("帮助文档"))
                    {
                        OpenDocument();
                    }

                    EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                    {
                        if (GUILayout.Button("创建镜头检测器<Checker>"))
                        {
                            var objs       = GameObject.FindObjectsOfType <SimpleController>();
                            int displaySet = EditorPrefs.GetInt(checkerDisplayKey, 0);
                            if (objs.Length > 0)
                            {
                                if (objs.Length > 0)
                                {
                                    util.SetIcon(objs[0].gameObject, util.Icon.CirclePurple);
                                }

                                if (displaySet != 2)
                                {
                                    var res = EditorUtility.DisplayDialogComplex("提醒", "场景中已经存在镜头检测器了,帮你标成圆形紫色,并选中它了", "选中", "关闭", "不再提示");
                                    Debug.Log(res);
                                    EditorPrefs.SetInt(checkerDisplayKey, res);
                                }
                                Selection.activeGameObject = objs[0].gameObject;
                                return;
                            }

                            var checker = new GameObject("Checker", new Type[] { typeof(SimpleController) });
                            Selection.activeGameObject = checker;
                            Undo.RegisterCreatedObjectUndo(checker, "General Checker");
                            util.SetIcon(checker, util.Icon.CirclePurple);


                            Mesh mesh;
                            if (util.TryGetCameraMesh(out mesh))
                            {
                                mesh.SetTarget(checker.transform);
                                checker.transform.SetParent(mesh.transform, false);
                                checker.transform.position = Vector3.zero;
                                //如果有顶点,放到第一个顶点那里去
                                var vertices = mesh.GetAllVertices();
                                if (vertices.Count > 0 && vertices[0] != null)
                                {
                                    checker.transform.position = vertices[0].transform.position;
                                }
                            }
                        }

                        FixedCheckerPositionToMeshSurface = EditorPrefs.GetBool("FixedCheckerPositionToMeshSurface", true);
                        FixedCheckerPositionToMeshSurface = EditorGUILayout.ToggleLeft("贴合网格表面", FixedCheckerPositionToMeshSurface, GUILayout.MaxWidth(86));
                        if (SimpleController.current != null)
                        {
                            SimpleController.current.FixedPositionToMeshsSurface = FixedCheckerPositionToMeshSurface;
                            EditorPrefs.SetBool("FixedCheckerPositionToMeshSurface", FixedCheckerPositionToMeshSurface);
                        }
                    }
                    EditorGUILayout.EndHorizontal();


                    if (GUILayout.Button("选择网格对象"))
                    {
                        var objs = GameObject.FindObjectsOfType <Mesh>();

                        var gobjs = new List <Object>();
                        for (int i = 0; i < objs.Length; i++)
                        {
                            gobjs.Add(objs[i].gameObject);
                        }

                        Selection.objects = gobjs.ToArray();
                    }

                    if (GUILayout.Button("显示/隐藏所有标记"))
                    {
                        MeshObjectIconVisualize(!maskSwitch);
                    }


                    if (GUILayout.Button("显示/隐藏网格"))
                    {
                        Mesh tCamearMesh = null;

                        if (util.TryGetCameraMesh(out tCamearMesh))
                        {
                            MeshVisualize(!tCamearMesh.GizmosOn);
                        }
                    }

                    //if (GUILayout.Button("测试"))
                    //{
                    //    Debug.Log(GetScriptStorePath());
                    //}
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.EndVertical();
            }
        }
 private void EndSettingsBox()
 {
     EditorGUILayout.EndFadeGroup();
     EditorGUILayout.EndVertical();
 }
Beispiel #20
0
        public override void OnInspectorGUI()
        {
            foreach (Object targetTemp in targets)
            {
                serializedObject.Update();
                var trans = GetTransition(m_TransitionForImageProperty);

                EditorGUILayout.PropertyField(m_interactableProperty);
                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_curCaseProperty);
                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();

                var graphic = m_GraphicForImageProperty.objectReferenceValue as Graphic;
                if (graphic == null)
                {
                    graphic = (targetTemp as TabButton).GetComponent <Graphic>();
                }

                m_ShowColorTint.target       = (!m_TransitionForImageProperty.hasMultipleDifferentValues && trans == TabButton.TransitionType.ColorTint);
                m_ShowSpriteTrasition.target = (!m_TransitionForImageProperty.hasMultipleDifferentValues && trans == TabButton.TransitionType.SpriteSwap);

                EditorGUILayout.PropertyField(m_GraphicForImageProperty);
                switch (trans)
                {
                case TabButton.TransitionType.ColorTint:
                    if (graphic == null)
                    {
                        EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning);
                    }
                    break;

                case TabButton.TransitionType.SpriteSwap:
                    if (graphic as Image == null)
                    {
                        EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Warning);
                    }
                    break;
                }

                ++EditorGUI.indentLevel;
                {
                    EditorGUILayout.PropertyField(m_TransitionForImageProperty);


                    if (EditorGUILayout.BeginFadeGroup(m_ShowColorTint.faded))
                    {
                        EditorGUILayout.PropertyField(m_ColorBlockForImageProperty);
                    }
                    EditorGUILayout.EndFadeGroup();

                    if (EditorGUILayout.BeginFadeGroup(m_ShowSpriteTrasition.faded))
                    {
                        EditorGUILayout.PropertyField(m_SpriteStateForImageProperty);
                    }
                    EditorGUILayout.EndFadeGroup();
                }
                --EditorGUI.indentLevel;

                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_GraphicForTextProperty);
                graphic = m_GraphicForTextProperty.objectReferenceValue as Graphic;

                if (graphic == null)
                {
                    EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning);
                }
                else
                {
                    ++EditorGUI.indentLevel;
                    {
                        EditorGUILayout.PropertyField(m_ColorBlockForTextProperty);
                    } --EditorGUI.indentLevel;


                    EditorGUI.BeginChangeCheck();
                    Rect toggleRect = EditorGUILayout.GetControlRect();
                    toggleRect.xMin += EditorGUIUtility.labelWidth;
                }

                var statableCase = GetStatableCase(m_curCaseProperty);
                {
                    TabButton statableCtrl = targetTemp as TabButton;
                    if (statableCtrl != null)
                    {
                        statableCtrl.SetStatableCase(statableCase, trans);
                    }
                }

                EditorGUILayout.Space();

                // We do this here to avoid requiring the user to also write a Editor for their Selectable-derived classes.
                // This way if we are on a derived class we dont draw anything else, otherwise draw the remaining properties.
                ChildClassPropertiesGUI();

                serializedObject.ApplyModifiedProperties();
            }
        }
Beispiel #21
0
        /// <summary>
        /// Sprites's custom properties based on the type.
        /// </summary>

        protected void TypeGUI()
        {
            EditorGUILayout.PropertyField(m_Type, m_SpriteTypeContent);

            ++EditorGUI.indentLevel;
            {
                Image.Type typeEnum = (Image.Type)m_Type.enumValueIndex;

                bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == Image.Type.Sliced || typeEnum == Image.Type.Tiled));
                if (showSlicedOrTiled && targets.Length > 1)
                {
                    showSlicedOrTiled = targets.Select(obj => obj as Image).All(img => img.hasBorder);
                }

                m_ShowSlicedOrTiled.target = showSlicedOrTiled;
                m_ShowSliced.target        = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced);
                m_ShowTiled.target         = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Tiled);
                m_ShowFilled.target        = (!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Filled);

                Image image = target as Image;
                if (EditorGUILayout.BeginFadeGroup(m_ShowSlicedOrTiled.faded))
                {
                    if (image.hasBorder)
                    {
                        EditorGUILayout.PropertyField(m_FillCenter);
                    }
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_ShowSliced.faded))
                {
                    if (image.sprite != null && !image.hasBorder)
                    {
                        EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning);
                    }
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_ShowTiled.faded))
                {
                    if (image.sprite != null && !image.hasBorder && (image.sprite.texture.wrapMode != TextureWrapMode.Repeat || image.sprite.packed))
                    {
                        EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to modify the Sprite properties, clear the Packing tag and set the Wrap mode to Repeat.", MessageType.Warning);
                    }
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_ShowFilled.faded))
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(m_FillMethod);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_FillOrigin.intValue = 0;
                    }
                    switch ((Image.FillMethod)m_FillMethod.enumValueIndex)
                    {
                    case Image.FillMethod.Horizontal:
                        m_FillOrigin.intValue = (int)(Image.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginHorizontal)m_FillOrigin.intValue);
                        break;

                    case Image.FillMethod.Vertical:
                        m_FillOrigin.intValue = (int)(Image.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginVertical)m_FillOrigin.intValue);
                        break;

                    case Image.FillMethod.Radial90:
                        m_FillOrigin.intValue = (int)(Image.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin90)m_FillOrigin.intValue);
                        break;

                    case Image.FillMethod.Radial180:
                        m_FillOrigin.intValue = (int)(Image.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin180)m_FillOrigin.intValue);
                        break;

                    case Image.FillMethod.Radial360:
                        m_FillOrigin.intValue = (int)(Image.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin360)m_FillOrigin.intValue);
                        break;
                    }
                    EditorGUILayout.PropertyField(m_FillAmount);
                    if ((Image.FillMethod)m_FillMethod.enumValueIndex > Image.FillMethod.Vertical)
                    {
                        EditorGUILayout.PropertyField(m_FillClockwise, m_ClockwiseContent);
                    }
                }
                EditorGUILayout.EndFadeGroup();
            }
            --EditorGUI.indentLevel;
        }
Beispiel #22
0
    /// <summary>
    /// Shows the rigidbody editor.
    /// </summary>
    private bool ShowRigidbodyEditor()
    {
        EditorGUIUtility.labelWidth = LABEL_WIDTH;

        bool updatePhysics = false;

        GUILayout.BeginHorizontal();
        bool useRigidBody = EditorGUILayout.Toggle(new GUIContent("RigidBody:", "Enable/Disable rigidbodies for letters"), _createRigidbody.boolValue);

        if (useRigidBody != _createRigidbody.boolValue)
        {
            _createRigidbody.boolValue = useRigidBody;
            updatePhysics = true;
        }

        if (_createRigidbody.boolValue != _showRigidBody.value)
        {
            _showRigidBody.target = _createRigidbody.boolValue;
        }
        VTextEditorGUIHelper.DrawHelpButton(ref _showRigidBodyInfo);
        GUILayout.EndHorizontal();

        if (EditorGUILayout.BeginFadeGroup(_showRigidBody.faded))
        {
            EditorGUI.indentLevel++;

            // mass
            GUILayout.BeginHorizontal();
            float mass = EditorGUILayout.FloatField(new GUIContent("Mass:", "The mass of this rigidbody"), _rigidbodyMass.floatValue);
            if (mass != _rigidbodyMass.floatValue)
            {
                _rigidbodyMass.floatValue = mass;
                updatePhysics             = true;
            }
            GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH);
            GUILayout.EndHorizontal();

            // drag
            GUILayout.BeginHorizontal();
            float drag = EditorGUILayout.FloatField(new GUIContent("Drag:", "The drag amount of this rigidbody"), _rigidbodyDrag.floatValue);
            if (drag != _rigidbodyDrag.floatValue)
            {
                _rigidbodyDrag.floatValue = drag;
                updatePhysics             = true;
            }
            GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH);
            GUILayout.EndHorizontal();

            // angular drag
            GUILayout.BeginHorizontal();
            float angularDrag = EditorGUILayout.FloatField(new GUIContent("Angular drag:", "The angular drag amount of this rigidbody"), _rigidbodyAngularDrag.floatValue);
            if (angularDrag != _rigidbodyAngularDrag.floatValue)
            {
                _rigidbodyAngularDrag.floatValue = angularDrag;
                updatePhysics = true;
            }
            GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH);
            GUILayout.EndHorizontal();

            // use gravity
            GUILayout.BeginHorizontal();
            bool gravity = EditorGUILayout.Toggle(new GUIContent("Use gravity:", "Use gravity?"), _rigidbodyGravity.boolValue);
            if (gravity != _rigidbodyGravity.boolValue)
            {
                _rigidbodyGravity.boolValue = gravity;
                updatePhysics = true;
            }
            GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH);
            GUILayout.EndHorizontal();

            // is kinematic
            GUILayout.BeginHorizontal();
            bool isKinematic = EditorGUILayout.Toggle(new GUIContent("Is kinematic:", "Is this rigidbody kinematic?"), _rigidbodyIsKinematic.boolValue);
            if (isKinematic != _rigidbodyIsKinematic.boolValue)
            {
                _rigidbodyIsKinematic.boolValue = isKinematic;
                updatePhysics = true;
            }
            GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH);
            GUILayout.EndHorizontal();

            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndFadeGroup();

        if (EditorGUILayout.BeginFadeGroup(_showRigidBodyInfo.faded))
        {
            string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("RigidBody:") + "\n\n" +
                         "This allows you to automatically add rigidbodies to each letter of the text. You can apply the most common parameters of Unity's rigidbodies as " +
                         "there are: \n\n" +
                         VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Mass: ") + "The mass of the rigidbody.\n\n" +
                         VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Drag: ") + "The drag amount of the rigidbody.\n\n" +
                         VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Angular drag: ") + "The angular drag amount of the rigidbody.\n\n" +
                         VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Use gravity: ") + "Determines if gravity should be applied to the letter.\n\n" +
                         VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Is kinematic: ") + "Controls whether physics affects the rigidbody or not. " +
                         "If this value is set to <b>true</b> then <b>no</b> physics are applied to the letter.";

            DrawHelpWindow(_rigidBodyInfoHelpImage, txt, ref _rigidBodyInfoHelpTextScrollPosition, ref _showRigidBodyInfo);
        }
        EditorGUILayout.EndFadeGroup();
        return(updatePhysics);
    }
Beispiel #23
0
        private void Initialise()
        {
            rootState = new StateMachineBuilder()
                        .State("Select")
                        .Enter(evt => selectedToolIndex = 0)
                        .Update((state, dt) =>
            {
                EditorUtilities.ShowHelpBox("Select", "Pick a hex tile to manually edit its properties.");

                HexTileData currentTile;
                if (hexMap.SelectedTile != null && hexMap.TryGetTile(hexMap.SelectedTile, out currentTile))
                {
                    // Tile info
                    GUILayout.Label("Tile position", EditorStyles.boldLabel);

                    EditorUtilities.ShowReadonlyIntField("Column", hexMap.SelectedTile.Q);
                    EditorUtilities.ShowReadonlyIntField("Row", hexMap.SelectedTile.R);
                    EditorUtilities.ShowReadonlyFloatField("Elevation", currentTile.Position.Elevation);

                    // Tile settings
                    GUILayout.Label("Settings", EditorStyles.boldLabel);

                    var currentMaterial = currentTile.Material;
                    var newMaterial     = (Material)EditorGUILayout.ObjectField("Material", currentMaterial, typeof(Material), false);
                    if (currentMaterial != newMaterial)
                    {
                        hexMap.ReplaceMaterialOnTile(currentTile.Position.Coordinates, newMaterial);
                        MarkSceneDirty();
                    }
                }
            })
                        .Event <SceneClickedEventArgs>("SceneClicked", (state, eventArgs) =>
            {
                if (eventArgs.Button == 0)
                {
                    var tile = TryFindTileForMousePosition(eventArgs.Position);
                    if (tile != null)
                    {
                        hexMap.SelectedTile = tile.Coordinates;
                    }
                }
            })
                        .End()
                        .State <PaintState>("Paint tiles")
                        .Enter(state =>
            {
                selectedToolIndex = 1;
            })
                        .Update((state, dt) =>
            {
                EditorUtilities.ShowHelpBox("Paint tiles", "Click and drag to add hex tiles at the specified height.");

                bool sceneNeedsRepaint = false;

                var newBrushSize = EditorGUILayout.IntSlider("Brush size", brushSize, 1, 10);
                if (newBrushSize != brushSize)
                {
                    brushSize = newBrushSize;

                    sceneNeedsRepaint = true;
                }

                var paintHeight = EditorGUILayout.FloatField("Paint height", state.PaintHeight);
                if (paintHeight != state.PaintHeight)
                {
                    state.PaintHeight = paintHeight;
                    foreach (var tile in highlightedTiles)
                    {
                        tile.Elevation = paintHeight;
                    }

                    sceneNeedsRepaint = true;
                }

                var paintOffsetHeight = EditorGUILayout.FloatField("Height offset", state.PaintOffset);
                if (paintOffsetHeight != state.PaintOffset)
                {
                    state.PaintOffset = paintOffsetHeight;
                    foreach (var tile in nextTilePositions)
                    {
                        tile.Elevation = paintHeight + paintOffsetHeight;
                    }

                    sceneNeedsRepaint = true;
                }

                hexMap.CurrentMaterial = (Material)EditorGUILayout.ObjectField("Material", hexMap.CurrentMaterial, typeof(Material), false);

                if (sceneNeedsRepaint)
                {
                    if (centerSelectedTileCoords != null)
                    {
                        UpdateHighlightedTiles(centerSelectedTileCoords.CoordinateRange(brushSize - 1), state.PaintHeight, state.PaintOffset);
                    }
                    SceneView.RepaintAll();
                }
            })
                        .Event("MouseMove", state =>
            {
                var highlightedPosition = EditorUtilities.GetWorldPositionForMouse(Event.current.mousePosition, state.PaintHeight);
                if (highlightedPosition != null)
                {
                    centerSelectedTileCoords = hexMap.QuantizeVector3ToHexCoords(highlightedPosition.GetValueOrDefault());

                    UpdateHighlightedTiles(centerSelectedTileCoords.CoordinateRange(brushSize - 1), state.PaintHeight, state.PaintOffset);
                }
                Event.current.Use();
            })
                        .Event <SceneClickedEventArgs>("SceneClicked", (state, eventArgs) =>
            {
                if (eventArgs.Button == 0)
                {
                    var position = EditorUtilities.GetWorldPositionForMouse(eventArgs.Position, state.PaintHeight);
                    if (position != null)
                    {
                        // Select the tile that was clicked on.
                        centerSelectedTileCoords = hexMap.QuantizeVector3ToHexCoords(position.GetValueOrDefault());
                        var coords = centerSelectedTileCoords.CoordinateRange(brushSize - 1);

                        foreach (var hex in coords)
                        {
                            // Keep track of which chunks we've modified so that
                            // we only record undo actions for each once.
                            var oldChunk = hexMap.FindChunkForCoordinates(hex);
                            if (oldChunk != null && !state.ModifiedChunks.Contains(oldChunk))
                            {
                                RecordChunkModifiedUndo(oldChunk);
                                state.ModifiedChunks.Add(oldChunk);
                            }

                            var newChunk = hexMap.FindChunkForCoordinatesAndMaterial(hex, hexMap.CurrentMaterial);
                            if (newChunk != null && newChunk != oldChunk && !state.ModifiedChunks.Contains(newChunk))
                            {
                                RecordChunkModifiedUndo(newChunk);
                                state.ModifiedChunks.Add(newChunk);
                            }

                            // TODO: add feature for disabling wireframe again.
                            var paintHeight = state.PaintHeight + state.PaintOffset;

                            var action = hexMap.CreateAndAddTile(
                                new HexPosition(hex, paintHeight),
                                hexMap.CurrentMaterial);

                            if (action.Operation == ModifiedTileInfo.ChunkOperation.Added)
                            {
                                RecordChunkAddedUndo(action.Chunk);
                            }
                        }

                        hexMap.SelectedTile = centerSelectedTileCoords;

                        MarkSceneDirty();
                    }
                }
            })
                        .Event("MouseUp", state =>
            {
                // Flush list of modified chunks so that they are not included in
                // the next undo action.
                state.ModifiedChunks.Clear();
            })
                        .Exit(state =>
            {
                highlightedTiles  = Enumerable.Empty <HexPosition>();
                nextTilePositions = Enumerable.Empty <HexPosition>();

                hexMap.NextTilePositions = null;
            })
                        .End()
                        .State <ChunkEditingState>("Material paint")
                        .Enter(state =>
            {
                selectedToolIndex = 2;
            })
                        .Update((state, dt) =>
            {
                bool sceneNeedsRepaint = false;

                EditorUtilities.ShowHelpBox("Material paint", "Paint over existing tiles to change their material.");

                var newBrushSize = EditorGUILayout.IntSlider("Brush size", brushSize, 1, 10);
                if (newBrushSize != brushSize)
                {
                    brushSize = newBrushSize;

                    sceneNeedsRepaint = true;
                }

                hexMap.CurrentMaterial = (Material)EditorGUILayout.ObjectField("Material", hexMap.CurrentMaterial, typeof(Material), false);

                EditorGUILayout.Space();

                if (GUILayout.Button("Apply to all tiles"))
                {
                    ApplyCurrentMaterialToAllTiles();
                    MarkSceneDirty();

                    sceneNeedsRepaint = true;
                }

                if (sceneNeedsRepaint)
                {
                    SceneView.RepaintAll();
                }
            })
                        .Event("MouseMove", state =>
            {
                HighlightTilesUnderMousePosition();

                Event.current.Use();
            })
                        .Event <SceneClickedEventArgs>("SceneClicked", (state, eventArgs) =>
            {
                if (eventArgs.Button == 0)
                {
                    var tilePosition = TryFindTileForMousePosition(eventArgs.Position);
                    if (tilePosition != null && hexMap.ContainsTile(tilePosition.Coordinates))
                    {
                        // Select that the tile that was clicked on.
                        hexMap.SelectedTile = tilePosition.Coordinates;

                        // Change the material on the tile
                        var tilesUnderBrush = tilePosition.Coordinates.CoordinateRange(brushSize - 1)
                                              .Where(coords => hexMap.ContainsTile(coords));
                        foreach (var coords in tilesUnderBrush)
                        {
                            ReplaceMaterialOnTile(coords, state.ModifiedChunks);
                        }
                    }

                    Event.current.Use();
                }
            })
                        .Event("MouseUp", state =>
            {
                // Flush list of modified chunks so that they are not included in
                // the next undo action.
                state.ModifiedChunks.Clear();
            })
                        .End()
                        .State <ChunkEditingState>("Erase")
                        .Enter(evt => selectedToolIndex = 3)
                        .Update((state, dt) =>
            {
                EditorUtilities.ShowHelpBox("Erase", "Click and drag on existing hex tiles to remove them.");

                var newBrushSize = EditorGUILayout.IntSlider("Brush size", brushSize, 1, 10);
                if (newBrushSize != brushSize)
                {
                    brushSize = newBrushSize;

                    SceneView.RepaintAll();
                }
            })
                        .Event("MouseMove", state =>
            {
                HighlightTilesUnderMousePosition();

                Event.current.Use();
            })
                        .Event <SceneClickedEventArgs>("SceneClicked", (state, eventArgs) =>
            {
                if (eventArgs.Button == 0)
                {
                    bool removedTile = false;

                    var centerTile = TryFindTileForMousePosition(eventArgs.Position);
                    if (centerTile != null)
                    {
                        foreach (var tile in centerTile.Coordinates.CoordinateRange(brushSize - 1))
                        {
                            var chunk = hexMap.FindChunkForCoordinates(tile);
                            if (chunk != null && !state.ModifiedChunks.Contains(chunk))
                            {
                                RecordChunkModifiedUndo(chunk);
                                state.ModifiedChunks.Add(chunk);
                            }

                            // Destroy tile
                            removedTile |= hexMap.TryRemovingTile(tile);
                        }
                    }

                    if (removedTile)
                    {
                        MarkSceneDirty();
                    }
                }
            })
                        .Event("MouseUp", state =>
            {
                // Flush list of modified chunks so that they are not included in
                // the next undo action.
                state.ModifiedChunks.Clear();
            })
                        .End()
                        .State <SettingsState>("Settings")
                        .Enter(state =>
            {
                selectedToolIndex = 4;
                state.HexSize     = hexMap.tileDiameter;
                state.ChunkSize   = hexMap.ChunkSize;

                showTileCoordinateFormat.value = hexMap.DrawHexPositionHandles;
            })
                        .Update((state, dt) =>
            {
                EditorUtilities.ShowHelpBox("Settings", "Configure options for the whole tile map.");

                var shouldDrawPositionHandles = EditorGUILayout.Toggle("Show tile positions", hexMap.DrawHexPositionHandles);
                if (shouldDrawPositionHandles != hexMap.DrawHexPositionHandles)
                {
                    hexMap.DrawHexPositionHandles = shouldDrawPositionHandles;
                    SceneView.RepaintAll();
                    MarkSceneDirty();

                    showTileCoordinateFormat.target = shouldDrawPositionHandles;
                }

                if (EditorGUILayout.BeginFadeGroup(showTileCoordinateFormat.faded))
                {
                    var newHandleFormat = (HexTileMap.HexCoordinateFormat)
                                          EditorGUILayout.EnumPopup("Tile coordinate format", hexMap.HexPositionHandleFormat);
                    if (newHandleFormat != hexMap.HexPositionHandleFormat)
                    {
                        hexMap.HexPositionHandleFormat = newHandleFormat;
                        SceneView.RepaintAll();
                    }
                }
                EditorGUILayout.EndFadeGroup();

                state.HexSize = EditorGUILayout.FloatField("Tile size", state.HexSize);
                if (state.HexSize != hexMap.tileDiameter)
                {
                    state.Dirty = true;
                }

                var newChunkSize = EditorGUILayout.IntField("Chunk size", state.ChunkSize);
                if (state.ChunkSize != newChunkSize)
                {
                    state.ChunkSize = newChunkSize;
                    state.Dirty     = true;
                }

                if (GUILayout.Button("Re-generate all tile geometry"))
                {
                    hexMap.RegenerateAllTiles();
                    MarkSceneDirty();
                }

                if (GUILayout.Button("Clear all tiles"))
                {
                    if (EditorUtility.DisplayDialog("Clear all tiles",
                                                    "Are you sure you want to delete all tiles in this hex tile map?",
                                                    "Clear",
                                                    "Cancel"))
                    {
                        hexMap.ClearAllTiles();
                        MarkSceneDirty();
                    }
                }

                EditorGUILayout.Space();

                GUI.enabled = state.Dirty;
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Apply", GUILayout.Width(160)))
                {
                    Debug.Log("Saving settings");
                    hexMap.tileDiameter = state.HexSize;
                    hexMap.ChunkSize    = state.ChunkSize;
                    hexMap.RegenerateAllTiles();
                    MarkSceneDirty();

                    state.Dirty = false;
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;
            })
                        .End()
                        .Build();

            rootState.ChangeState("Select");

            if (EditorGUIUtility.isProSkin)
            {
                toolIcons = new ButtonIcon[] {
                    new ButtonIcon {
                        NormalIcon = LoadImage("mouse-pointer_44_pro"), SelectedIcon = LoadImage("mouse-pointer_44_selected")
                    },
                    new ButtonIcon {
                        NormalIcon = LoadImage("add-hex_44_pro"), SelectedIcon = LoadImage("add-hex_44_selected")
                    },
                    new ButtonIcon {
                        NormalIcon = LoadImage("paint-brush_44_pro"), SelectedIcon = LoadImage("paint-brush_44_selected")
                    },
                    new ButtonIcon {
                        NormalIcon = LoadImage("eraser_44_pro"), SelectedIcon = LoadImage("eraser_44_selected")
                    },
                    new ButtonIcon {
                        NormalIcon = LoadImage("cog_44_pro"), SelectedIcon = LoadImage("cog_44_selected")
                    },
                };
            }
            else
            {
                toolIcons = new ButtonIcon[] {
                    new ButtonIcon {
                        NormalIcon = LoadImage("mouse-pointer_44"), SelectedIcon = LoadImage("mouse-pointer_44_selected")
                    },
                    new ButtonIcon {
                        NormalIcon = LoadImage("add-hex_44"), SelectedIcon = LoadImage("add-hex_44_selected")
                    },
                    new ButtonIcon {
                        NormalIcon = LoadImage("paint-brush_44"), SelectedIcon = LoadImage("paint-brush_44_selected")
                    },
                    new ButtonIcon {
                        NormalIcon = LoadImage("eraser_44"), SelectedIcon = LoadImage("eraser_44_selected")
                    },
                    new ButtonIcon {
                        NormalIcon = LoadImage("cog_44"), SelectedIcon = LoadImage("cog_44_selected")
                    },
                };
            }
        }
Beispiel #24
0
    /// <summary>
    /// Shows the collider editor.
    /// </summary>
    private bool ShowColliderEditor()
    {
        bool updatePhysics = false;

        EditorGUILayout.BeginHorizontal();
        int colliderTypeID = (int)(VTextPhysics.ColliderType)EditorGUILayout.EnumPopup(new GUIContent("Collider type:", "The type of the collider added to each letter"),
                                                                                       (VTextPhysics.ColliderType)System.Enum.GetValues(typeof(VTextPhysics.ColliderType)).GetValue(_colliderType.enumValueIndex));

        if (_colliderType.enumValueIndex != colliderTypeID)
        {
            _colliderType.enumValueIndex = colliderTypeID;
            updatePhysics |= true;
        }

        if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex != VTextPhysics.ColliderType.None && _showCollider.value == false)
        {
            _showCollider.target = true;
        }
        else if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex == VTextPhysics.ColliderType.None && _showCollider.value == true)
        {
            _showCollider.target = false;
        }

        VTextEditorGUIHelper.DrawHelpButton(ref _showColliderInfo);
        EditorGUILayout.EndHorizontal();

        if (EditorGUILayout.BeginFadeGroup(_showCollider.faded))
        {
            EditorGUI.indentLevel++;

            if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex == VTextPhysics.ColliderType.Box)
            {
                updatePhysics |= ShowBoxColliderParameters();
            }
            else if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex == VTextPhysics.ColliderType.Mesh)
            {
                updatePhysics |= ShowMeshColliderParameters();
            }

            // physics material ... this will work for all colliders
            if ((VTextPhysics.ColliderType)_colliderType.enumValueIndex != VTextPhysics.ColliderType.None)
            {
                GUILayout.BeginHorizontal();
                PhysicMaterial colMat = EditorGUILayout.ObjectField("Physic material:", _colliderMaterial.objectReferenceValue, typeof(PhysicMaterial), false) as PhysicMaterial;
                if (colMat != _colliderMaterial.objectReferenceValue)
                {
                    _colliderMaterial.objectReferenceValue = colMat;
                    updatePhysics |= true;
                }
                GUILayout.Space(VTextEditorGUIHelper.HELP_BUTTON_WIDTH);
                GUILayout.EndHorizontal();
            }

            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndFadeGroup();

        if (EditorGUILayout.BeginFadeGroup(_showColliderInfo.faded))
        {
            string txt = VTextEditorGUIHelper.ConvertStringToHelpWindowHeader("Collider:") + "\n\n" +
                         "Here you can specify a collider for each letter of your text. Actually the following types are supported:\n\n" +
                         VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("None: ") + "Don't add a collider at all.\n\n" +
                         VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Box: ") + "Add a box collider to each letter. You can specify the <b>IsTrigger</b> " +
                         "property of it. A trigger doesn't register a collision with an incoming Rigidbody. Instead, it sends OnTriggerEnter, OnTriggerExit and " +
                         "OnTriggerStay message when a rigidbody enters or exits the trigger volume.\n\n" +
                         VTextEditorGUIHelper.ConvertStringToHelpWindowListItem("Mesh: ") + "Add a mesh collider to each letter. Here you can specify if it is " +
                         "<b>convex</b> or not. You can see convex mesh colliders as simplified colliders without holes or entrances. If (<b>and only if</b>) you " +
                         "define the mesh collider to be convex then you can set its <b>IsTrigger</b> property as well. A trigger doesn't register a collision with " +
                         "an incoming Rigidbody. Instead, it sends OnTriggerEnter, OnTriggerExit and OnTriggerStay message when a rigidbody enters or exits the " +
                         "trigger volume. \n\n" +
                         "If you have defined a collider you can also set the colliders <b>physics material</b> to change its physics behaviour.";

            DrawHelpWindow(_colliderInfoHelpImage, txt, ref _colliderInfoHelpTextScrollPosition, ref _showColliderInfo);
        }
        EditorGUILayout.EndFadeGroup();

        return(updatePhysics);
    }
Beispiel #25
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        MonoBehaviourAdapter.Adaptor clr = target as MonoBehaviourAdapter.Adaptor;
        var instance = clr.ILInstance;

        if (instance != null)
        {
            EditorGUILayout.LabelField("Script", clr.ILInstance.Type.Name);

            //如果JBehaviour
            var JBehaviourType = Init.appdomain.LoadedTypes["JEngine.Core.JBehaviour"];
            var t = instance.Type.ReflectionType;
            if (t.IsSubclassOf(JBehaviourType.ReflectionType))
            {
                var f  = t.GetField("_instanceID", BindingFlags.NonPublic);
                var id = f.GetValue(instance).ToString();
                EditorGUILayout.TextField("InstanceID", id);

                this.fadeGroup[0].target = EditorGUILayout.Foldout(this.fadeGroup[0].target,
                                                                   "JBehaviour Stats", true);
                if (EditorGUILayout.BeginFadeGroup(this.fadeGroup[0].faded))
                {
                    var  fm        = t.GetField("FrameMode", BindingFlags.Public);
                    bool frameMode = EditorGUILayout.Toggle("FrameMode", (bool)fm.GetValue(instance));
                    fm.SetValue(instance, frameMode);

                    var fq        = t.GetField("Frequency", BindingFlags.Public);
                    int frequency = EditorGUILayout.IntField("Frequency", (int)fq.GetValue(instance));
                    fq.SetValue(instance, frequency);

                    GUI.enabled = false;

                    var paused = t.GetField("Paused", BindingFlags.NonPublic);
                    EditorGUILayout.Toggle("Paused", (bool)paused.GetValue(instance));

                    var totalTime = t.GetField("TotalTime", BindingFlags.Public);
                    EditorGUILayout.FloatField("TotalTime", (float)totalTime.GetValue(instance));

                    var loopDeltaTime = t.GetField("LoopDeltaTime", BindingFlags.Public);
                    EditorGUILayout.FloatField("LoopDeltaTime", (float)loopDeltaTime.GetValue(instance));

                    var loopCounts = t.GetField("LoopCounts", BindingFlags.Public);
                    EditorGUILayout.LongField("LoopCounts", (long)loopCounts.GetValue(instance));

                    GUI.enabled = true;

                    var timeScale = t.GetField("TimeScale", BindingFlags.Public);
                    var ts        = EditorGUILayout.FloatField("TimeScale", (float)timeScale.GetValue(instance));
                    timeScale.SetValue(instance, ts);
                }

                EditorGUILayout.EndFadeGroup();

                if (instance.Type.FieldMapping.Count > 0)
                {
                    EditorGUILayout.Space(10);
                    EditorGUILayout.HelpBox($"{t.Name} variables", MessageType.Info);
                }
            }

            int index = 0;
            foreach (var i in instance.Type.FieldMapping)
            {
                //这里是取的所有字段,没有处理不是public的
                var name = i.Key;
                var type = instance.Type.FieldTypes[index];
                index++;

                var    cType = type.TypeForCLR;
                object obj   = instance[i.Value];
                if (cType.IsPrimitive) //如果是基础类型
                {
                    GUI.enabled = true;
                    try
                    {
                        if (cType == typeof(float))
                        {
                            instance[i.Value] = EditorGUILayout.FloatField(name, (float)instance[i.Value]);
                        }
                        else if (cType == typeof(double))
                        {
                            instance[i.Value] = EditorGUILayout.DoubleField(name, (float)instance[i.Value]);
                        }
                        else if (cType == typeof(int))
                        {
                            instance[i.Value] = EditorGUILayout.IntField(name, (int)instance[i.Value]);
                        }
                        else if (cType == typeof(long))
                        {
                            instance[i.Value] = EditorGUILayout.LongField(name, (long)instance[i.Value]);
                        }
                        else if (cType == typeof(bool))
                        {
                            var result = bool.TryParse(instance[i.Value].ToString(), out var value);
                            if (!result)
                            {
                                value = instance[i.Value].ToString() == "1";
                            }

                            instance[i.Value] = EditorGUILayout.Toggle(name, value);
                        }
                        else
                        {
                            EditorGUILayout.LabelField(name, instance[i.Value].ToString());
                        }
                    }
                    catch (Exception e)
                    {
                        Log.PrintError($"无法序列化{name},{e.Message}");
                        EditorGUILayout.LabelField(name, instance[i.Value].ToString());
                    }
                }
                else
                {
                    if (cType == typeof(string))
                    {
                        if (obj != null)
                        {
                            instance[i.Value] = EditorGUILayout.TextField(name, (string)instance[i.Value]);
                        }
                        else
                        {
                            instance[i.Value] = EditorGUILayout.TextField(name, "");
                        }
                    }
                    else if (cType == typeof(JsonData)) //可以折叠显示Json数据
                    {
                        if (instance[i.Value] != null)
                        {
                            this.fadeGroup[1].target = EditorGUILayout.Foldout(this.fadeGroup[1].target, name, true);
                            if (EditorGUILayout.BeginFadeGroup(this.fadeGroup[1].faded))
                            {
                                instance[i.Value] = EditorGUILayout.TextArea(
                                    ((JsonData)instance[i.Value]).ToString()
                                    );
                            }

                            EditorGUILayout.EndFadeGroup();
                            EditorGUILayout.Space();
                        }
                        else
                        {
                            EditorGUILayout.LabelField(name, "暂无值的JsonData");
                        }
                    }
                    else if (typeof(UnityEngine.Object).IsAssignableFrom(cType))
                    {
                        if (obj == null && cType.GetInterfaces().Contains(typeof(CrossBindingAdaptorType)))
                        {
                            EditorGUILayout.LabelField(name, "未赋值的热更类");
                            break;
                        }

                        if (cType.GetInterfaces().Contains(typeof(CrossBindingAdaptorType)))
                        {
                            try
                            {
                                var clrInstance = (MonoBehaviour)Tools.FindObjectsOfTypeAll <CrossBindingAdaptorType>()
                                                  .Find(adaptor =>
                                                        adaptor.ILInstance == instance[i.Value]);
                                GUI.enabled = true;
                                EditorGUILayout.ObjectField(name, clrInstance, cType, true);
                                GUI.enabled = false;
                            }
                            catch
                            {
                                EditorGUILayout.LabelField(name, "未赋值的热更类");
                            }

                            break;
                        }

                        //处理Unity类型
                        var res = EditorGUILayout.ObjectField(name, obj as UnityEngine.Object, cType, true);
                        instance[i.Value] = res;
                    }
                    //可绑定值,可以尝试更改
                    else if (type.ReflectionType.ToString().Contains("BindableProperty") && obj != null)
                    {
                        PropertyInfo fi  = type.ReflectionType.GetProperty("Value");
                        object       val = fi.GetValue(obj);

                        string genericTypeStr = type.ReflectionType.ToString().Split('`')[1].Replace("1<", "")
                                                .Replace(">", "");
                        Type genericType = Type.GetType(genericTypeStr);
                        if (genericType == null ||
                            (!genericType.IsPrimitive && genericType != typeof(string))) //不是基础类型或字符串
                        {
                            EditorGUILayout.LabelField(name, val.ToString());            //只显示字符串
                        }
                        else
                        {
                            //可更改
                            var data = Tools.ConvertSimpleType(EditorGUILayout.TextField(name, val.ToString()),
                                                               genericType);
                            if (data != null) //尝试更改
                            {
                                fi.SetValue(obj, data);
                            }
                        }
                    }
                    else
                    {
                        //其他类型现在没法处理
                        if (obj != null)
                        {
                            if (cType.GetInterfaces().Contains(typeof(CrossBindingAdaptorType))) //需要跨域继承的普遍都有适配器
                            {
                                var clrInstance = (MonoBehaviour)Tools.FindObjectsOfTypeAll <CrossBindingAdaptorType>()
                                                  .Find(adaptor =>
                                                        adaptor.ILInstance.Equals(instance[i.Value]));
                                if (clrInstance != null)
                                {
                                    GUI.enabled = true;
                                    EditorGUILayout.ObjectField(name, clrInstance.gameObject, typeof(GameObject), true);
                                    GUI.enabled = false;
                                }
                            }
                            else //不需要跨域继承的,也有可能以ClassBind挂载
                            {
                                var clrInstance = Tools.FindObjectsOfTypeAll <MonoBehaviourAdapter.Adaptor>()
                                                  .Find(adaptor =>
                                                        adaptor.ILInstance.Equals(instance[i.Value]));
                                if (clrInstance != null)
                                {
                                    GUI.enabled = true;
                                    EditorGUILayout.ObjectField(name, clrInstance, typeof(MonoBehaviourAdapter.Adaptor),
                                                                true);
                                    GUI.enabled = false;
                                }
                                else
                                {
                                    EditorGUILayout.LabelField(name, obj.ToString());
                                }
                            }
                        }
                        else
                        {
                            EditorGUILayout.LabelField(name, "(null)");
                        }
                    }
                }
            }
        }

        // 应用属性修改
        this.serializedObject.ApplyModifiedProperties();
    }
Beispiel #26
0
    //自定义检视面板
    public override void OnInspectorGUI()
    {
        EditorGUILayout.HelpBox("检查区域可以检查拖入的物品或者道具物价是否符合要求,符合要求的话则执行状态列表中对应的动作。", MessageType.Info);
        element.Update();

        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("触发检查的方式: ", GUILayout.MaxWidth(100));
        EditorGUILayout.PropertyField(element.FindProperty("checkType"), pointContent, GUILayout.MaxWidth(80));
        EditorGUILayout.EndHorizontal();

        if (element.FindProperty("checkType").enumValueIndex == 0)
        {
            EditorGUILayout.HelpBox("松手时触发检查", MessageType.None);
        }
        else if (element.FindProperty("checkType").enumValueIndex == 1)
        {
            EditorGUILayout.HelpBox("拖动到区域时检查", MessageType.None);
        }
        else if (element.FindProperty("checkType").enumValueIndex == 2)
        {
            EditorGUILayout.HelpBox("不检查", MessageType.None);
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("触发后隐藏道具: ", GUILayout.MaxWidth(100));
        EditorGUILayout.PropertyField(element.FindProperty("ishideitem"), pointContent, GUILayout.MaxWidth(80));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
        EditorGUILayout.Space();

        //状态列表标题
        GUILayout.Label("状态列表: ", EditorStyles.largeLabel);

        //状态列表内容
        for (int i = 0; i < dolist.arraySize; i++)
        {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.BeginHorizontal();
            SerializedProperty statedo = dolist.GetArrayElementAtIndex(i);
            GUILayout.Label("  状态ID");
            EditorGUILayout.PropertyField(statedo.FindPropertyRelative("StateID"), pointContent, GUILayout.MaxWidth(80));
            GUILayout.Label("  检查物件");
            EditorGUILayout.PropertyField(statedo.FindPropertyRelative("DragName"), pointContent);
            GUILayout.Label("  执行命令");
            EditorGUILayout.PropertyField(statedo.FindPropertyRelative("NextDo"), pointContent);
            if (statedo.FindPropertyRelative("NextDo").enumValueIndex == 2)
            {
                EditorGUILayout.PropertyField(element.FindProperty("jumpnum"), pointContent, GUILayout.Width(50));
                EditorGUILayout.Space();
            }
            else if (statedo.FindPropertyRelative("NextDo").enumValueIndex == 3)
            {
                EditorGUILayout.PropertyField(element.FindProperty("sceneName"), pointContent, GUILayout.Width(50));
                EditorGUILayout.Space();
            }

            if (GUILayout.Button(deleteContent, EditorStyles.miniButton, buttonWidth))
            {
                dolist.DeleteArrayElementAtIndex(i);
                SaveProperties();
                ChangeshowActionList();
                return;
            }
            EditorGUILayout.EndHorizontal();

            //状态列表内的动画列表
            EditorGUI.indentLevel = 1;
            SerializedProperty actinlist           = statedo.FindPropertyRelative("ActionList");
            SerializedProperty animatorlist        = statedo.FindPropertyRelative("AnimatorList");
            SerializedProperty animationActionlist = statedo.FindPropertyRelative("AnimationAction");
            if (animatorlist.arraySize != actinlist.arraySize)
            {
                animatorlist.arraySize = actinlist.arraySize;
            }
            if (animationActionlist.arraySize != actinlist.arraySize)
            {
                animationActionlist.arraySize = actinlist.arraySize;
            }

            showActionList[i] = EditorGUILayout.Foldout(showActionList[i], "  动画列表: " + actinlist.arraySize + "个", true);
            if (showActionList[i])
            {
                for (int j = 0; j < actinlist.arraySize; j++)
                {
                    EditorGUILayout.BeginHorizontal();
                    //动画控制器
                    SerializedProperty animator = animatorlist.GetArrayElementAtIndex(j);
                    EditorGUILayout.PropertyField(animator, pointContent);

                    //动画clip
                    SerializedProperty clip = actinlist.GetArrayElementAtIndex(j);
                    EditorGUILayout.PropertyField(clip, pointContent);

                    //播放方式
                    SerializedProperty animationtype = animationActionlist.GetArrayElementAtIndex(j);
                    if (animationtype != null)
                    {
                        EditorGUILayout.PropertyField(animationtype, pointContent, GUILayout.Width(70f));
                    }

                    if (GUILayout.Button(deleteAniContent, EditorStyles.miniButton, GUILayout.Width(20f)))
                    {
                        if (actinlist.GetArrayElementAtIndex(j).objectReferenceValue != null)
                        {
                            actinlist.DeleteArrayElementAtIndex(j);
                        }
                        actinlist.DeleteArrayElementAtIndex(j);
                        if (animatorlist.GetArrayElementAtIndex(j).objectReferenceValue != null)
                        {
                            animatorlist.DeleteArrayElementAtIndex(j);
                        }
                        animatorlist.DeleteArrayElementAtIndex(j);
                        animationActionlist.DeleteArrayElementAtIndex(j);
                        SaveProperties();
                        return;
                    }
                    EditorGUILayout.EndHorizontal();
                    //动画归纳成组的判断
                    if (animationtype != null && animationtype.enumValueIndex == 1)
                    {
                        EditorGUILayout.HelpBox("-----上面的动画播放完后在播放之后的动画------", MessageType.None);
                    }
                    ////检查是否出错
                    //if (clip.objectReferenceValue != null)
                    //{
                    //    string rootname = clip.objectReferenceValue.name.Split('_')[0];
                    //    GetAnimator(rootname);
                    //}
                }
                //添加动画按钮
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("");
                if (GUILayout.Button(insertAniContent, EditorStyles.miniButton, GUILayout.MinWidth(80f), GUILayout.MaxWidth(200f)))
                {
                    actinlist.InsertArrayElementAtIndex(actinlist.arraySize);
                    animatorlist.InsertArrayElementAtIndex(animatorlist.arraySize);
                    animationActionlist.InsertArrayElementAtIndex(animationActionlist.arraySize);
                    SaveProperties();
                    return;
                }
                GUILayout.Label("");
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndFadeGroup();
            }

            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.Space();
        if (GUILayout.Button(insertContent))
        {
            dolist.InsertArrayElementAtIndex(dolist.arraySize);
            SaveProperties();
            ChangeshowActionList();
            return;
        }
        SaveProperties();
    }
Beispiel #27
0
        /// <summary>
        /// All drawing logic is placed inside of this method.
        /// </summary>
        public virtual void OnWidgetGUI(ScriptForgeStyles style)
        {
            GUI.backgroundColor = m_BackgroundColor;
            Rect headerRect = EditorGUILayout.BeginVertical(GUI.skin.box);

            {
                GUILayout.BeginHorizontal();
                {
                    OnTitleBarGUI(style);
                }
                GUILayout.EndHorizontal();

                headerRect.height = 30f;

                if (Event.current.type == EventType.MouseDown && headerRect.Contains(Event.current.mousePosition))
                {
                    // They left clicked.
                    if (Event.current.button == 0)
                    {
                        FlashColor(Color.gray, 0.25f);
                        m_IsOpen = !m_IsOpen;
                        GUIUtility.hotControl      = -1;
                        GUIUtility.keyboardControl = -1;
                    }
                    // They right clicked.
                    else if (Event.current.button == 1)
                    {
                        // Create our menu.
                        GenericMenu menu = new GenericMenu();
                        // Populate it
                        OnGenerateContexMenu(menu);
                        // Check if we have any elements
                        if (menu.GetItemCount() > 0)
                        {
                            // Show it.
                            menu.DropDown(headerRect);
                        }
                    }
                }

                // As long as our animation is playing we
                // want to force a repaint.
                if (m_OpenAnimation.isAnimating)
                {
                    m_ScriptableForge.Repaint();
                }

                if (EditorGUILayout.BeginFadeGroup(m_OpenAnimation.faded))
                {
                    GUILayout.Box(GUIContent.none, style.spacer);
                    if (m_ErrorCode != ScriptForgeErrors.Codes.None)
                    {
                        EditorGUILayout.HelpBox(m_ErrorMessage, MessageType.Error);
                    }
                    EditorGUI.BeginChangeCheck();
                    {
                        DrawWidgetContent(style);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        OnContentChanged();
                    }
                    GUILayout.Box(GUIContent.none, style.spacer);
                    DrawWidgetFooter(style);
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.EndVertical();

            if (m_ScriptableForge.animateWidgets)
            {
                m_OpenAnimation.target = m_IsOpen;
            }
            else
            {
                m_OpenAnimation.value = m_IsOpen;
            }

            GUI.backgroundColor = Color.white;
        }
        private Vector2 m_ScrollPosition4; //滚动视图4

        /// <summary>
        /// 面板GUI
        /// 这里兼容多语言,用的笨方法,以后会改善
        /// </summary>
        void OnGUI()
        {
            //GUI样式
            GUIStyle header = new GUIStyle();

            header.fontSize         = 20;
            header.normal.textColor = Color.white;

            GUIStyle body = new GUIStyle();

            body.fontSize         = 13;
            body.normal.textColor = Color.red;
            GUILayout.BeginVertical();
            EditorStyles.textArea.wordWrap = true;

            if (Language == Language.中文)
            {
                //全部Key区域
                GUILayout.BeginArea(new Rect(25, 10, this.position.width / 3, this.position.height - 10));

                EditorGUILayout.LabelField("Db" + SQL_DB + "中的Keys", header);
                GUILayout.Space(5);
                EditorGUILayout.LabelField("共" + Keys.Count + "Keys", body);
                if (GUILayout.Button("新增"))
                {
                    CurrentValue = "";
                    CurrentKey   = "";
                    SelectedKey  = "";
                    this.Repaint();
                }
                GUILayout.Space(10);

                m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
                foreach (var key in Keys)
                {
                    if (GUILayout.Button(key))
                    {
                        GetValue(key);
                    }
                }
                GUILayout.Space(10);
                GUILayout.EndScrollView();
                GUILayout.EndArea();


                //配置+数据区域
                GUILayout.BeginArea(new Rect(this.position.width / 3 + 50, 10, this.position.width / 3 * 2 - 75, this.position.height - 110));
                EditorGUILayout.HelpBox("Unity GUI Redis\n" +
                                        "作者: 傑", MessageType.Info);
                Language = (Language)EditorGUILayout.EnumPopup("语言(Language)", Language);
                //配置区域
                m_ScrollPosition2     = EditorGUILayout.BeginScrollView(m_ScrollPosition2);
                this.fadeGroup.target = EditorGUILayout.Foldout(this.fadeGroup.target, "基础设置", true);
                if (EditorGUILayout.BeginFadeGroup(this.fadeGroup.faded))
                {
                    EditorGUILayout.HelpBox("注意:\n如果Redis服务器外网没访问权,请使用SSH连接\n如果通过SSH连接,数据库IP为Redis配置文件中绑定的地址(理论上为127.0.0.1)\n如果不通过SSH连接,数据库IP为服务器IP\nRedis数据库端口默认是6379\n数据库如果没密码就留空\n数据库默认为0", MessageType.Warning);
                    SQL_IP       = EditorGUILayout.TextField("数据库IP", SQL_IP);
                    SQL_Port     = (uint)EditorGUILayout.IntField("数据库端口", (int)SQL_Port);
                    SQL_Password = EditorGUILayout.PasswordField("数据库密码", SQL_Password);
                    SQL_DB       = EditorGUILayout.IntField("数据库", (int)SQL_DB);
                    Debug        = EditorGUILayout.Toggle("调试模式", Debug);
                    GUILayout.Space(10);
                    ConnectThroughSSH = EditorGUILayout.BeginToggleGroup("使用SSH连接(建议开启)", ConnectThroughSSH);
                    EditorGUILayout.HelpBox("注意:\nSSH服务器必须具有数据库访问权(即数据库在该服务器内或该服务器IP有权限访问数据库)\nSSH端口默认22\nSSH用户为服务器登入用户名,CentOS的机子一般是root,Ubuntu机子是ubuntu,Windows机子是Administrator\nSSH密码为你登入服务器的密码", MessageType.Warning);
                    SSH_Host     = EditorGUILayout.TextField("SSH服务器IP", SSH_Host);
                    SSH_Port     = EditorGUILayout.IntField("端口", SSH_Port);
                    SSH_User     = EditorGUILayout.TextField("用户", SSH_User);
                    SSH_Password = EditorGUILayout.PasswordField("密码", SSH_Password);
                    EditorGUILayout.EndToggleGroup();
                    GUILayout.Space(10);
                }
                EditorGUILayout.EndFadeGroup();
                //数据处理区域
                GUILayout.Space(5);
                CurrentKey = EditorGUILayout.TextField("Key", CurrentKey);
                EditorGUILayout.LabelField("Value");
                m_ScrollPosition3 = EditorGUILayout.BeginScrollView(m_ScrollPosition3);
                CurrentValue      = EditorGUILayout.TextArea(CurrentValue, GUILayout.MinHeight(150), GUILayout.ExpandHeight(true));
                GUILayout.EndScrollView();
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                if (CurrentKey != "" && CurrentValue != "" && SelectedKey != "")
                {
                    if (GUILayout.Button("保存"))
                    {
                        SetValue();
                    }
                    if (GUILayout.Button("删除"))
                    {
                        DeleteValue();
                    }
                }
                else
                {
                    if (GUILayout.Button("新增"))
                    {
                        SetValue();
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
                GUILayout.EndArea();
                //按钮区域
                GUILayout.BeginArea(new Rect(this.position.width / 3 + 25 + ((this.position.width / 3 * 2) - 275) / 2, this.position.height - 90, 250, 80));
                m_ScrollPosition4 = EditorGUILayout.BeginScrollView(m_ScrollPosition4);
                if (GUILayout.Button("刷新Keys"))
                {
                    GetKeys();
                }
                if (GUILayout.Button("测试连接"))
                {
                    TestConnection();
                }
                EditorGUILayout.HelpBox("测试连接会阻塞主线程,建议不要在游戏运行时点击测试,慎用!", MessageType.Error);
                GUILayout.EndScrollView();
                GUILayout.EndArea();
                EditorGUILayout.EndVertical();
            }

            #region 如果不需要英文版可以把下面的删了

            else//英文版本
            {
                //全部Key区域
                GUILayout.BeginArea(new Rect(25, 10, this.position.width / 3, this.position.height - 10));

                EditorGUILayout.LabelField("Keys in Db" + SQL_DB + "", header);
                GUILayout.Space(5);
                EditorGUILayout.LabelField(Keys.Count + " Keys in total", body);
                if (GUILayout.Button("Add new key"))
                {
                    CurrentValue = "";
                    CurrentKey   = "";
                    this.Repaint();
                }
                GUILayout.Space(10);

                m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
                foreach (var key in Keys)
                {
                    if (GUILayout.Button(key))
                    {
                        GetValue(key);
                    }
                }
                GUILayout.Space(10);
                GUILayout.EndScrollView();
                GUILayout.EndArea();


                //配置+数据区域
                GUILayout.BeginArea(new Rect(this.position.width / 3 + 50, 10, this.position.width / 3 * 2 - 75, this.position.height - 110));
                EditorGUILayout.HelpBox("Unity GUI Redis\n" +
                                        "Author: JasonXuDeveloper", MessageType.Info);
                Language = (Language)EditorGUILayout.EnumPopup("语言(Language)", Language);
                //配置区域
                m_ScrollPosition2     = EditorGUILayout.BeginScrollView(m_ScrollPosition2);
                this.fadeGroup.target = EditorGUILayout.Foldout(this.fadeGroup.target, "Basics", true);
                if (EditorGUILayout.BeginFadeGroup(this.fadeGroup.faded))
                {
                    EditorGUILayout.HelpBox("Note:\nPlease use SSH if your Redis service refuses to connect from your ip\nWhen you are using SSH, please change the SQL IP to bind IP in your redis configuration (usually is 127.0.0.1)\nIf you are not using SSH, change the SQL IP to you Server IP\nDefault port for Redis is 6379\nRemain SQL Password empty when there is no password\nDefault database is 9", MessageType.Warning);
                    SQL_IP       = EditorGUILayout.TextField("SQL IP", SQL_IP);
                    SQL_Port     = (uint)EditorGUILayout.IntField("SQL Port", (int)SQL_Port);
                    SQL_Password = EditorGUILayout.PasswordField("SQL Password", SQL_Password);
                    SQL_DB       = EditorGUILayout.IntField("Database", (int)SQL_DB);
                    Debug        = EditorGUILayout.Toggle("Debug mode", Debug);
                    GUILayout.Space(10);
                    ConnectThroughSSH = EditorGUILayout.BeginToggleGroup("Use SSH (Highly recommended)", ConnectThroughSSH);
                    EditorGUILayout.HelpBox("Note:\nSSH must be avaliable to connect to Redis\nDefault port for SSH is 22\nSSH Username is usually root on CentOS Machines, ubuntu on Ubuntu Machines, Administrator on Windows\nSSH Password is the password which you access to your machine", MessageType.Warning);
                    SSH_Host     = EditorGUILayout.TextField("SSH IP", SSH_Host);
                    SSH_Port     = EditorGUILayout.IntField("SSH Port", SSH_Port);
                    SSH_User     = EditorGUILayout.TextField("SSH User", SSH_User);
                    SSH_Password = EditorGUILayout.PasswordField("SSH Password", SSH_Password);
                    EditorGUILayout.EndToggleGroup();
                    GUILayout.Space(10);
                }
                EditorGUILayout.EndFadeGroup();
                //数据处理区域
                GUILayout.Space(5);
                CurrentKey = EditorGUILayout.TextField("Key", CurrentKey);
                EditorGUILayout.LabelField("Value");
                m_ScrollPosition3 = EditorGUILayout.BeginScrollView(m_ScrollPosition3);
                CurrentValue      = EditorGUILayout.TextArea(CurrentValue, GUILayout.MinHeight(150), GUILayout.ExpandHeight(true));
                GUILayout.EndScrollView();
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                if (CurrentKey != "" && CurrentValue != "")
                {
                    if (GUILayout.Button("Save"))
                    {
                        SetValue();
                    }
                    if (GUILayout.Button("Delete"))
                    {
                        DeleteValue();
                    }
                }
                else
                {
                    if (GUILayout.Button("Add New"))
                    {
                        SetValue();
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
                GUILayout.EndArea();
                //按钮区域
                GUILayout.BeginArea(new Rect(this.position.width / 3 + 25 + ((this.position.width / 3 * 2) - 275) / 2, this.position.height - 90, 250, 80));
                m_ScrollPosition4 = EditorGUILayout.BeginScrollView(m_ScrollPosition4);
                if (GUILayout.Button("Refresh Keys"))
                {
                    GetKeys();
                }
                if (GUILayout.Button("Test Connection"))
                {
                    TestConnection();
                }
                EditorGUILayout.HelpBox("Test connection will be running on main thread,\nThus it is not recommended to try it while the game is playing,\nPlease be aware before you use this feature", MessageType.Error);
                GUILayout.EndScrollView();
                GUILayout.EndArea();
                EditorGUILayout.EndVertical();
            }
            #endregion
            //删到这里就够了
        }
    void OnGUI()
    {
        IsoTexture[] textures = TextureManager.getInstance().textureList();

        GUIStyle style = new GUIStyle(GUI.skin.button);

        style.padding = new RectOffset(5, 5, 5, 5);

        GUIStyle s = new GUIStyle(GUIStyle.none);

        s.fontStyle = FontStyle.Bold;

        /* NO me gusta como se ve esto la verdad...
         * EditorGUILayout.BeginHorizontal();
         *
         *      if(GUILayout.Button("New", style))
         *              TextureManager.getInstance().newTexture();
         *
         *
         *      if(GUILayout.Button("Delete", style))
         *              if(selected < textures.Length){
         *                      TextureManager.getInstance().deleteTexture(TextureManager.getInstance().textureList()[selected]);
         *                      selected = textures.Length;
         *              }
         *
         * EditorGUILayout.EndHorizontal();
         *
         *
         * GUIContent[] texts = new GUIContent[textures.Length];
         * for(int i = 0; i< textures.Length; i++){
         *      texts[i] = new GUIContent(textures[i].name);
         * }
         *
         * EditorGUILayout.PrefixLabel("IsoTextures List", s);
         *
         * scrollPos = EditorGUILayout.BeginScrollView(scrollPos,GUILayout.Width(0), GUILayout.Height(60));
         * selected = GUILayout.SelectionGrid(selected,texts,2,style,GUILayout.MaxWidth(auxWidth-25));
         * EditorGUILayout.EndScrollView();
         */

        if (selected < textures.Length && textures[selected] != null)
        {
            currentText = textures[selected];
        }
        else
        {
            currentText = null;
        }

        EditorGUILayout.PrefixLabel("IsoTexture", s);
        currentText = EditorGUILayout.ObjectField(currentText, typeof(IsoTexture), false) as IsoTexture;
        for (int i = 0; i < textures.Length; i++)
        {
            if (currentText == textures[i])
            {
                selected = i;
            }
        }

        // Textura
        if (currentText != null)
        {
            currentText.name = UnityEditor.EditorGUILayout.TextField("Name", currentText.name);
            currentText.setTexture(UnityEditor.EditorGUILayout.ObjectField("Base tile", currentText.getTexture(), typeof(Texture2D), true) as Texture2D);

            Texture2D texture = currentText.getTexture();

            if (texture != null)
            {
                EditorGUILayout.PrefixLabel("Presets", s);

                if (GUILayout.Button("Top"))
                {
                    currentText.Rotation = 0;
                    currentText.setXCorner(Mathf.RoundToInt(currentText.getTexture().width / 2f));
                    currentText.setYCorner(Mathf.RoundToInt(currentText.getTexture().height / 2f));
                }
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Left"))
                {
                    currentText.Rotation = 0;
                    currentText.setXCorner(0);
                    currentText.setYCorner(Mathf.RoundToInt((2f * currentText.getTexture().height) / 3f));
                }
                if (GUILayout.Button("Right"))
                {
                    currentText.Rotation = 3;
                    currentText.setXCorner(currentText.getTexture().width);
                    currentText.setYCorner(Mathf.RoundToInt(currentText.getTexture().height / 3f));
                }

                EditorGUILayout.EndHorizontal();

                extra.target = EditorGUILayout.ToggleLeft("Advanced", extra.target);
                if (EditorGUILayout.BeginFadeGroup(extra.faded))

                {
                    EditorGUI.indentLevel++;

                    if (GUILayout.Button("Rotation: " + currentText.Rotation * 90))
                    {
                        currentText.Rotation++;
                    }

                    EditorGUILayout.BeginHorizontal();
                    currentText.setXCorner(EditorGUILayout.IntField(currentText.getXCorner(), GUILayout.Width(30)));
                    currentText.setXCorner(Mathf.FloorToInt(GUILayout.HorizontalSlider(currentText.getXCorner(), 0, texture.width, null)));
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    currentText.setYCorner(EditorGUILayout.IntField(currentText.getYCorner(), GUILayout.Width(30)));
                    currentText.setYCorner(Mathf.FloorToInt(GUILayout.HorizontalSlider(currentText.getYCorner(), 0, texture.height, null)));
                    EditorGUILayout.EndHorizontal();

                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.EndFadeGroup();

                if (extra.faded != lastValue)
                {
                    this.Repaint();
                }
                lastValue = extra.faded;

                EditorGUILayout.Space();
                Rect rect = GUILayoutUtility.GetLastRect();
                if (Event.current.type == EventType.repaint)
                {
                    float w = position.width;
                    float h = position.height - rect.y;

                    float rh = (w / texture.width * 1.0f) * (texture.height * 1.0f) - 10;
                    float rw = w - 10;

                    if (rh > h)
                    {
                        rw = (h / texture.height * 1.0f) * texture.width - 10;
                        rh = h - 10;
                    }

                    textureRect = new Rect(w / 2f - rw / 2f, rect.y + 5, rw, rh);
                }

                float converter = textureRect.width / texture.width;

                /*Rect auxRect = GUILayoutUtility.GetRect(auxWidth, auxHeight);
                 * auxRect.width = auxWidth;*/
                GUI.DrawTexture(textureRect, texture);

                Vector2 rectCorner   = new Vector2(textureRect.x, textureRect.y);
                Vector2 xCorner      = rectCorner + new Vector2(converter * currentText.getXCorner(), 0);
                Vector2 yCorner      = rectCorner + new Vector2(0, converter * currentText.getYCorner());
                Vector2 xOtherCorner = rectCorner + new Vector2(converter * currentText.getOppositeXCorner(), textureRect.height);
                Vector2 yOtherCorner = rectCorner + new Vector2(textureRect.width, converter * currentText.getOppositeYCorner());

                Drawing.DrawLine(xCorner, yCorner, Color.yellow, 0.5f, true);
                Drawing.DrawLine(yCorner, xOtherCorner, Color.yellow, 0.5f, true);
                Drawing.DrawLine(xOtherCorner, yOtherCorner, Color.yellow, 0.5f, true);
                Drawing.DrawLine(yOtherCorner, xCorner, Color.yellow, 0.5f, true);
            }
            else
            {
                EditorGUILayout.LabelField("Please asign a texture!");
            }
        }
        else
        {
            EditorGUILayout.LabelField("Please select a texture o create a new one!", style);
        }

        //GUI
    }
        void ShowHeatmapGUI()
        {
            m_Settings.HeatLevels = m_Settings.DistanceSelection.Count;
            EditorGUILayout.BeginFadeGroup(Mathf.Clamp((int)m_selectedMode, 0, 1));

            //Color chooser GUI
            EditorGUI.indentLevel++;
            m_Settings.ReferenceSpace = (TerrainVisualizationSettings.REFERENCESPACE)EditorGUILayout.EnumPopup(Styles.ReferenceSpace, m_Settings.ReferenceSpace);
            if (m_Settings.ReferenceSpace == TerrainVisualizationSettings.REFERENCESPACE.WorldSpace)
            {
                m_Settings.SeaLevel = EditorGUILayout.FloatField(Styles.SeaLevel, m_Settings.SeaLevel, GUILayout.ExpandWidth(false));
            }

            // Measure GUI
            EditorGUI.BeginChangeCheck();
            m_Settings.CurrentMeasure = (TerrainVisualizationSettings.MEASUREMENTS)EditorGUILayout.EnumPopup(Styles.MeasurementUnit, m_Settings.CurrentMeasure);
            if (EditorGUI.EndChangeCheck())
            {
                ConvertUnits();
            }

            // Heat Levels GUI
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(Styles.HeatLevels, GUILayout.MaxWidth(100));
            EditorGUI.BeginChangeCheck();
            m_Settings.HeatLevels = EditorGUILayout.IntSlider(m_Settings.HeatLevels, 1, 8);
            if (EditorGUI.EndChangeCheck())
            {
                ConfigureHeatLevels();
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(20f);
            EditorGUILayout.BeginVertical("Box");
            if (m_Settings.DistanceSelection.Count > 0 && m_Settings.HeatLevels > 0)
            {
                float min = m_Settings.DistanceSelection[0];
                float max = m_Settings.DistanceSelection[m_Settings.HeatLevels - 1];
                for (int i = 0; i < m_Settings.HeatLevels; i++)
                {
                    float distance = (float)System.Math.Round(m_Settings.DistanceSelection[i], 2);

                    EditorGUILayout.BeginHorizontal();
                    if (m_Settings.ReferenceSpace == TerrainVisualizationSettings.REFERENCESPACE.WorldSpace)
                    {
                        m_Settings.DistanceSelection[i] = EditorGUILayout.FloatField(distance, GUILayout.Width(70));
                    }
                    else
                    {
                        m_Settings.DistanceSelection[i] = Mathf.Clamp(EditorGUILayout.FloatField(distance, GUILayout.Width(70)), 0, m_TerrainMaxHeight);
                    }

                    float height = m_Settings.DistanceSelection[i];

                    //Compare the distances
                    EditorGUI.indentLevel--;
                    if (m_Settings.CurrentMeasure == TerrainVisualizationSettings.MEASUREMENTS.Feet)
                    {
                        EditorGUILayout.LabelField(new GUIContent("ft"), GUILayout.Width(30));
                        height /= TerrainVisualizationSettings.CONVERSIONNUM;
                    }
                    else
                    {
                        EditorGUILayout.LabelField(new GUIContent("m"), GUILayout.Width(30));
                    }
                    m_Settings.MaxDistance = Mathf.Max(height, max);
                    m_Settings.MinDistance = Mathf.Min(height, min);
                    EditorGUI.indentLevel--;

                    m_Settings.ColorSelection[i] = EditorGUILayout.ColorField(m_Settings.ColorSelection[i]);
                    EditorGUI.indentLevel       += 2;
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndFadeGroup();
            EditorGUI.indentLevel--;
        }