Exemplo n.º 1
0
        protected float HandleBorderScaleSlider(float x, float y, float width, float height, bool isHorizontal)
        {
            float   handleSize = styles.dragBorderdot.fixedWidth;
            Vector2 point      = Handles.matrix.MultiplyPoint(new Vector2(x, y));
            float   result;

            EditorGUI.BeginChangeCheck();

            if (isHorizontal)
            {
                Rect newRect = new Rect(point.x - handleSize * .5f, point.y, handleSize, height);
                result = SpriteEditorHandles.ScaleSlider(point, MouseCursor.ResizeHorizontal, newRect).x;
            }
            else
            {
                Rect newRect = new Rect(point.x, point.y - handleSize * .5f, width, handleSize);
                result = SpriteEditorHandles.ScaleSlider(point, MouseCursor.ResizeVertical, newRect).y;
            }

            if (EditorGUI.EndChangeCheck())
            {
                return(result);
            }

            return(isHorizontal ? x : y);
        }
Exemplo n.º 2
0
        protected float HandleBorderScaleSlider(float x, float y, float width, float height, bool isHorizontal)
        {
            float   fixedWidth = SpriteFrameModuleBase.styles.dragBorderdot.fixedWidth;
            Vector2 pos        = Handles.matrix.MultiplyPoint(new Vector2(x, y));

            EditorGUI.BeginChangeCheck();
            float num;

            if (isHorizontal)
            {
                Rect cursorRect = new Rect(pos.x - fixedWidth * 0.5f, pos.y, fixedWidth, height);
                num = SpriteEditorHandles.ScaleSlider(pos, MouseCursor.ResizeHorizontal, cursorRect).x;
            }
            else
            {
                Rect cursorRect2 = new Rect(pos.x, pos.y - fixedWidth * 0.5f, width, fixedWidth);
                num = SpriteEditorHandles.ScaleSlider(pos, MouseCursor.ResizeVertical, cursorRect2).y;
            }
            float result;

            if (EditorGUI.EndChangeCheck())
            {
                result = num;
            }
            else
            {
                result = ((!isHorizontal) ? y : x);
            }
            return(result);
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 5
0
 private void HandleCreate()
 {
     if (!base.MouseOnTopOfInspector() && !base.eventSystem.current.alt)
     {
         EditorGUI.BeginChangeCheck();
         Rect rect = SpriteEditorHandles.RectCreator((float)base.textureActualWidth, (float)base.textureActualHeight, SpriteFrameModuleBase.styles.createRect);
         if (EditorGUI.EndChangeCheck() && rect.width > 0f && rect.height > 0f)
         {
             this.CreateSprite(rect);
             GUIUtility.keyboardControl = 0;
         }
     }
 }
Exemplo n.º 6
0
 private void HandleCreate()
 {
     if (!MouseOnTopOfInspector() && !eventSystem.current.alt)
     {
         // Create new rects via dragging in empty space
         EditorGUI.BeginChangeCheck();
         Rect newRect = SpriteEditorHandles.RectCreator(textureActualWidth, textureActualHeight, styles.createRect);
         if (EditorGUI.EndChangeCheck() && newRect.width > 0f && newRect.height > 0f)
         {
             CreateSprite(newRect);
             GUIUtility.keyboardControl = 0;
         }
     }
 }
Exemplo n.º 7
0
        protected void HandleBorderPointSlider(ref float x, ref float y, MouseCursor mouseCursor, bool isHidden, GUIStyle dragDot, GUIStyle dragDotActive, Color color)
        {
            Color color2 = GUI.color;

            if (isHidden)
            {
                GUI.color = new Color(0f, 0f, 0f, 0f);
            }
            else
            {
                GUI.color = color;
            }
            Vector2 vector = SpriteEditorHandles.PointSlider(new Vector2(x, y), mouseCursor, dragDot, dragDotActive);

            x         = vector.x;
            y         = vector.y;
            GUI.color = color2;
        }
Exemplo n.º 8
0
        protected void HandleBorderPointSlider(ref float x, ref float y, MouseCursor mouseCursor, bool isHidden, GUIStyle dragDot, GUIStyle dragDotActive, Color color)
        {
            var originalColor = GUI.color;

            if (isHidden)
            {
                GUI.color = new Color(0, 0, 0, 0);
            }
            else
            {
                GUI.color = color;
            }

            Vector2 point = SpriteEditorHandles.PointSlider(new Vector2(x, y), mouseCursor, dragDot, dragDotActive);

            x = point.x;
            y = point.y;

            GUI.color = originalColor;
        }
Exemplo n.º 9
0
        private void HandleDragging()
        {
            if (hasSelected && !MouseOnTopOfInspector())
            {
                Rect textureBounds = new Rect(0, 0, textureActualWidth, textureActualHeight);
                EditorGUI.BeginChangeCheck();

                Rect oldRect = selectedSpriteRect;
                Rect newRect = SpriteEditorUtility.ClampedRect(SpriteEditorUtility.RoundedRect(SpriteEditorHandles.SliderRect(oldRect)), textureBounds, true);

                if (EditorGUI.EndChangeCheck())
                {
                    selectedSpriteRect = newRect;
                }
            }
        }
Exemplo n.º 10
0
 private void HandleDragging()
 {
     if (base.hasSelected && !base.MouseOnTopOfInspector())
     {
         Rect clamp = new Rect(0f, 0f, (float)base.textureActualWidth, (float)base.textureActualHeight);
         EditorGUI.BeginChangeCheck();
         Rect selectedSpriteRect  = base.selectedSpriteRect;
         Rect selectedSpriteRect2 = SpriteEditorUtility.ClampedRect(SpriteEditorUtility.RoundedRect(SpriteEditorHandles.SliderRect(selectedSpriteRect)), clamp, true);
         if (EditorGUI.EndChangeCheck())
         {
             base.selectedSpriteRect = selectedSpriteRect2;
         }
     }
 }