Пример #1
0
 private static void DrawNavigationArrow(Vector2 direction, Selectable fromObj, Selectable toObj)
 {
     if (!(fromObj == null) && !(toObj == null))
     {
         Transform transform  = fromObj.transform;
         Transform transform2 = toObj.transform;
         Vector2   vector     = new Vector2(direction.y, -direction.x);
         Vector3   vector2    = transform.TransformPoint(SelectableEditor.GetPointOnRectEdge(transform as RectTransform, direction));
         Vector3   vector3    = transform2.TransformPoint(SelectableEditor.GetPointOnRectEdge(transform2 as RectTransform, -direction));
         float     d          = HandleUtility.GetHandleSize(vector2) * 0.05f;
         float     d2         = HandleUtility.GetHandleSize(vector3) * 0.05f;
         vector2 += transform.TransformDirection(vector) * d;
         vector3 += transform2.TransformDirection(vector) * d2;
         float   d3 = Vector3.Distance(vector2, vector3);
         Vector3 b  = transform.rotation * direction * d3 * 0.3f;
         Vector3 b2 = transform2.rotation * -direction * d3 * 0.3f;
         Handles.DrawBezier(vector2, vector3, vector2 + b, vector3 + b2, Handles.color, null, 2.5f);
         Handles.DrawAAPolyLine(2.5f, new Vector3[]
         {
             vector3,
             vector3 + transform2.rotation * (-direction - vector) * d2 * 1.2f
         });
         Handles.DrawAAPolyLine(2.5f, new Vector3[]
         {
             vector3,
             vector3 + transform2.rotation * (-direction + vector) * d2 * 1.2f
         });
     }
 }
Пример #2
0
 protected virtual void OnEnable()
 {
     this.m_Script = base.serializedObject.FindProperty("m_Script");
     this.m_InteractableProperty  = base.serializedObject.FindProperty("m_Interactable");
     this.m_TargetGraphicProperty = base.serializedObject.FindProperty("m_TargetGraphic");
     this.m_TransitionProperty    = base.serializedObject.FindProperty("m_Transition");
     this.m_ColorBlockProperty    = base.serializedObject.FindProperty("m_Colors");
     this.m_SpriteStateProperty   = base.serializedObject.FindProperty("m_SpriteState");
     this.m_AnimTriggerProperty   = base.serializedObject.FindProperty("m_AnimationTriggers");
     this.m_NavigationProperty    = base.serializedObject.FindProperty("m_Navigation");
     this.m_PropertyPathToExcludeForChildClasses = new string[]
     {
         this.m_Script.propertyPath,
         this.m_NavigationProperty.propertyPath,
         this.m_TransitionProperty.propertyPath,
         this.m_ColorBlockProperty.propertyPath,
         this.m_SpriteStateProperty.propertyPath,
         this.m_AnimTriggerProperty.propertyPath,
         this.m_InteractableProperty.propertyPath,
         this.m_TargetGraphicProperty.propertyPath
     };
     Selectable.Transition transition = SelectableEditor.GetTransition(this.m_TransitionProperty);
     this.m_ShowColorTint.value       = (transition == Selectable.Transition.ColorTint);
     this.m_ShowSpriteTrasition.value = (transition == Selectable.Transition.SpriteSwap);
     this.m_ShowAnimTransition.value  = (transition == Selectable.Transition.Animation);
     this.m_ShowColorTint.valueChanged.AddListener(new UnityAction(base.Repaint));
     this.m_ShowSpriteTrasition.valueChanged.AddListener(new UnityAction(base.Repaint));
     SelectableEditor.s_Editors.Add(this);
     this.RegisterStaticOnSceneGUI();
     SelectableEditor.s_ShowNavigation = EditorPrefs.GetBool(SelectableEditor.s_ShowNavigationKey);
 }
