Esempio n. 1
0
            private void DrawMenuButtonProperties()
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Menu Button Properties:", EditorStyles.boldLabel);

                // Draw array of menu button names and events.
                for (int index = 0; index < mSP_ButtonNames.arraySize; index++)
                {
                    // Div-like wrapper for each button data.
                    Rect buttonDataRect = EditorGUILayout.BeginVertical(MarginNMarginStyle);
                    EditorGUI.DrawRect(buttonDataRect, Color.grey);
                    DTEditorUtility.ShrinkRectByOne(ref buttonDataRect);
                    EditorGUI.DrawRect(buttonDataRect, Color.white);

                    DrawButtonDataAtIndex(index);

                    EditorGUILayout.EndVertical();
                }

                // Button to add menu buttons.
                if (GUILayout.Button(addButtonContent))
                {
                    mSP_ButtonNames.InsertArrayElementAtIndex(mSP_ButtonNames.arraySize);
                    mSP_ButtonEvents.InsertArrayElementAtIndex(mSP_ButtonEvents.arraySize);

                    mbNeedUpdateNumberOfButtons = true;
                }
            }
Esempio n. 2
0
            public override void OnInspectorGUI()
            {
                serializedObject.Update();

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("General Options", EditorStyles.boldLabel);

                // Menu Size Field.
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(mSP_MenuSize, menuSizeContent);
                if (EditorGUI.EndChangeCheck())
                {
                    mbNeedUpdateMenuSize = true;
                }

                // Menu Top and Bottom Padding Fields
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.Slider(mSP_MenuPaddingTop, 0.0f, 1.0f, menuPaddingTopContent);
                EditorGUILayout.Slider(mSP_MenuPaddingBottom, 0.0f, 1.0f, menuPaddingBottomContent);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Button Layout Options", EditorStyles.boldLabel);

                // Button Horizontal Percentage Field.
                EditorGUILayout.Slider(mSP_ButtonHorzPercent, 0.0f, 1.0f, buttonHorzPercentContent);

                // Button Verticle Margin Field.
                EditorGUILayout.Slider(mSP_ButtonVertMargin, 0.0f, 0.1f, buttonVertMarginContent);
                if (EditorGUI.EndChangeCheck())
                {
                    mbNeedUpdateButtonTransforms = true;
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Button Content Options", EditorStyles.boldLabel);

                // Button Font Size Field.
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(mSP_ButtonFontSize, buttonFontSizeContent);
                if (EditorGUI.EndChangeCheck())
                {
                    mbNeedUpdateButtonFontSize = true;
                }

                // Menu Button order, name, and events.
                DrawMenuButtonProperties();

                EditorGUILayout.Space();

                // Danger Zone (Force Reconstruct, Deleting, etc.)
                Rect dangerZoneRect = EditorGUILayout.BeginVertical(MarginNMarginStyle);

                EditorGUI.DrawRect(dangerZoneRect, Color.grey);
                DTEditorUtility.ShrinkRectByOne(ref dangerZoneRect);
                EditorGUI.DrawRect(dangerZoneRect, Color.red);
                EditorGUILayout.LabelField("DANGER ZONE", EditorStyles.boldLabel);
                if (GUILayout.Button(forceReconstructButtonContent))
                {
                    ConstructCanvasFromScratch();
                }
                GUILayout.EndVertical();

                serializedObject.ApplyModifiedProperties();

                // Once inspector is done drawing and applying modifications,
                // Ensure that a Canvas and EventSystem are created.
                // If there is no Canvas and/or EventSystem, EnsureMenuCanvas will create one.
                EnsureMenuCanvas();
                UpdateCanvas();                 // Then Update the Canvas if needed.
            }