Ejemplo n.º 1
0
        private void PaintHeader(SerializedProperty spEnabled, AnimBool state, string title)
        {
            EditorGUILayout.BeginHorizontal();

            GUIStyle style = (spEnabled.boolValue
                                ? CoreGUIStyles.GetToggleButtonOn()
                                : CoreGUIStyles.GetToggleButtonOff()
                              );

            bool buttonPressed = GUILayout.Button(title, style);
            Rect buttonRect    = GUILayoutUtility.GetLastRect();

            if (buttonPressed)
            {
                spEnabled.boolValue = !spEnabled.boolValue;
                state.target        = spEnabled.boolValue;
            }

            if (UnityEngine.Event.current.type == EventType.Repaint)
            {
                Rect toggleRect = new Rect(
                    buttonRect.x + 5f,
                    buttonRect.y + (buttonRect.height / 2 - 8),
                    12,
                    12
                    );

                bool isOn = spEnabled.boolValue;
                EditorStyles.toggle.Draw(toggleRect, GUIContent.none, false, false, isOn, isOn);
            }

            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 2
0
 public static GUIStyle GetToggleButtonOn()
 {
     if (CoreGUIStyles.btnToggleOn == null)
     {
         CoreGUIStyles.btnToggleOn               = new GUIStyle(CoreGUIStyles.GetToggleButtonOff());
         CoreGUIStyles.btnToggleOn.alignment     = TextAnchor.MiddleLeft;
         CoreGUIStyles.btnToggleOn.normal        = CoreGUIStyles.btnToggleOn.onNormal;
         CoreGUIStyles.btnToggleOn.hover         = CoreGUIStyles.btnToggleOn.onHover;
         CoreGUIStyles.btnToggleOn.active        = CoreGUIStyles.btnToggleOn.onActive;
         CoreGUIStyles.btnToggleOn.focused       = CoreGUIStyles.btnToggleOn.onFocused;
         CoreGUIStyles.btnToggleOn.richText      = true;
         CoreGUIStyles.btnToggleOn.margin.bottom = 0;
     }
     return(CoreGUIStyles.btnToggleOn);
 }
Ejemplo n.º 3
0
        private void PaintItemsToolbar()
        {
            Rect rectItem = GUILayoutUtility.GetRect(
                GUIContent.none, CoreGUIStyles.GetToggleButtonOff()
                );

            Rect rectItem1 = new Rect(
                rectItem.x,
                rectItem.y,
                ITEMS_TOOLBAR_WIDTH,
                rectItem.height
                );
            Rect rectItem2 = new Rect(
                rectItem1.x + rectItem1.width,
                rectItem1.y,
                rectItem1.width,
                rectItem1.height
                );
            Rect rectItem3 = new Rect(
                rectItem2.x + rectItem2.width,
                rectItem2.y,
                rectItem2.width,
                rectItem2.height
                );
            Rect rectItemH = new Rect(
                //rectItem.x + (rectItem.width - ITEMS_TOOLBAR_WIDTH),
                rectItem3.x + rectItem3.width + 5f,
                rectItem2.y,
                ITEMS_TOOLBAR_WIDTH,
                rectItem2.height
                );

            if (GUI.Button(rectItem1, GC_ACTIONS, CoreGUIStyles.GetButtonLeft()))
            {
                int index = this.spItems.arraySize;
                this.spItems.InsertArrayElementAtIndex(index);

                SerializedProperty spItem = this.spItems.GetArrayElementAtIndex(index);
                spItem.FindPropertyRelative(PROP_OPTION).intValue = (int)Trigger.ItemOpts.Actions;
                spItem.FindPropertyRelative(PROP_ACTIONS).objectReferenceValue    = this.CreateSubObject <Actions>();
                spItem.FindPropertyRelative(PROP_CONDITIONS).objectReferenceValue = null;
            }

            if (GUI.Button(rectItem2, GC_CONDITIONS, CoreGUIStyles.GetButtonMid()))
            {
                int index = this.spItems.arraySize;
                this.spItems.InsertArrayElementAtIndex(index);

                SerializedProperty spItem = this.spItems.GetArrayElementAtIndex(index);
                spItem.FindPropertyRelative(PROP_OPTION).intValue = (int)Trigger.ItemOpts.Conditions;
                spItem.FindPropertyRelative(PROP_ACTIONS).objectReferenceValue    = null;
                spItem.FindPropertyRelative(PROP_CONDITIONS).objectReferenceValue = this.CreateSubObject <Conditions>();
            }

            if (GUI.Button(rectItem3, "+", CoreGUIStyles.GetButtonRight()))
            {
                int index = this.spItems.arraySize;
                this.spItems.InsertArrayElementAtIndex(index);

                SerializedProperty spItem = this.spItems.GetArrayElementAtIndex(index);
                spItem.FindPropertyRelative(PROP_OPTION).intValue = (int)Trigger.ItemOpts.Actions;
                spItem.FindPropertyRelative(PROP_ACTIONS).objectReferenceValue    = null;
                spItem.FindPropertyRelative(PROP_CONDITIONS).objectReferenceValue = null;
            }

            EditorGUI.BeginDisabledGroup(this.trigger.gameObject.GetComponent <Hotspot>() != null);
            if (GUI.Button(rectItemH, GC_HOTSPOT))
            {
                Undo.AddComponent <Hotspot>(this.trigger.gameObject);
            }
            EditorGUI.EndDisabledGroup();
        }