Пример #3
0
        private static void DrawNavigationArrow(Vector2 direction, Selectable fromObj, Selectable toObj)
        {
            if ((UnityEngine.Object)fromObj == (UnityEngine.Object)null || (UnityEngine.Object)toObj == (UnityEngine.Object)null)
            {
                return;
            }
            Transform transform1 = fromObj.transform;
            Transform transform2 = toObj.transform;
            Vector2   vector2    = new Vector2(direction.y, -direction.x);
            Vector3   position1  = transform1.TransformPoint(SelectableEditor.GetPointOnRectEdge(transform1 as RectTransform, direction));
            Vector3   position2  = transform2.TransformPoint(SelectableEditor.GetPointOnRectEdge(transform2 as RectTransform, -direction));
            float     num1       = HandleUtility.GetHandleSize(position1) * 0.05f;
            float     num2       = HandleUtility.GetHandleSize(position2) * 0.05f;
            Vector3   vector3_1  = position1 + transform1.TransformDirection((Vector3)vector2) * num1;
            Vector3   vector3_2  = position2 + transform2.TransformDirection((Vector3)vector2) * num2;
            float     num3       = Vector3.Distance(vector3_1, vector3_2);
            Vector3   vector3_3  = transform1.rotation * (Vector3)direction * num3 * 0.3f;
            Vector3   vector3_4  = transform2.rotation * (Vector3)(-direction) * num3 * 0.3f;

            Handles.DrawBezier(vector3_1, vector3_2, vector3_1 + vector3_3, vector3_2 + vector3_4, Handles.color, (Texture2D)null, 2.5f);
            Handles.DrawAAPolyLine(2.5f, new Vector3[2]
            {
                vector3_2,
                vector3_2 + transform2.rotation * (Vector3)(-direction - vector2) * num2 * 1.2f
            });
            Handles.DrawAAPolyLine(2.5f, new Vector3[2]
            {
                vector3_2,
                vector3_2 + transform2.rotation * (Vector3)(-direction + vector2) * num2 * 1.2f
            });
        }
Пример #4
0
        private static AnimatorController GenerateSelectableAnimatorContoller(AnimationTriggers animationTriggers, Selectable target)
        {
            AnimatorController result;

            if (target == null)
            {
                result = null;
            }
            else
            {
                string saveControllerPath = SelectableEditor.GetSaveControllerPath(target);
                if (string.IsNullOrEmpty(saveControllerPath))
                {
                    result = null;
                }
                else
                {
                    string             name  = (!string.IsNullOrEmpty(animationTriggers.normalTrigger)) ? animationTriggers.normalTrigger : "Normal";
                    string             name2 = (!string.IsNullOrEmpty(animationTriggers.highlightedTrigger)) ? animationTriggers.highlightedTrigger : "Highlighted";
                    string             name3 = (!string.IsNullOrEmpty(animationTriggers.pressedTrigger)) ? animationTriggers.pressedTrigger : "Pressed";
                    string             name4 = (!string.IsNullOrEmpty(animationTriggers.disabledTrigger)) ? animationTriggers.disabledTrigger : "Disabled";
                    AnimatorController animatorController = AnimatorController.CreateAnimatorControllerAtPath(saveControllerPath);
                    SelectableEditor.GenerateTriggerableTransition(name, animatorController);
                    SelectableEditor.GenerateTriggerableTransition(name2, animatorController);
                    SelectableEditor.GenerateTriggerableTransition(name3, animatorController);
                    SelectableEditor.GenerateTriggerableTransition(name4, animatorController);
                    AssetDatabase.ImportAsset(saveControllerPath);
                    result = animatorController;
                }
            }
            return(result);
        }
