GetPivotValue() public static method

public static GetPivotValue ( SpriteAlignment alignment, Vector2 customOffset ) : Vector2
alignment SpriteAlignment
customOffset Vector2
return Vector2
コード例 #1
0
        private void DoPivotGUI()
        {
            EditorGUI.BeginChangeCheck();
            int num = EditorGUILayout.Popup("Pivot", SpriteEditorMenu.s_Setting.spriteAlignment, this.spriteAlignmentOptions, new GUILayoutOption[0]);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo((UnityEngine.Object)SpriteEditorMenu.s_Setting, "Change Alignment");
                SpriteEditorMenu.s_Setting.spriteAlignment = num;
                SpriteEditorMenu.s_Setting.pivot           = SpriteEditorUtility.GetPivotValue((SpriteAlignment)num, SpriteEditorMenu.s_Setting.pivot);
            }
            Vector2 pivot = SpriteEditorMenu.s_Setting.pivot;

            EditorGUI.BeginChangeCheck();
            EditorGUI.BeginDisabledGroup(num != 9);
            Vector2 vector2 = EditorGUILayout.Vector2Field("Custom Pivot", pivot);

            EditorGUI.EndDisabledGroup();
            if (!EditorGUI.EndChangeCheck())
            {
                return;
            }
            Undo.RegisterCompleteObjectUndo((UnityEngine.Object)SpriteEditorMenu.s_Setting, "Change custom pivot");
            SpriteEditorMenu.s_Setting.pivot = vector2;
        }
コード例 #2
0
        private void DoPivotGUI()
        {
            EditorGUI.BeginChangeCheck();
            int alignment = s_Setting.spriteAlignment;

            alignment = EditorGUILayout.Popup(s_Styles.pivotLabel, alignment, s_Styles.spriteAlignmentOptions);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(s_Setting, "Change Alignment");
                s_Setting.spriteAlignment = alignment;
                s_Setting.pivot           = SpriteEditorUtility.GetPivotValue((SpriteAlignment)alignment, s_Setting.pivot);
            }

            Vector2 pivot = s_Setting.pivot;

            EditorGUI.BeginChangeCheck();
            using (new EditorGUI.DisabledScope(alignment != (int)SpriteAlignment.Custom))
            {
                pivot = EditorGUILayout.Vector2Field(s_Styles.customPivotLabel, pivot);
            }
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(s_Setting, "Change custom pivot");

                s_Setting.pivot = pivot;
            }
        }
コード例 #3
0
        private void DoPivotGUI()
        {
            EditorGUI.BeginChangeCheck();
            int num = SpriteEditorMenu.s_Setting.spriteAlignment;

            num = EditorGUILayout.Popup(SpriteEditorMenu.s_Styles.pivotLabel, num, SpriteEditorMenu.s_Styles.spriteAlignmentOptions, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(SpriteEditorMenu.s_Setting, "Change Alignment");
                SpriteEditorMenu.s_Setting.spriteAlignment = num;
                SpriteEditorMenu.s_Setting.pivot           = SpriteEditorUtility.GetPivotValue((SpriteAlignment)num, SpriteEditorMenu.s_Setting.pivot);
            }
            Vector2 vector = SpriteEditorMenu.s_Setting.pivot;

            EditorGUI.BeginChangeCheck();
            using (new EditorGUI.DisabledScope(num != 9))
            {
                vector = EditorGUILayout.Vector2Field(SpriteEditorMenu.s_Styles.customPivotLabel, vector, new GUILayoutOption[0]);
            }
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(SpriteEditorMenu.s_Setting, "Change custom pivot");
                SpriteEditorMenu.s_Setting.pivot = vector;
            }
        }
コード例 #4
0
        private void DoPivotGUI()
        {
            EditorGUI.BeginChangeCheck();
            int spriteAlignment = s_Setting.spriteAlignment;

            spriteAlignment = EditorGUILayout.Popup("Pivot", spriteAlignment, this.spriteAlignmentOptions, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(s_Setting, "Change Alignment");
                s_Setting.spriteAlignment = spriteAlignment;
                s_Setting.pivot           = SpriteEditorUtility.GetPivotValue((SpriteAlignment)spriteAlignment, s_Setting.pivot);
            }
            Vector2 pivot = s_Setting.pivot;

            EditorGUI.BeginChangeCheck();
            EditorGUI.BeginDisabledGroup(spriteAlignment != 9);
            pivot = EditorGUILayout.Vector2Field("Custom Pivot", pivot, new GUILayoutOption[0]);
            EditorGUI.EndDisabledGroup();
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(s_Setting, "Change custom pivot");
                s_Setting.pivot = pivot;
            }
        }