예제 #1
0
    /*
     * For more information on the OnInspectorGUI and adding your own variables
     * in the UltimateStatusBar.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();

        UltimateStatusBar usbLogic = ( UltimateStatusBar )target;

        EditorGUILayout.Space();

        #region ASSIGNED VARIABLES
        /* ---------------------------------------- > ASSIGNED VARIABLES < ---------------------------------------- */
        DisplayHeaderDropdown("Assigned Variables", "UUI_Variables", AssignedVariables);
        if (EditorGUILayout.BeginFadeGroup(AssignedVariables.faded))
        {
            EditorGUILayout.Space();

            // Status Bar Variables
            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.PropertyField(statusBar, new GUIContent("Status Bar", "The targeted image to display the status."));
                EditorGUI.BeginDisabledGroup(usbLogic.statusBar == null);
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField(statusBarColor, new GUIContent("Status Bar Color", "The default color of the status bar."));
                EditorGUI.EndDisabledGroup();
                if (usbLogic.statusBar == null)
                {
                    EditorGUILayout.HelpBox("Status Bar variable needs to be assigned.", MessageType.Error);
                }
                else if (usbLogic.statusBar.type != UnityEngine.UI.Image.Type.Filled)
                {
                    EditorGUILayout.HelpBox("Status Bar image needs to be adjusted to type: Filled.", MessageType.Warning);
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Adjust Image"))
                    {
                        usbLogic.statusBar.type       = UnityEngine.UI.Image.Type.Filled;
                        usbLogic.statusBar.fillMethod = UnityEngine.UI.Image.FillMethod.Horizontal;
                    }

                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUI.indentLevel = 0;
            }
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                usbLogic.UpdateStatusBarColor(usbLogic.statusBarColor);
            }

            EditorGUILayout.Space();

            // Text variables
            if (EditorGUILayout.BeginFadeGroup(ShowText.faded))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(statusBarText, new GUIContent("Status Bar Text", "The text component used to display the values of the status."));
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginDisabledGroup(usbLogic.statusBarText == null);
                EditorGUILayout.PropertyField(statusBarTextColor, new GUIContent("Text Color", "The color of the text component."));
                EditorGUI.EndDisabledGroup();
                EditorGUI.indentLevel = 0;
                if (usbLogic.statusBarText != null && usbLogic.statusBarTextColor != usbLogic.statusBarText.color)
                {
                    EditorGUILayout.HelpBox("Please assign the color of the text component using the color property above.", MessageType.Warning);
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button(new GUIContent("Update Color", "Updates the Text Color property to match the color of the text component.")))
                        {
                            usbLogic.statusBarTextColor = usbLogic.statusBarText.color;
                        }
                        GUILayout.FlexibleSpace();
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                    if (usbLogic.statusBarText != null)
                    {
                        usbLogic.UpdateStatusBarTextColor(usbLogic.statusBarTextColor);
                    }
                }
            }
            if (AssignedVariables.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* -------------------------------------- > END ASSIGNED VARIABLES < -------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        /* ----------------------------------------- > STYLE AND OPTIONS < ----------------------------------------- */
        DisplayHeaderDropdown("Style and Options", "UUI_StyleAndOptions", StyleAndOptions);
        if (EditorGUILayout.BeginFadeGroup(StyleAndOptions.faded))
        {
            /* ---------------------- < SHOW TEXT > ---------------------- */
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(showText);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                if (usbLogic.showText == false && usbLogic.statusBarText != null)
                {
                    usbLogic.statusBarText.gameObject.SetActive(false);
                }
                else if (usbLogic.showText == true && usbLogic.statusBarText != null)
                {
                    usbLogic.statusBarText.gameObject.SetActive(true);
                }

                ShowText.target = usbLogic.showText;
            }

            if (EditorGUILayout.BeginFadeGroup(ShowText.faded))
            {
                EditorGUI.indentLevel = 1;
                if (usbLogic.statusBarText != null)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(usePercentage, new GUIContent("Use Percentage", "Should the status bar values be displayed as a percentage?"));
                    EditorGUILayout.PropertyField(additionalText, new GUIContent("Additional Text", "Determines what additional text is displayed before the values."));
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                        usbLogic.UpdateStatusBar(testValue, 100.0f);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("The Status Bar Text Variable needs to be assigned before making any changes.", MessageType.Error);
                }
                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }
            /* -------------------- > END SHOW TEXT < -------------------- */

            /* ---------------------- < ALTERNATE STATES > ---------------------- */
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(alternateStateOption, new GUIContent("Alternate State", "Does this status require having an alternate state to display?"));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                if (usbLogic.alternateStateOption == UltimateStatusBar.AlternateStateOption.None)
                {
                    usbLogic.UpdateStatusBarColor(usbLogic.statusBarColor);
                }
                else
                {
                    usbLogic.UpdateStatusBar(testValue, 1.0f);
                }

                AlternateState.target = usbLogic.alternateStateOption != UltimateStatusBar.AlternateStateOption.None ? true : false;
            }

            if (EditorGUILayout.BeginFadeGroup(AlternateState.faded))
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                {
                    if (usbLogic.alternateStateOption != UltimateStatusBar.AlternateStateOption.ColorBlended)
                    {
                        if (usbLogic.alternateStateOption == UltimateStatusBar.AlternateStateOption.Percentage)
                        {
                            EditorGUILayout.Slider(triggerValue, 0.0f, 1.0f, new GUIContent("Trigger Value", "The value at which the state will trigger."));
                        }

                        EditorGUILayout.PropertyField(alternateStateColor, new GUIContent("Alt State Color", "The color of the alternate state."));

                        EditorGUILayout.PropertyField(flashing);
                        if (EditorGUILayout.BeginFadeGroup(Flashing.faded))
                        {
                            EditorGUI.indentLevel = 2;
                            EditorGUILayout.PropertyField(alternateStateColorAlt, new GUIContent("Flashing Alt", "The alternate color of the alternate state."));
                            EditorGUILayout.Slider(flashingSpeed, 10.0f, 20.0f, new GUIContent("Flashing Speed", "The speed at which the status bar should transition between the colors."));
                            EditorGUI.indentLevel = 1;
                        }
                        if (AlternateState.faded == 1 && StyleAndOptions.faded == 1)
                        {
                            EditorGUILayout.EndFadeGroup();
                        }
                    }
                    else if (usbLogic.alternateStateOption == UltimateStatusBar.AlternateStateOption.ColorBlended)
                    {
                        EditorGUILayout.PropertyField(statusBarColor, new GUIContent("Alt State Full", "The color of the alternate state."));
                        EditorGUILayout.PropertyField(alternateStateColor, new GUIContent("Alt State Mid", "The color of the alternate state."));
                        EditorGUILayout.PropertyField(alternateStateColorAlt, new GUIContent("Alt State Low", "The alternate color of the alternate state."));
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                    usbLogic.UpdateStatusBar(testValue, 100.0f);

                    AltStateColorBlend.target    = usbLogic.alternateStateOption == UltimateStatusBar.AlternateStateOption.ColorBlended ? true : false;
                    AltStateDefaultOption.target = usbLogic.alternateStateOption != UltimateStatusBar.AlternateStateOption.ColorBlended ? true : false;
                    Flashing.target = usbLogic.flashing;
                }
                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }
            /* -------------------- < END ALTERNATE STATES > -------------------- */

            /* ---------------------- < SMOOTH FILL > ---------------------- */
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(smoothFill, new GUIContent("Smooth Fill", "Fills the status bar from the current amount to the target amount over time."));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                SmoothFill.target = usbLogic.smoothFill;
            }

            if (EditorGUILayout.BeginFadeGroup(SmoothFill.faded))
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.PropertyField(smoothFillDuration, new GUIContent("Duration", "The time in which it takes to fill the status bar to the target amount."));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }
            /* ---------------------- < END SMOOTH FILL > ---------------------- */

            // Fill Constraint
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(fillConstraint, new GUIContent("Fill Constraint", "Constrains the image fill amount to a minimum and maximum value."));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                FillConstraint.target = usbLogic.fillConstraint;
                usbLogic.UpdateStatusBar(testValue, 100.0f);
            }
            if (EditorGUILayout.BeginFadeGroup(FillConstraint.faded))
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider(fillConstraintMin, 0.0f, usbLogic.fillConstraintMax, new GUIContent("Constraint Min", "The minimum fill amount to be constrained by."));
                EditorGUILayout.Slider(fillConstraintMax, usbLogic.fillConstraintMin, 1.0f, new GUIContent("Constraint Max", "The maximum fill amount to be constrained by."));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                    usbLogic.UpdateStatusBar(testValue, 100.0f);
                }
                EditorGUI.indentLevel = 0;
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }

            if (controller.timeoutOption != UltimateStatusBarController.TimeoutOption.None)
            {
                EditorGUI.BeginChangeCheck();                // EDIT MAJOR:
                EditorGUILayout.PropertyField(keepControllerAwake, new GUIContent("Keep Visible", "Should this status keep the controller awake if it is below a certain amount?"));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                    KeepAwake.target = usbLogic.keepControllerAwake;
                }

                if (EditorGUILayout.BeginFadeGroup(KeepAwake.faded))
                {
                    EditorGUI.indentLevel = 1;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.Slider(keepAwakeTrigger, 0.0f, 1.0f, new GUIContent("Trigger", "The amount at which to keep the controller awake."));
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                    }
                    EditorGUI.indentLevel = 0;
                }

                if (StyleAndOptions.faded == 1)
                {
                    EditorGUILayout.EndFadeGroup();
                }
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* --------------------------------------- > END STYLE AND OPTIONS < --------------------------------------- */

        EditorGUILayout.Space();

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

                nameUnassigned.target = usbLogic.statusBarName == string.Empty ? true : false;
                nameAssigned.target   = usbLogic.statusBarName != string.Empty ? true : false;
            }

            if (EditorGUILayout.BeginFadeGroup(nameUnassigned.faded))
            {
                EditorGUILayout.HelpBox("Please make sure to assign a name so that this status bar 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.UpdateStatus)
                {
                    EditorGUILayout.TextField("UltimateStatusBar.UpdateStatus( \"" + usbLogic.statusBarName + "\", currentValue, maxValue );");
                }
                else if (scriptCast == ScriptCast.UpdateColor)
                {
                    EditorGUILayout.TextField("UltimateStatusBar.UpdateStatusBarColor( \"" + usbLogic.statusBarName + "\", targetColor );");
                }
                else if (scriptCast == ScriptCast.UpdateTextColor)
                {
                    EditorGUILayout.TextField("UltimateStatusBar.UpdateStatusBarTextColor( \"" + usbLogic.statusBarName + "\", targetTextColor );");
                }
                else if (scriptCast == ScriptCast.AlternateState)
                {
                    EditorGUILayout.TextField("UltimateStatusBar.AlternateState( \"" + usbLogic.statusBarName + "\", targetState );");
                }
                GUILayout.Space(1);
                EditorGUILayout.EndVertical();
            }
            if (ScriptReference.faded == 1.0f)
            {
                EditorGUILayout.EndFadeGroup();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* ------------------------------------ > END REFERENCE < ------------------------------------ */

        EditorGUILayout.Space();

        /* -------------------------------------- > DEBUGGING < -------------------------------------- */
        DisplayHeaderDropdown("Debugging", "UUI_ExtraOption_01", Debugging);
        if (EditorGUILayout.BeginFadeGroup(Debugging.faded))
        {
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Box");
            GUILayout.Space(1);
            if (GUILayout.Button("Controller"))
            {
                Selection.activeGameObject = Selection.activeGameObject.GetComponentInParent <UltimateStatusBarController>().gameObject;
            }

            if (usbLogic.statusBar != null)
            {
                EditorGUILayout.LabelField(new GUIContent("Fill Method: " + usbLogic.statusBar.fillMethod, "The Fill Method as determined by the Image Component on the Status Bar."));
            }

            EditorGUI.BeginChangeCheck();
            testValue = EditorGUILayout.Slider(new GUIContent("Test Value", "A test value to preview the Ultimate Status Bar when values change."), testValue, 0.0f, 100.0f);
            if (EditorGUI.EndChangeCheck())
            {
                usbLogic.statusBar.enabled = false;
                usbLogic.UpdateStatusBar(testValue, 100.0f);
                usbLogic.statusBar.enabled = true;
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndFadeGroup();
        /* ------------------------------------ > END DEBUGGING < ------------------------------------ */

        EditorGUILayout.Space();
        Repaint();
    }
예제 #2
0
    /*
    For more information on the OnInspectorGUI and adding your own variables
    in the UltimateJoystick.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();

        EditorGUILayout.Space();

        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 Joystick to function correctly.", MessageType.Error );
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space( 5 );
                if( GUILayout.Button( "Update Canvas" ) )
                {
                    parentCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
                    parentCanvas = GetParentCanvas();
                }
                GUILayout.Space( 5 );
                if( GUILayout.Button( "Update Joystick" ) )
                {
                    UltimateJoystickCreator.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 Joystick to function correctly.", MessageType.Error );
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space( 5 );
                    if( GUILayout.Button( "Update Canvas" ) )
                    {
                        parentCanvas.GetComponent<CanvasScaler>().uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize;
                        parentCanvas = GetParentCanvas();
                        UltimateJoystick joystick = ( UltimateJoystick )target;
                        joystick.UpdatePositioning();
                    }
                    GUILayout.Space( 5 );
                    if( GUILayout.Button( "Update Joystick" ) )
                    {
                        UltimateJoystickCreator.RequestCanvas( Selection.activeGameObject );
                        parentCanvas = GetParentCanvas();
                    }
                    GUILayout.Space( 5 );
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                }
            }
            return;
        }

        UltimateJoystick uj = ( UltimateJoystick ) target;

        #region ASSIGNED VARIABLES
        /* ----------------------------------------< ** ASSIGNED VARIABLES ** >---------------------------------------- */
        DisplayHeader( "Assigned Variables", "UUI_Variables", AssignedVariables );
        if( EditorGUILayout.BeginFadeGroup( AssignedVariables.faded ) )
        {
            EditorGUILayout.Space();
            EditorGUI.indentLevel = 1;
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( joystick );
            EditorGUILayout.PropertyField( joystickSizeFolder, new GUIContent( "Size Folder" ) );
            EditorGUILayout.PropertyField( joystickBase );
            EditorGUI.indentLevel = 0;

            if( EditorGUILayout.BeginFadeGroup( highlightOption.faded ) )
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField( "Highlight Variables", EditorStyles.boldLabel );
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField( highlightBase );
                EditorGUILayout.PropertyField( highlightJoystick );
                EditorGUI.indentLevel = 0;
            }
            if( AssignedVariables.faded == 1 )
                EditorGUILayout.EndFadeGroup();

            if( EditorGUILayout.BeginFadeGroup( tensionOption.faded ) )
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField( "Tension Variables", EditorStyles.boldLabel );
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField( tensionAccentUp, new GUIContent( "Tension Up" ) );
                EditorGUILayout.PropertyField( tensionAccentDown, new GUIContent( "Tension Down" ) );
                EditorGUILayout.PropertyField( tensionAccentLeft, new GUIContent( "Tension Left" ) );
                EditorGUILayout.PropertyField( tensionAccentRight, new GUIContent( "Tension Right" ) );
                EditorGUI.indentLevel = 0;
            }
            if( AssignedVariables.faded == 1 )
                EditorGUILayout.EndFadeGroup();

            if( EditorGUILayout.BeginFadeGroup( animationOption.faded ) )
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField( "Touch Action Variables", EditorStyles.boldLabel );
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField( joystickAnimator );
                EditorGUI.indentLevel = 0;
            }
            if( AssignedVariables.faded == 1 )
                EditorGUILayout.EndFadeGroup();

            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( scalingAxis, new GUIContent( "Scaling Axis", "The axis to scale the Ultimate Joystick from." ) );
            EditorGUILayout.PropertyField( anchor, new GUIContent( "Anchor", "The side of the screen that the\njoystick will be anchored to." ) );
            EditorGUILayout.PropertyField( joystickTouchSize, new GUIContent( "Touch Size", "The size of the area in which\nthe touch can be initiated." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                if( uj.joystickTouchSize == UltimateJoystick.JoystickTouchSize.Custom )
                    customTouchSizeOption.target = true;
                else
                    customTouchSizeOption.target = false;
            }
            if( EditorGUILayout.BeginFadeGroup( customTouchSizeOption.faded ) )
            {
                EditorGUILayout.BeginVertical( "Box" );
                EditorGUILayout.LabelField( "Touch Size Customization" );
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.Slider( customTouchSize_X, 0.0f, 100.0f, new GUIContent( "Width", "The width of the Joystick Touch Area." ) );
                    EditorGUILayout.Slider( customTouchSize_Y, 0.0f, 100.0f, new GUIContent( "Height", "The height of the Joystick Touch Area." ) );
                    EditorGUILayout.Slider( customTouchSizePos_X, 0.0f, 100.0f, new GUIContent( "X Position", "The x position of the Joystick Touch Area." ) );
                    EditorGUILayout.Slider( customTouchSizePos_Y, 0.0f, 100.0f, new GUIContent( "Y Position", "The y position of the Joystick Touch Area." ) );
                }
                if( EditorGUI.EndChangeCheck() )
                    serializedObject.ApplyModifiedProperties();
                EditorGUILayout.EndVertical();
                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if( SizeAndPlacement.faded == 1 )
                EditorGUILayout.EndFadeGroup();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( dynamicPositioning, new GUIContent( "Dynamic Positioning", "Moves the joystick to the position of the initial touch." ) );
            EditorGUILayout.Slider( joystickSize, 1.0f, 4.0f, new GUIContent( "Joystick Size", "The overall size of the joystick." ) );
            EditorGUILayout.Slider( radiusModifier, 2.0f, 7.0f, new GUIContent( "Radius", "Determines how far the joystick can\nmove visually from the center." ) );
            EditorGUILayout.BeginVertical( "Box" );
            EditorGUILayout.LabelField( "Joystick Position" );
            EditorGUI.indentLevel = 1;
            EditorGUILayout.Slider( customSpacing_X, 0.0f, 50.0f, new GUIContent( "X Position:", "The horizontal position of the joystick." ) );
            EditorGUILayout.Slider( customSpacing_Y, 0.0f, 100.0f, new GUIContent( "Y Position:", "The vertical position of the joystick." ) );
            EditorGUI.indentLevel = 0;
            EditorGUILayout.EndVertical();
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();
        }
        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();

            // --------------------------< TOUCH PAD >-------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( touchPad, new GUIContent( "Touch Pad", "Disables the visuals of the joystick." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                if( uj.touchPad == true )
                {
                    highlightOption.target = false;
                    tensionOption.target = false;
                }

                SetTouchPad( uj );
                SetHighlight( uj );
                SetTensionAccent( uj );
            }

            if( uj.touchPad == true && uj.joystickBase == null )
                EditorGUILayout.HelpBox( "Joystick Base needs to be assigned in the Assigned Variables section.", MessageType.Error );
            // ------------------------< END TOUCH PAD >------------------------ //

            // --------------------------< THROWABLE >-------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( throwable, new GUIContent( "Throwable", "Smoothly transitions the joystick back to\ncenter when the input is released." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                throwableOption.target = uj.throwable;
            }

            if( EditorGUILayout.BeginFadeGroup( throwableOption.faded ) )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider( throwDuration, 0.05f, 1.0f, new GUIContent( "Throw Duration", "Time in seconds to return to center." ) );
                if( EditorGUI.EndChangeCheck() )
                    serializedObject.ApplyModifiedProperties();

                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if( StyleAndOptions.faded == 1 )
                EditorGUILayout.EndFadeGroup();
            // ------------------------< END THROWABLE >------------------------ //

            // --------------------------< DRAGGABLE >-------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( draggable, new GUIContent( "Draggable", "Drags the joystick to follow the touch if it is farther than the radius." ) );
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();

            if( uj.draggable == true && uj.boundary == UltimateJoystick.Boundary.Square )
                EditorGUILayout.HelpBox( "Draggable option will force the boundary to being circular. " +
                                        "Please use a circular boundary when using the draggable option.", MessageType.Warning );
            // ------------------------< END DRAGGABLE >------------------------ //

            EditorGUI.BeginDisabledGroup( uj.touchPad == true );// This is the start of the disabled fields if the user is using the touchPad option.

            // --------------------------< HIGHLIGHT >-------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( showHighlight, new GUIContent( "Show Highlight", "Displays the highlight images with the Highlight Color variable." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                SetHighlight( uj );
                highlightOption.target = uj.showHighlight;
            }

            if( EditorGUILayout.BeginFadeGroup( highlightOption.faded ) )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField( highlightColor );
                if( EditorGUI.EndChangeCheck() )
                {
                    serializedObject.ApplyModifiedProperties();
                    uj.UpdateHighlightColor( uj.highlightColor );
                }

                if( uj.highlightBase == null && uj.highlightJoystick == null )
                    EditorGUILayout.HelpBox( "No highlight images have been assigned. Please assign some highlight images before continuing.", MessageType.Error );

                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if( StyleAndOptions.faded == 1 )
                EditorGUILayout.EndFadeGroup();
            // ------------------------< END HIGHLIGHT >------------------------ //

            // ---------------------------< TENSION >--------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( showTension, new GUIContent( "Show Tension", "Displays the visual direction of the joystick using the tension color options." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                SetTensionAccent( uj );
                tensionOption.target = uj.showTension;
            }

            if( EditorGUILayout.BeginFadeGroup( tensionOption.faded ) )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField( tensionColorNone, new GUIContent( "Tension None", "The color displayed when the joystick\nis closest to center." ) );
                EditorGUILayout.PropertyField( tensionColorFull, new GUIContent( "Tension Full", "The color displayed when the joystick\nis at the furthest distance." ) );
                if( EditorGUI.EndChangeCheck() )
                {
                    serializedObject.ApplyModifiedProperties();
                    TensionAccentReset( uj );
                }

                if( uj.tensionAccentUp == null || uj.tensionAccentDown == null || uj.tensionAccentLeft == null || uj.tensionAccentRight == null )
                    EditorGUILayout.HelpBox( "Some tension accents are unassigned. Please assign all images before continuing.", MessageType.Error );

                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if( StyleAndOptions.faded == 1 )
                EditorGUILayout.EndFadeGroup();
            // -------------------------< END TENSION >------------------------- //

            EditorGUI.EndDisabledGroup();// This is the end for the Touch Pad option.

            // -----------------------------< AXIS >---------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( axis, new GUIContent( "Axis", "Contrains the joystick to a certain axis." ) );
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();
            // ---------------------------< END AXIS >-------------------------- //

            // ---------------------------< BOUNDARY >-------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( boundary, new GUIContent( "Boundry", "Determines how the joystick's position is clamped." ) );
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();
            // -------------------------< END BOUNDARY >------------------------ //

            // --------------------------< DEAD ZONE >-------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( deadZoneOption, new GUIContent( "Dead Zone", "Forces the joystick position to being only values of -1, 0, and 1." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                dzOneValueOption.target = uj.deadZoneOption == UltimateJoystick.DeadZoneOption.OneValue ? true : false;
                dzTwoValueOption.target = uj.deadZoneOption == UltimateJoystick.DeadZoneOption.TwoValues ? true : false;
            }
            EditorGUI.indentLevel = 1;
            EditorGUI.BeginChangeCheck();
            if( EditorGUILayout.BeginFadeGroup( dzTwoValueOption.faded ) )
            {
                EditorGUILayout.Slider( xDeadZone, 0.0f, 1.0f, new GUIContent( "X Dead Zone", "X values within this range will be forced to 0." ) );
                EditorGUILayout.Slider( yDeadZone, 0.0f, 1.0f, new GUIContent( "Y Dead Zone", "Y values within this range will be forced to 0." ) );
            }
            if( StyleAndOptions.faded == 1 )
                EditorGUILayout.EndFadeGroup();

            if( EditorGUILayout.BeginFadeGroup( dzOneValueOption.faded ) )
            {
                EditorGUILayout.Slider( xDeadZone, 0.0f, 1.0f, new GUIContent( "Dead Zone", "Values within this range will be forced to 0." ) );
                uj.yDeadZone = uj.xDeadZone;
            }
            if( StyleAndOptions.faded == 1 )
                EditorGUILayout.EndFadeGroup();

            EditorGUI.indentLevel = 0;
            if( EditorGUI.EndChangeCheck() )
                serializedObject.ApplyModifiedProperties();
            // ------------------------< END DEAD ZONE >------------------------ //
        }
        EditorGUILayout.EndFadeGroup();
        /* --------------------------------------< ** END STYLE AND OPTIONS ** >------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        #region TOUCH ACTIONS
        /* ------------------------------------------< ** TOUCH ACTIONS ** >----------------------------------------- */
        DisplayHeader( "Touch Actions", "UUI_TouchActions", TouchActions );
        if( EditorGUILayout.BeginFadeGroup( TouchActions.faded ) )
        {
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( tapCountOption, new GUIContent( "Tap Count", "Allows the joystick to calculate double taps and a touch and release within a certain time window." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                tcOption.target = uj.tapCountOption != UltimateJoystick.TapCountOption.NoCount ? true : false;
                tcTargetTapOption.target = uj.tapCountOption == UltimateJoystick.TapCountOption.Accumulate ? true : false;
            }

            if( EditorGUILayout.BeginFadeGroup( tcOption.faded ) )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField( tapCountEvent );
                EditorGUILayout.Slider( tapCountDuration, 0.0f, 1.0f, new GUIContent( "Tap Time Window", "Time in seconds that the joystick can recieve taps." ) );
                if( EditorGUILayout.BeginFadeGroup( tcTargetTapOption.faded ) )
                    EditorGUILayout.IntSlider( targetTapCount, 1, 5, new GUIContent( "Target Tap Count", "How many taps to activate the Tap Count Event?" ) );
                if( TouchActions.faded == 1 )
                    EditorGUILayout.EndFadeGroup();

                if( EditorGUI.EndChangeCheck() )
                    serializedObject.ApplyModifiedProperties();

                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if( TouchActions.faded == 1 )
                EditorGUILayout.EndFadeGroup();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( useAnimation, new GUIContent( "Use Animation", "Play animation in reaction to input." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                SetAnimation( uj );
                animationOption.target = uj.useAnimation;
            }
            if( uj.useAnimation == true )
            {
                EditorGUI.indentLevel = 1;
                if( uj.joystickAnimator == null )
                    EditorGUILayout.HelpBox( "Joystick Animator needs to be assigned.", MessageType.Error );
                EditorGUI.indentLevel = 0;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( useFade, new GUIContent( "Use Fade", "Fade joystick visuals when touched,\nand released?" ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();
                if( uj.useFade == true )
                    uj.gameObject.GetComponent<CanvasGroup>().alpha = uj.fadeUntouched;
                else
                    uj.gameObject.GetComponent<CanvasGroup>().alpha = 1.0f;

                fadeOption.target = uj.useFade;
            }
            if( EditorGUILayout.BeginFadeGroup( fadeOption.faded ) )
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider( fadeUntouched, 0.0f, 1.0f, new GUIContent( "Fade Untouched", "The alpha of the joystick when it is NOT receiving input." ) );
                EditorGUILayout.Slider( fadeTouched, 0.0f, 1.0f, new GUIContent( "Fade Touched", "The alpha of the joystick when receiving input." ) );
                EditorGUILayout.PropertyField( fadeInDuration );
                EditorGUILayout.PropertyField( fadeOutDuration );
                if( EditorGUI.EndChangeCheck() )
                {
                    serializedObject.ApplyModifiedProperties();
                    uj.gameObject.GetComponent<CanvasGroup>().alpha = uj.fadeUntouched;
                }

                EditorGUI.indentLevel = 0;
            }
            if( TouchActions.faded == 1 )
                EditorGUILayout.EndFadeGroup();
        }
        EditorGUILayout.EndFadeGroup();
        /* ------------------------------------------< ** END TOUCH ACTIONS ** >------------------------------------------ */
        #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( joystickName, new GUIContent( "Joystick Name", "The name of the targeted joystick used for static referencing." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();

                if( uj.joystickName == string.Empty )
                {
                    joystickNameUnassigned.target = true;
                    joystickNameAssigned.target = false;
                }
                else
                {
                    joystickNameUnassigned.target = false;
                    joystickNameAssigned.target = true;
                }
            }

            if( EditorGUILayout.BeginFadeGroup( joystickNameUnassigned.faded ) )
            {
                EditorGUILayout.HelpBox( "Please assign a Joystick Name in order to be able to get this joystick's position dynamically.", MessageType.Warning );
            }
            if( ScriptReference.faded == 1.0f )
                EditorGUILayout.EndFadeGroup();

            if( EditorGUILayout.BeginFadeGroup( joystickNameAssigned.faded ) )
            {
                EditorGUILayout.BeginVertical( "Box" );
                EditorGUILayout.LabelField( "Script Reference:", EditorStyles.boldLabel );
                scriptCast = ( ScriptCast )EditorGUILayout.EnumPopup( "Joystick Use: ", scriptCast );
                GUILayout.Space( 5 );
                if( scriptCast == ScriptCast.Vector2 )
                    EditorGUILayout.TextField( "UltimateJoystick.GetPosition( \"" + uj.joystickName + "\" )" );
                else if( scriptCast == ScriptCast.distance )
                    EditorGUILayout.TextField( "UltimateJoystick.GetDistance( \"" + uj.joystickName + "\" )" );
                else if( scriptCast == ScriptCast.horizontalFloat )
                    EditorGUILayout.TextField( "UltimateJoystick.GetPosition( \"" + uj.joystickName + "\" ).x" );
                else if( scriptCast == ScriptCast.verticalFloat )
                    EditorGUILayout.TextField( "UltimateJoystick.GetPosition( \"" + uj.joystickName + "\" ).y" );
                else
                    EditorGUILayout.TextField( "UltimateJoystick.GetJoystickState( \"" + uj.joystickName + "\" )" );
                GUILayout.Space( 1 );
                EditorGUILayout.EndVertical();
            }
            if( ScriptReference.faded == 1.0f )
                EditorGUILayout.EndFadeGroup();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField( exposeValues, new GUIContent( "Expose Values", "Should this script expose it's values for certain game making plugins? This option does not effect performance of other references." ) );
            if( EditorGUI.EndChangeCheck() )
            {
                serializedObject.ApplyModifiedProperties();

                exposeValuesBool.target = uj.exposeValues;
            }

            if( EditorGUILayout.BeginFadeGroup( exposeValuesBool.faded ) )
            {
                EditorGUILayout.BeginVertical( "Box" );
                EditorGUILayout.LabelField( "Current Position:", EditorStyles.boldLabel );
                EditorGUILayout.LabelField( "Horizontal Value: " + uj.horizontalValue.ToString( "F2" ) );
                EditorGUILayout.LabelField( "Vertical Value: " + uj.verticalValue.ToString( "F2" ) );
                EditorGUILayout.EndVertical();
            }
            if( ScriptReference.faded == 1.0f )
                EditorGUILayout.EndFadeGroup();
        }
        EditorGUILayout.EndFadeGroup();
        /* -----------------------------------------< ** END SCRIPT REFERENCE ** >---------------------------------------- */
        #endregion

        EditorGUILayout.Space();

        /* ----------------------------------------------< ** HELP TIPS ** >---------------------------------------------- */

        if( uj.joystick == null )
            EditorGUILayout.HelpBox( "Joystick needs to be assigned in 'Assigned Variables'!", MessageType.Error );
        if( uj.joystickSizeFolder == null )
            EditorGUILayout.HelpBox( "Joystick Size Folder needs to be assigned in 'Assigned Variables'!", MessageType.Error );
        if( uj.joystickBase == null )
            EditorGUILayout.HelpBox( "Joystick Base needs to be assigned in 'Assigned Variables'!", MessageType.Error );
        /* --------------------------------------------< ** END HELP TIPS ** >-------------------------------------------- */

        Repaint();
    }