Пример #5
0
        private static AnimatorController GenerateSelectableAnimatorContoller(AnimationTriggers animationTriggers, Selectable target)
        {
            if ((UnityEngine.Object)target == (UnityEngine.Object)null)
            {
                return((AnimatorController)null);
            }
            string saveControllerPath = SelectableEditor.GetSaveControllerPath(target);

            if (string.IsNullOrEmpty(saveControllerPath))
            {
                return((AnimatorController)null);
            }
            string             name1            = !string.IsNullOrEmpty(animationTriggers.normalTrigger) ? animationTriggers.normalTrigger : "Normal";
            string             name2            = !string.IsNullOrEmpty(animationTriggers.highlightedTrigger) ? animationTriggers.highlightedTrigger : "Highlighted";
            string             name3            = !string.IsNullOrEmpty(animationTriggers.pressedTrigger) ? animationTriggers.pressedTrigger : "Pressed";
            string             name4            = !string.IsNullOrEmpty(animationTriggers.disabledTrigger) ? animationTriggers.disabledTrigger : "Disabled";
            AnimatorController controllerAtPath = AnimatorController.CreateAnimatorControllerAtPath(saveControllerPath);

            SelectableEditor.GenerateTriggerableTransition(name1, controllerAtPath);
            SelectableEditor.GenerateTriggerableTransition(name2, controllerAtPath);
            SelectableEditor.GenerateTriggerableTransition(name3, controllerAtPath);
            SelectableEditor.GenerateTriggerableTransition(name4, controllerAtPath);
            AssetDatabase.ImportAsset(saveControllerPath);
            return(controllerAtPath);
        }
Пример #6
0
 private static void StaticOnSceneGUI(SceneView view)
 {
     if (SelectableEditor.s_ShowNavigation)
     {
         for (int i = 0; i < Selectable.allSelectables.Count; i++)
         {
             SelectableEditor.DrawNavigationForSelectable(Selectable.allSelectables[i]);
         }
     }
 }
Пример #7
0
 private static void StaticOnSceneGUI(SceneView view)
 {
     if (!SelectableEditor.s_ShowNavigation)
     {
         return;
     }
     for (int index = 0; index < Selectable.allSelectables.Count; ++index)
     {
         SelectableEditor.DrawNavigationForSelectable(Selectable.allSelectables[index]);
     }
 }
Пример #8
0
 private static void DrawNavigationForSelectable(Selectable sel)
 {
     if (!(sel == null))
     {
         Transform transform = sel.transform;
         bool      flag      = Selection.transforms.Any((Transform e) => e == transform);
         Handles.color = new Color(1f, 0.9f, 0.1f, (!flag) ? 0.4f : 1f);
         SelectableEditor.DrawNavigationArrow(-Vector2.right, sel, sel.FindSelectableOnLeft());
         SelectableEditor.DrawNavigationArrow(Vector2.right, sel, sel.FindSelectableOnRight());
         SelectableEditor.DrawNavigationArrow(Vector2.up, sel, sel.FindSelectableOnUp());
         SelectableEditor.DrawNavigationArrow(-Vector2.up, sel, sel.FindSelectableOnDown());
     }
 }
Пример #9
0
 private static void DrawNavigationForSelectable(Selectable sel)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     SelectableEditor.\u003CDrawNavigationForSelectable\u003Ec__AnonStorey1 selectableCAnonStorey1 = new SelectableEditor.\u003CDrawNavigationForSelectable\u003Ec__AnonStorey1();
     if ((UnityEngine.Object)sel == (UnityEngine.Object)null)
     {
         return;
     }
     // ISSUE: reference to a compiler-generated field
     selectableCAnonStorey1.transform = sel.transform;
     // ISSUE: reference to a compiler-generated method
     Handles.color = new Color(1f, 0.9f, 0.1f, !((IEnumerable <Transform>)Selection.transforms).Any <Transform>(new Func <Transform, bool>(selectableCAnonStorey1.\u003C\u003Em__0)) ? 0.4f : 1f);
     SelectableEditor.DrawNavigationArrow(-Vector2.right, sel, sel.FindSelectableOnLeft());
     SelectableEditor.DrawNavigationArrow(Vector2.right, sel, sel.FindSelectableOnRight());
     SelectableEditor.DrawNavigationArrow(Vector2.up, sel, sel.FindSelectableOnUp());
     SelectableEditor.DrawNavigationArrow(-Vector2.up, sel, sel.FindSelectableOnDown());
 }
