Esempio n. 1
0
 protected void HandlePivotHandle()
 {
     if (this.hasSelected)
     {
         EditorGUI.BeginChangeCheck();
         SpriteAlignment alignment          = this.selectedSpriteAlignment;
         Vector2         vector             = this.selectedSpritePivot;
         Rect            selectedSpriteRect = this.selectedSpriteRect;
         vector = SpriteFrameModuleBase.ApplySpriteAlignmentToPivot(vector, selectedSpriteRect, alignment);
         Vector2 vector2 = SpriteEditorHandles.PivotSlider(selectedSpriteRect, vector, SpriteFrameModuleBase.styles.pivotdot, SpriteFrameModuleBase.styles.pivotdotactive);
         if (EditorGUI.EndChangeCheck())
         {
             if (this.eventSystem.current.control)
             {
                 this.SnapPivot(vector2, out vector, out alignment);
             }
             else
             {
                 vector    = vector2;
                 alignment = SpriteAlignment.Custom;
             }
             this.SetSpritePivotAndAlignment(vector, alignment);
         }
     }
 }
        protected void HandlePivotHandle()
        {
            if (!hasSelected)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();

            SpriteAlignment alignment = selectedSpriteAlignment;
            Vector2         pivot     = selectedSpritePivot;
            Rect            rect      = selectedSpriteRect;

            pivot = ApplySpriteAlignmentToPivot(pivot, rect, alignment);
            Vector2 pivotHandlePosition = SpriteEditorHandles.PivotSlider(rect, pivot, styles.pivotdot, styles.pivotdotactive);

            if (EditorGUI.EndChangeCheck())
            {
                // Pivot snapping only happen when ctrl is press. Same as scene view snapping move
                if (eventSystem.current.control)
                {
                    SnapPivot(pivotHandlePosition, out pivot, out alignment);
                }
                else
                {
                    pivot     = pivotHandlePosition;
                    alignment = SpriteAlignment.Custom;
                }
                SetSpritePivotAndAlignment(pivot, alignment);
                PopulateSpriteFrameInspectorField();
            }
        }