예제 #3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.Space();

        #region CANVAS ERRORS
        /* ///// ---------------------------------------- < CANVAS ERRORS > ---------------------------------------- \\\\\ */
        if (CanvasErrors() == true)
        {
            if (parentCanvas.renderMode != RenderMode.ScreenSpaceOverlay)
            {
                EditorGUILayout.BeginVertical("Box");
                EditorGUILayout.HelpBox("The parent Canvas needs to be set to 'Screen Space - Overlay' in order for the Ultimate Button to function correctly.", MessageType.Error);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Update Canvas", EditorStyles.miniButtonLeft))
                {
                    parentCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
                    parentCanvas            = GetParentCanvas();
                }
                if (GUILayout.Button("Update Button", EditorStyles.miniButtonRight))
                {
                    UltimateButtonCreator.RequestCanvas(Selection.activeGameObject);
                    parentCanvas = GetParentCanvas();
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }
            if (parentCanvas.GetComponent <CanvasScaler>())
            {
                if (parentCanvas.GetComponent <CanvasScaler>().uiScaleMode != CanvasScaler.ScaleMode.ConstantPixelSize)
                {
                    EditorGUILayout.BeginVertical("Box");
                    EditorGUILayout.HelpBox("The Canvas Scaler component located on the parent Canvas needs to be set to 'Constant Pixel Size' in order for the Ultimate Button to function correctly.", MessageType.Error);
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Update Canvas", EditorStyles.miniButtonLeft))
                    {
                        parentCanvas.GetComponent <CanvasScaler>().uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize;
                        parentCanvas = GetParentCanvas();
                        UltimateButton button = ( UltimateButton )target;
                        button.UpdatePositioning();
                    }
                    if (GUILayout.Button("Update Button", EditorStyles.miniButtonRight))
                    {
                        UltimateButtonCreator.RequestCanvas(Selection.activeGameObject);
                        parentCanvas = GetParentCanvas();
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.EndVertical();
                }
            }
            return;
        }
        /* \\\\\ -------------------------------------- < END CANVAS ERRORS > -------------------------------------- ///// */
        #endregion

        UltimateButton targ = ( UltimateButton )target;

        #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(positioning);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            if (targ.positioning == UltimateButton.Positioning.ScreenSpace)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(sizeFolder, new GUIContent("Button Size Folder"));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.PropertyField(scalingAxis);
                    EditorGUILayout.PropertyField(anchor);
                    EditorGUILayout.PropertyField(touchSize, new GUIContent("Touch Size", "The size of the area in which the touch can start"));
                    EditorGUILayout.Slider(buttonSize, 0.0f, 5.0f, new GUIContent("Button Size"));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                    TouchSizeDefaultOptions.target = targ.touchSize == UltimateButton.TouchSize.Default ? true : false;
                }

                EditorGUILayout.BeginVertical("Box");
                {
                    EditorGUILayout.LabelField("Button Position");
                    EditorGUI.indentLevel = 1;
                    {
                        EditorGUI.BeginChangeCheck();
                        {
                            EditorGUILayout.Slider(customSpacing_X, 0.0f, 50.0f, new GUIContent("X Position:"));
                            EditorGUILayout.Slider(customSpacing_Y, 0.0f, 100.0f, new GUIContent("Y Position:"));
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            serializedObject.ApplyModifiedProperties();
                        }
                    }
                    EditorGUI.indentLevel = 0;
                }
                EditorGUILayout.EndVertical();
            }
            else if (targ.positioning == UltimateButton.Positioning.RelativeToJoystick)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(joystick);
                EditorGUILayout.PropertyField(sizeFolder, new GUIContent("Button Size Folder"));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.PropertyField(anchorSide);
                    EditorGUILayout.PropertyField(touchSize, new GUIContent("Touch Size", "The size of the area in which the touch can start"));
                    EditorGUILayout.Slider(buttonSize, 0.0f, 5.0f, new GUIContent("Button Size"));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                    TouchSizeDefaultOptions.target = targ.touchSize == UltimateButton.TouchSize.Default ? true : false;
                }

                EditorGUILayout.BeginVertical("Box");
                {
                    EditorGUILayout.LabelField("Button Position");
                    EditorGUI.indentLevel = 1;
                    {
                        EditorGUI.BeginChangeCheck();
                        {
                            EditorGUILayout.Slider(customSpacing_X, 0.0f, 100.0f, new GUIContent("X Position:"));
                            EditorGUILayout.Slider(customSpacing_Y, 0.0f, 100.0f, new GUIContent("Y Position:"));
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            serializedObject.ApplyModifiedProperties();
                        }
                    }
                    EditorGUI.indentLevel = 0;
                }
                EditorGUILayout.EndVertical();
            }
            else if (targ.positioning == UltimateButton.Positioning.RelativeToButton)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(rectTrans, new GUIContent("Target Size Folder"));
                EditorGUILayout.PropertyField(targetButtonBase, new GUIContent("Target Button Base Image"));
                EditorGUILayout.PropertyField(sizeFolder, new GUIContent("This Button Size Folder"));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.PropertyField(anchorSide);
                    EditorGUILayout.PropertyField(touchSize, new GUIContent("Touch Size", "The size of the area in which the touch can start"));
                    EditorGUILayout.Slider(buttonSize, 0.0f, 5.0f, new GUIContent("Button Size"));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                    TouchSizeDefaultOptions.target = targ.touchSize == UltimateButton.TouchSize.Default ? true : false;
                }

                EditorGUILayout.BeginVertical("Box");
                {
                    EditorGUILayout.LabelField("Button Position");
                    EditorGUI.indentLevel = 1;
                    {
                        EditorGUI.BeginChangeCheck();
                        {
                            EditorGUILayout.Slider(customSpacing_X, -200.0f, 200.0f, new GUIContent("X Position:"));
                            EditorGUILayout.Slider(customSpacing_Y, -200.0f, 200.0f, new GUIContent("Y Position:"));
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            serializedObject.ApplyModifiedProperties();
                        }
                    }
                    EditorGUI.indentLevel = 0;
                }
                EditorGUILayout.EndVertical();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* \\\\\ -------------------------------------- < END SIZE AND PLACEMENT > -------------------------------------- ///// */
        #endregion

        EditorGUILayout.Space();

        #region STYLE AND OPTIONS
        /* ///// ---------------------------------------- < STYLES AND OPTIONS > ---------------------------------------- \\\\\ */
        DisplayHeader("Style and Options", "UUI_StyleAndOptions", StyleAndOptions);
        if (EditorGUILayout.BeginFadeGroup(StyleAndOptions.faded))
        {
            EditorGUILayout.Space();

            if (EditorGUILayout.BeginFadeGroup(TouchSizeDefaultOptions.faded))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(imageStyle, new GUIContent("Image Style", "Determines whether the input range should be circular or square. This option affects how the Input Range and Track Input options function."));
                EditorGUILayout.Slider(inputRange, 0.0f, 1.0f, new GUIContent("Input Range", "The range that the Ultimate Button will react to when initiating and dragging the input."));
                EditorGUILayout.PropertyField(trackInput, new GUIContent("Track Input", "Enabling this option will allow the Ultimate Button to track the users input to ensure that button events and states are only called when the input is within the Input Range."));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
            if (StyleAndOptions.faded == 1.0f)
            {
                EditorGUILayout.EndFadeGroup();
            }

            // TRANSMIT INPUT //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(transmitInput, new GUIContent("Transmit Input", "Should the Ultimate Button transmit input events to another UI game object?"));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                TransmitInputEnabled.target = targ.transmitInput;
            }

            if (EditorGUILayout.BeginFadeGroup(TransmitInputEnabled.faded))
            {
                EditorGUI.indentLevel = 1;

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(receiver, new GUIContent("Input Receiver"));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if (StyleAndOptions.faded == 1.0f)
            {
                EditorGUILayout.EndFadeGroup();
            }

            // TAP COUNT OPTIONS //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(tapCountOption);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                tapOption.target = targ.tapCountOption != UltimateButton.TapCountOption.NoCount ? true : false;
            }
            if (EditorGUILayout.BeginFadeGroup(tapOption.faded))
            {
                EditorGUI.indentLevel = 1;
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.Slider(tapCountDuration, 0.0f, 1.0f, new GUIContent("Tap Time Window"));
                    EditorGUI.BeginDisabledGroup(targ.tapCountOption != UltimateButton.TapCountOption.Accumulate);
                    EditorGUILayout.IntSlider(targetTapCount, 1, 5, new GUIContent("Target Tap Count"));
                    EditorGUI.EndDisabledGroup();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                EditorGUI.indentLevel = 0;

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Example Code"))
                {
                    ScriptReference.target = true;
                    EditorPrefs.SetBool("UUI_ScriptReference", true);
                    scriptCast = ScriptCast.GetTapCount;
                }
                if (GUILayout.Button("Button Events"))
                {
                    ButtonEvents.target = true;
                    EditorPrefs.SetBool("UUI_ExtraOption_01", true);
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(8);
            EditorGUILayout.LabelField("───────");
            EditorGUILayout.EndHorizontal();

            // BASE COLOR //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(buttonBase);
            EditorGUILayout.PropertyField(baseColor);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                targ.UpdateBaseColor(targ.baseColor);
                if (targ.buttonBase != null)
                {
                    EditorUtility.SetDirty(targ.buttonBase);
                }
            }
            if (targ.buttonBase == null)
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.HelpBox("The Button Base image has not been assigned. Please make sure to assign this variable within the Assigned Variables section.", MessageType.Warning);
                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }

            // --------------------------< HIGHLIGHT >-------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(showHighlight, new GUIContent("Show Highlight", "Displays the highlight images with the Highlight Color variable."));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                SetHighlight(targ);
                highlightOption.target = targ.showHighlight;
                if (targ.buttonHighlight != null)
                {
                    EditorUtility.SetDirty(targ.buttonHighlight);
                }
            }
            EditorGUI.indentLevel = 1;
            if (EditorGUILayout.BeginFadeGroup(highlightOption.faded))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(buttonHighlight, new GUIContent("Button Highlight"));
                EditorGUILayout.PropertyField(highlightColor);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                    targ.UpdateHighlightColor(targ.highlightColor);
                    if (targ.buttonHighlight != null)
                    {
                        EditorUtility.SetDirty(targ.buttonHighlight);
                    }
                }
                EditorGUILayout.Space();
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }

            EditorGUI.indentLevel = 0;
            // ------------------------< END HIGHLIGHT >------------------------ //

            // ---------------------------< TENSION >--------------------------- //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(showTension, new GUIContent("Show Tension", "Displays the visual state of the button using the tension color options."));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                SetTensionAccent(targ);
                tensionOption.target = targ.showTension;
                if (targ.tensionAccent != null)
                {
                    EditorUtility.SetDirty(targ.tensionAccent);
                }
            }

            EditorGUI.indentLevel = 1;

            if (EditorGUILayout.BeginFadeGroup(tensionOption.faded))
            {
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.PropertyField(tensionAccent);
                    EditorGUILayout.PropertyField(tensionColorNone, new GUIContent("Tension None", "The Color of the Tension with no input."));
                    EditorGUILayout.PropertyField(tensionColorFull, new GUIContent("Tension Full", "The Color of the Tension when there is input."));
                    EditorGUILayout.PropertyField(tensionFadeInDuration, new GUIContent("Fade In Duration", "Time is seconds for the tension to fade in, with 0 being instant."));
                    EditorGUILayout.PropertyField(tensionFadeOutDuration, new GUIContent("Fade Out Duration", "Time is seconds for the tension to fade out, with 0 being instant."));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    if (tensionFadeInDuration.floatValue < 0)
                    {
                        tensionFadeInDuration.floatValue = 0;
                    }
                    if (tensionFadeOutDuration.floatValue < 0)
                    {
                        tensionFadeOutDuration.floatValue = 0;
                    }

                    serializedObject.ApplyModifiedProperties();
                    if (targ.tensionAccent != null)
                    {
                        targ.tensionAccent.color = targ.tensionColorNone;
                        EditorUtility.SetDirty(targ.tensionAccent);
                    }
                }
                if (EditorGUILayout.BeginFadeGroup(TensionAccentError.faded))
                {
                    EditorGUILayout.HelpBox("The Tension Accent image has not been assigned. Please make sure to assign this immediately.", MessageType.Error);
                }
                if (StyleAndOptions.faded == 1.0f && tensionOption.faded == 1.0f)
                {
                    EditorGUILayout.EndFadeGroup();
                }

                EditorGUILayout.Space();
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }

            EditorGUI.indentLevel = 0;
            // -------------------------< END TENSION >------------------------- //

            // USE ANIMATION OPTIONS //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(useAnimation);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                SetAnimation(targ);
                animationOption.target = targ.useAnimation;
            }
            if (EditorGUILayout.BeginFadeGroup(animationOption.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(buttonAnimator, new GUIContent("Animator"));
                EditorGUI.indentLevel--;
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }

            // USE FADE OPTIONS //
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(useFade);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                fadeOption.target = targ.useFade;

                if (!targ.GetComponent <CanvasGroup>())
                {
                    targ.gameObject.AddComponent <CanvasGroup>();
                }

                if (targ.useFade == true)
                {
                    targ.gameObject.GetComponent <CanvasGroup>().alpha = targ.fadeUntouched;
                }
                else
                {
                    targ.gameObject.GetComponent <CanvasGroup>().alpha = 1.0f;
                }
            }
            if (EditorGUILayout.BeginFadeGroup(fadeOption.faded))
            {
                EditorGUI.indentLevel = 1;
                {
                    EditorGUI.BeginChangeCheck();
                    {
                        EditorGUILayout.Slider(fadeUntouched, 0.0f, 1.0f, new GUIContent("Fade Untouched", "This controls the alpha of the button when it is NOT receiving any input."));
                        EditorGUILayout.Slider(fadeTouched, 0.0f, 1.0f, new GUIContent("Fade Touched", "This controls the alpha of the button when it is receiving input."));
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();

                        if (!targ.GetComponent <CanvasGroup>())
                        {
                            targ.gameObject.AddComponent <CanvasGroup>();
                        }

                        if (targ.useFade == true)
                        {
                            targ.gameObject.GetComponent <CanvasGroup>().alpha = targ.fadeUntouched;
                        }
                        else
                        {
                            targ.gameObject.GetComponent <CanvasGroup>().alpha = 1.0f;
                        }
                    }
                    EditorGUI.BeginChangeCheck();
                    {
                        EditorGUILayout.PropertyField(fadeInDuration, new GUIContent("Fade In Duration", "Time is seconds for the button to fade in, with 0 being instant."));
                        EditorGUILayout.PropertyField(fadeOutDuration, new GUIContent("Fade Out Duration", "Time is seconds for the button to fade out, with 0 being instant."));
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (fadeInDuration.floatValue < 0)
                        {
                            fadeInDuration.floatValue = 0;
                        }
                        if (fadeOutDuration.floatValue < 0)
                        {
                            fadeOutDuration.floatValue = 0;
                        }

                        serializedObject.ApplyModifiedProperties();
                    }
                }
                EditorGUI.indentLevel = 0;
                EditorGUILayout.Space();
            }
            if (StyleAndOptions.faded == 1)
            {
                EditorGUILayout.EndFadeGroup();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* \\\\\ -------------------------------------- < END STYLES 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(buttonName);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                buttonNameAssigned.target   = targ.buttonName == string.Empty ? false : true;
                buttonNameUnassigned.target = targ.buttonName != string.Empty ? false : true;
            }

            if (EditorGUILayout.BeginFadeGroup(buttonNameUnassigned.faded))
            {
                EditorGUILayout.HelpBox("Please assign a Button Name in order to be able to get this button's states dynamically.", MessageType.Warning);
            }
            if (ScriptReference.faded == 1.0f)
            {
                EditorGUILayout.EndFadeGroup();
            }

            if (EditorGUILayout.BeginFadeGroup(buttonNameAssigned.faded))
            {
                EditorGUILayout.BeginVertical("Box");
                EditorGUILayout.LabelField("Example Code:", EditorStyles.boldLabel);
                EditorGUILayout.LabelField("Please select the function you would like to copy and paste into your script.", EditorStyles.wordWrappedLabel);
                scriptCast = ( ScriptCast )EditorGUILayout.EnumPopup(scriptCast);
                GUILayout.Space(5);
                switch (scriptCast)
                {
                case ScriptCast.GetButtonDown:
                {
                    EditorGUILayout.TextField("if( UltimateButton.GetButtonDown( \"" + targ.buttonName + "\" ) )");
                }
                break;

                case ScriptCast.GetButtonUp:
                {
                    EditorGUILayout.TextField("if( UltimateButton.GetButtonUp( \"" + targ.buttonName + "\" ) )");
                }
                break;

                case ScriptCast.GetButton:
                default:
                {
                    EditorGUILayout.TextField("if( UltimateButton.GetButton( \"" + targ.buttonName + "\" ) )");
                }
                break;

                case ScriptCast.GetTapCount:
                {
                    EditorGUILayout.TextField("if( UltimateButton.GetTapCount( \"" + targ.buttonName + "\" ) )");

                    if (targ.tapCountOption == UltimateButton.TapCountOption.NoCount)
                    {
                        EditorGUILayout.HelpBox("Tap Count is not being used. Please set the Tap Count Option in order to use this option.", MessageType.Warning);
                    }
                }
                break;

                case ScriptCast.GetUltimateButton:
                {
                    EditorGUILayout.TextField("UltimateButton.GetUltimateButton( \"" + targ.buttonName + "\" )");
                }
                break;

                case ScriptCast.DisableButton:
                {
                    EditorGUILayout.TextField("UltimateButton.DisableButton( \"" + targ.buttonName + "\" );");
                }
                break;

                case ScriptCast.EnableButton:
                {
                    EditorGUILayout.TextField("UltimateButton.EnableButton( \"" + targ.buttonName + "\" );");
                }
                break;
                }
                GUILayout.Space(1);
                EditorGUILayout.EndVertical();

                if (GUILayout.Button("Open Documentation"))
                {
                    UltimateButtonWindow.OpenDocumentation();
                }
            }
            if (ScriptReference.faded == 1.0f)
            {
                EditorGUILayout.EndFadeGroup();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* ///// --------------------------------------- < END SCRIPT REFERENCE > --------------------------------------- \\\\\ */
        #endregion

        EditorGUILayout.Space();

        #region BUTTON EVENTS
        /* \\\\\ ----------------------------------------- < SCRIPT REFERENCE > ----------------------------------------- ///// */
        DisplayHeader("Button Events", "UUI_ExtraOption_01", ButtonEvents);
        if (EditorGUILayout.BeginFadeGroup(ButtonEvents.faded))
        {
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(onButtonDown);
            EditorGUILayout.PropertyField(onButtonUp);

            if (EditorGUILayout.BeginFadeGroup(tapOption.faded))
            {
                EditorGUILayout.PropertyField(tapCountEvent);
            }
            if (ButtonEvents.faded == 1.0f)
            {
                EditorGUILayout.EndFadeGroup();
            }

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
        EditorGUILayout.EndFadeGroup();
        /* ///// --------------------------------------- < END SCRIPT REFERENCE > --------------------------------------- \\\\\ */
        #endregion

        EditorGUILayout.Space();

        if (PrefabUtility.GetPrefabType(Selection.activeGameObject) == PrefabType.Prefab)
        {
            GUISkin defaultSkin     = GUI.skin;
            int     defaultFontSize = defaultSkin.FindStyle("Button").fontSize;
            defaultSkin.FindStyle("Button").fontSize = 12;
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add to Scene", GUILayout.Height(25), GUILayout.Width(200)))
            {
                UltimateButtonCreator.CreateNewUltimateButton(targ.gameObject);
            }
            GUILayout.FlexibleSpace();
            GUILayout.Space(10);
            EditorGUILayout.EndHorizontal();
            defaultSkin.FindStyle("Button").fontSize = defaultFontSize;
        }

        Repaint();
    }
예제 #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();
    }