Пример #10
0
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            EditorGUILayout.PropertyField(this.m_InteractableProperty, new GUILayoutOption[0]);
            Selectable.Transition transition = SelectableEditor.GetTransition(this.m_TransitionProperty);
            Graphic graphic = this.m_TargetGraphicProperty.objectReferenceValue as Graphic;

            if (graphic == null)
            {
                graphic = (base.target as Selectable).GetComponent <Graphic>();
            }
            Animator animator = (base.target as Selectable).GetComponent <Animator>();

            this.m_ShowColorTint.target       = (!this.m_TransitionProperty.hasMultipleDifferentValues && transition == Selectable.Transition.ColorTint);
            this.m_ShowSpriteTrasition.target = (!this.m_TransitionProperty.hasMultipleDifferentValues && transition == Selectable.Transition.SpriteSwap);
            this.m_ShowAnimTransition.target  = (!this.m_TransitionProperty.hasMultipleDifferentValues && transition == Selectable.Transition.Animation);
            EditorGUILayout.PropertyField(this.m_TransitionProperty, new GUILayoutOption[0]);
            EditorGUI.indentLevel++;
            if (transition == Selectable.Transition.ColorTint || transition == Selectable.Transition.SpriteSwap)
            {
                EditorGUILayout.PropertyField(this.m_TargetGraphicProperty, new GUILayoutOption[0]);
            }
            if (transition != Selectable.Transition.ColorTint)
            {
                if (transition == Selectable.Transition.SpriteSwap)
                {
                    if (graphic as Image == null)
                    {
                        EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Warning);
                    }
                }
            }
            else if (graphic == null)
            {
                EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning);
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowColorTint.faded))
            {
                EditorGUILayout.PropertyField(this.m_ColorBlockProperty, new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowSpriteTrasition.faded))
            {
                EditorGUILayout.PropertyField(this.m_SpriteStateProperty, new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowAnimTransition.faded))
            {
                EditorGUILayout.PropertyField(this.m_AnimTriggerProperty, new GUILayoutOption[0]);
                if (animator == null || animator.runtimeAnimatorController == null)
                {
                    Rect controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
                    controlRect.xMin += EditorGUIUtility.labelWidth;
                    if (GUI.Button(controlRect, "Auto Generate Animation", EditorStyles.miniButton))
                    {
                        AnimatorController animatorController = SelectableEditor.GenerateSelectableAnimatorContoller((base.target as Selectable).animationTriggers, base.target as Selectable);
                        if (animatorController != null)
                        {
                            if (animator == null)
                            {
                                animator = (base.target as Selectable).gameObject.AddComponent <Animator>();
                            }
                            AnimatorController.SetAnimatorController(animator, animatorController);
                        }
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(this.m_NavigationProperty, new GUILayoutOption[0]);
            EditorGUI.BeginChangeCheck();
            Rect controlRect2 = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);

            controlRect2.xMin += EditorGUIUtility.labelWidth;
            SelectableEditor.s_ShowNavigation = GUI.Toggle(controlRect2, SelectableEditor.s_ShowNavigation, this.m_VisualizeNavigation, EditorStyles.miniButton);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool(SelectableEditor.s_ShowNavigationKey, SelectableEditor.s_ShowNavigation);
                SceneView.RepaintAll();
            }
            this.ChildClassPropertiesGUI();
            base.serializedObject.ApplyModifiedProperties();
        }
