Ejemplo n.º 1
0
        private void PaintAdvancedSettings()
        {
            GUIStyle style = (this.foldoutAdvancedSettings
                                ? CoreGUIStyles.GetToggleButtonNormalOn()
                                : CoreGUIStyles.GetToggleButtonNormalOff()
                              );

            EditorGUILayout.BeginVertical(CoreGUIStyles.GetBoxExpanded());
            if (GUILayout.Button("Advanced Options", style))
            {
                this.foldoutAdvancedSettings = !this.foldoutAdvancedSettings;
            }

            if (this.foldoutAdvancedSettings)
            {
                EditorGUILayout.PropertyField(this.spMinDistance);
                EditorGUI.BeginDisabledGroup(!this.spMinDistance.boolValue);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(this.spMinDistanceToPlayer);
                EditorGUI.indentLevel--;
                EditorGUI.EndDisabledGroup();
            }

            EditorGUILayout.EndVertical();

            if (this.trigger.gameObject.GetComponent <Hotspot>() == null)
            {
                if (GUILayout.Button("Create Hotspot"))
                {
                    Undo.AddComponent <Hotspot>(this.trigger.gameObject);
                }
            }
        }
Ejemplo n.º 2
0
 public static GUIStyle GetToggleButtonNormalOn()
 {
     if (CoreGUIStyles.btnToggleNormalOn == null)
     {
         CoreGUIStyles.btnToggleNormalOn               = new GUIStyle(CoreGUIStyles.GetToggleButtonNormalOff());
         CoreGUIStyles.btnToggleNormalOn.alignment     = TextAnchor.MiddleLeft;
         CoreGUIStyles.btnToggleNormalOn.normal        = CoreGUIStyles.btnToggleNormalOn.onNormal;
         CoreGUIStyles.btnToggleNormalOn.hover         = CoreGUIStyles.btnToggleNormalOn.onHover;
         CoreGUIStyles.btnToggleNormalOn.active        = CoreGUIStyles.btnToggleNormalOn.onActive;
         CoreGUIStyles.btnToggleNormalOn.focused       = CoreGUIStyles.btnToggleNormalOn.onFocused;
         CoreGUIStyles.btnToggleNormalOn.richText      = true;
         CoreGUIStyles.btnToggleNormalOn.margin.bottom = 0;
     }
     return(CoreGUIStyles.btnToggleNormalOn);
 }
Ejemplo n.º 3
0
        private void PaintItems()
        {
            int  itemsCount   = this.spItems.arraySize;
            int  removeIndex  = -1;
            bool forceRepaint = false;

            GUIContent gcDelete = ClausesUtilities.Get(ClausesUtilities.Icon.Delete);

            for (int i = 0; i < itemsCount; ++i)
            {
                SerializedProperty spItem        = this.spItems.GetArrayElementAtIndex(i);
                SerializedProperty spIOption     = spItem.FindPropertyRelative(PROP_OPTION);
                SerializedProperty spIActions    = spItem.FindPropertyRelative(PROP_ACTIONS);
                SerializedProperty spIConditions = spItem.FindPropertyRelative(PROP_CONDITIONS);

                Rect rectItem = GUILayoutUtility.GetRect(GUIContent.none, CoreGUIStyles.GetToggleButtonNormalOff());

                Rect rectHandle = new Rect(
                    rectItem.x,
                    rectItem.y,
                    25f,
                    rectItem.height
                    );

                Rect rectToggle = new Rect(
                    rectHandle.x + rectHandle.width,
                    rectHandle.y,
                    25f,
                    rectHandle.height
                    );

                Rect rectDelete = new Rect(
                    rectItem.x + (rectItem.width - 25f),
                    rectToggle.y,
                    25f,
                    rectToggle.height
                    );

                Rect rectCont = new Rect(
                    rectToggle.x + rectToggle.width,
                    rectToggle.y,
                    rectItem.width - (rectHandle.width + rectToggle.width + rectDelete.width),
                    rectToggle.height
                    );

                GUI.Label(rectHandle, "=", CoreGUIStyles.GetButtonLeft());
                bool forceSortRepaint = this.sortableList.CaptureSortEvents(rectHandle, i);
                forceRepaint = forceSortRepaint || forceRepaint;

                EditorGUIUtility.AddCursorRect(rectHandle, MouseCursor.Pan);

                GUIContent gcToggle = null;
                if (spIOption.intValue == (int)Trigger.ItemOpts.Actions)
                {
                    gcToggle = GC_ACTIONS;
                }
                if (spIOption.intValue == (int)Trigger.ItemOpts.Conditions)
                {
                    gcToggle = GC_CONDITIONS;
                }

                if (GUI.Button(rectToggle, gcToggle, CoreGUIStyles.GetButtonMid()))
                {
                    switch (spIOption.intValue)
                    {
                    case (int)Trigger.ItemOpts.Actions:
                        spIOption.intValue = (int)Trigger.ItemOpts.Conditions;
                        break;

                    case (int)Trigger.ItemOpts.Conditions:
                        spIOption.intValue = (int)Trigger.ItemOpts.Actions;
                        break;
                    }
                }

                GUI.Label(rectCont, string.Empty, CoreGUIStyles.GetButtonMid());
                Rect rectField = new Rect(
                    rectCont.x + 2f,
                    rectCont.y + (rectCont.height / 2f - EditorGUIUtility.singleLineHeight / 2f),
                    rectCont.width - 7f,
                    EditorGUIUtility.singleLineHeight
                    );

                switch (spIOption.intValue)
                {
                case (int)Trigger.ItemOpts.Actions:
                    EditorGUI.PropertyField(rectField, spIActions, GUIContent.none, true);
                    break;

                case (int)Trigger.ItemOpts.Conditions:
                    EditorGUI.PropertyField(rectField, spIConditions, GUIContent.none, true);
                    break;
                }


                if (GUI.Button(rectDelete, gcDelete, CoreGUIStyles.GetButtonRight()))
                {
                    removeIndex = i;
                }

                this.sortableList.PaintDropPoints(rectItem, i, itemsCount);
            }

            if (removeIndex != -1 && removeIndex < this.spItems.arraySize)
            {
                SerializedProperty spItem        = this.spItems.GetArrayElementAtIndex(removeIndex);
                SerializedProperty spIOption     = spItem.FindPropertyRelative(PROP_OPTION);
                SerializedProperty spIActions    = spItem.FindPropertyRelative(PROP_ACTIONS);
                SerializedProperty spIConditions = spItem.FindPropertyRelative(PROP_CONDITIONS);
                UnityEngine.Object @object       = null;
                switch (spIOption.intValue)
                {
                case (int)Trigger.ItemOpts.Actions: @object = spIActions.objectReferenceValue; break;

                case (int)Trigger.ItemOpts.Conditions: @object = spIConditions.objectReferenceValue; break;
                }

                this.spItems.DeleteArrayElementAtIndex(removeIndex);
            }

            EditorSortableList.SwapIndexes swapIndexes = this.sortableList.GetSortIndexes();
            if (swapIndexes != null)
            {
                this.spItems.MoveArrayElement(swapIndexes.src, swapIndexes.dst);
            }

            if (forceRepaint)
            {
                this.Repaint();
            }
        }