Пример #11
0
        /// <summary>
        ///   <para>See Editor.OnInspectorGUI.</para>
        /// </summary>
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();
            if (!this.IsDerivedSelectableEditor())
            {
                EditorGUILayout.PropertyField(this.m_Script);
            }
            EditorGUILayout.PropertyField(this.m_InteractableProperty);
            Selectable.Transition transition = SelectableEditor.GetTransition(this.m_TransitionProperty);
            Graphic graphic = this.m_TargetGraphicProperty.objectReferenceValue as Graphic;

            if ((UnityEngine.Object)graphic == (UnityEngine.Object)null)
            {
                graphic = (this.target as Selectable).GetComponent <Graphic>();
            }
            Animator behavior = (this.target as Selectable).GetComponent <Animator>();

            this.m_ShowColorTint.target       = !this.m_TransitionProperty.hasMultipleDifferentValues && transition == Selectable.Transition.ColorTint;
            this.m_ShowSpriteTrasition.target = !this.m_TransitionProperty.hasMultipleDifferentValues && transition == Selectable.Transition.SpriteSwap;
            this.m_ShowAnimTransition.target  = !this.m_TransitionProperty.hasMultipleDifferentValues && transition == Selectable.Transition.Animation;
            EditorGUILayout.PropertyField(this.m_TransitionProperty);
            ++EditorGUI.indentLevel;
            if (transition == Selectable.Transition.ColorTint || transition == Selectable.Transition.SpriteSwap)
            {
                EditorGUILayout.PropertyField(this.m_TargetGraphicProperty);
            }
            switch (transition)
            {
            case Selectable.Transition.ColorTint:
                if ((UnityEngine.Object)graphic == (UnityEngine.Object)null)
                {
                    EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning);
                    break;
                }
                break;

            case Selectable.Transition.SpriteSwap:
                if ((UnityEngine.Object)(graphic as Image) == (UnityEngine.Object)null)
                {
                    EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Warning);
                    break;
                }
                break;
            }
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowColorTint.faded))
            {
                EditorGUILayout.PropertyField(this.m_ColorBlockProperty);
            }
            EditorGUILayout.EndFadeGroup();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowSpriteTrasition.faded))
            {
                EditorGUILayout.PropertyField(this.m_SpriteStateProperty);
            }
            EditorGUILayout.EndFadeGroup();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowAnimTransition.faded))
            {
                EditorGUILayout.PropertyField(this.m_AnimTriggerProperty);
                if ((UnityEngine.Object)behavior == (UnityEngine.Object)null || (UnityEngine.Object)behavior.runtimeAnimatorController == (UnityEngine.Object)null)
                {
                    Rect controlRect = EditorGUILayout.GetControlRect();
                    controlRect.xMin += EditorGUIUtility.labelWidth;
                    if (GUI.Button(controlRect, "Auto Generate Animation", EditorStyles.miniButton))
                    {
                        AnimatorController animatorContoller = SelectableEditor.GenerateSelectableAnimatorContoller((this.target as Selectable).animationTriggers, this.target as Selectable);
                        if ((UnityEngine.Object)animatorContoller != (UnityEngine.Object)null)
                        {
                            if ((UnityEngine.Object)behavior == (UnityEngine.Object)null)
                            {
                                behavior = (this.target as Selectable).gameObject.AddComponent <Animator>();
                            }
                            AnimatorController.SetAnimatorController(behavior, animatorContoller);
                        }
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();
            --EditorGUI.indentLevel;
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(this.m_NavigationProperty);
            EditorGUI.BeginChangeCheck();
            Rect controlRect1 = EditorGUILayout.GetControlRect();

            controlRect1.xMin += EditorGUIUtility.labelWidth;
            SelectableEditor.s_ShowNavigation = GUI.Toggle(controlRect1, SelectableEditor.s_ShowNavigation, this.m_VisualizeNavigation, EditorStyles.miniButton);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool(SelectableEditor.s_ShowNavigationKey, SelectableEditor.s_ShowNavigation);
                SceneView.RepaintAll();
            }
            this.ChildClassPropertiesGUI();
            this.serializedObject.ApplyModifiedProperties();
        }