public void DrawTriangles()
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            CommonDrawingUtility.DrawTriangleLines(vertices, m_Indices, 1f, Color.white.AlphaMultiplied(0.35f));
        }
Пример #2
0
 public void DrawSpriteRectBorder()
 {
     if (spriteEditor.selectedSpriteRect != null &&
         Event.current != null && Event.current.type == EventType.Repaint)
     {
         CommonDrawingUtility.BeginLines(Color.green);
         CommonDrawingUtility.DrawBox(spriteEditor.selectedSpriteRect.rect);
         CommonDrawingUtility.EndLines();
     }
 }
Пример #3
0
        public static void DrawBoneBody(Vector3 startPos, Vector3 endPos, Color color, float scale = 1.0f)
        {
            Color c = Handles.color;

            Handles.color = color;

            CommonDrawingUtility.DrawLine(startPos, endPos, Vector3.back, GetBoneRadius(scale), GetBoneRadius(scale) * 0.05f);

            Handles.color = c;
        }
        public void EndDrawEdges()
        {
            if (guiWrapper.eventType != EventType.Repaint)
            {
                return;
            }

            CommonDrawingUtility.EndLines();
            Handles.color = m_TempColor;
        }
        public void BeginDrawEdges()
        {
            if (guiWrapper.eventType != EventType.Repaint)
            {
                return;
            }

            CommonDrawingUtility.BeginSolidLines();
            m_TempColor = Handles.color;
        }
Пример #6
0
        public static void DrawParentLink(Vector3 startPos, Vector3 endPos, Color color, float scale = 1.0f)
        {
            CommonDrawingUtility.DrawLine(startPos, endPos, Vector3.back, GetBoneRadius(scale) * 0.1f, GetBoneRadius(scale) * 0.1f, color);

            var dir            = (startPos - endPos).normalized;
            var arrowTipPoint  = Vector3.Lerp(startPos, endPos, 0.5f);
            var arrowWingPoint = arrowTipPoint + dir * GetBoneRadius(scale);

            // Arrow
            CommonDrawingUtility.DrawLine(arrowWingPoint, arrowTipPoint, Vector3.back, GetBoneRadius(0.7f), 0.0f, color);
        }
Пример #7
0
        public static void DrawBoneOutline(Vector3 startPos, Vector3 endPos, Color color, float scale = 1.0f)
        {
            Color c = Handles.color;

            Handles.color = color;

            CommonDrawingUtility.DrawLine(startPos, endPos, Vector3.back, GetBoneRadius(scale) * 1.25f, GetBoneRadius(scale) * 0.25f);
            Handles.DrawSolidDisc(startPos, Vector3.back, 0.5f * GetBoneRadius(scale) * 1.25f);
            Handles.DrawSolidDisc(endPos, Vector3.back, 0.5f * GetBoneRadius(scale) * 0.25f);

            Handles.color = c;
        }
        private void DrawEdge(Vector2 startPosition, Vector2 endPosition, Color color)
        {
            if (guiWrapper.eventType != EventType.Repaint)
            {
                return;
            }

            Handles.color = color;
            float width = kEdgeWidth / Handles.matrix.m00;

            CommonDrawingUtility.DrawSolidLine(width, startPosition, endPosition);
        }
        private void DrawBindPose()
        {
            Debug.Assert(bindPoseView.IsRepainting());

            for (int i = 0; i < spriteMeshData.bones.Count; i++)
            {
                var spriteBoneData = spriteMeshData.bones[i];
                var color          = CommonDrawingUtility.CalculateNiceColor(i, kNiceColorCount);

                bindPoseView.DrawBone(spriteBoneData.position, spriteBoneData.endPosition, selection.IsSelected(i), bindPoseView.hoveredBone == i, color);
            }
        }
 private void DrawGizmos()
 {
     if (Event.current.type == EventType.Repaint)
     {
         var selected = spriteEditor.selectedSpriteRect;
         if (selected != null)
         {
             CommonDrawingUtility.BeginLines(CommonDrawingUtility.kSpriteBorderColor);
             CommonDrawingUtility.DrawBox(selected.rect);
             CommonDrawingUtility.EndLines();
         }
     }
 }
Пример #11
0
        public void DrawBone(Transform boneTransform, float length, float alpha)
        {
            Debug.Assert(m_GUIWapper.IsRepainting());

            if (!IsBoneVisible(boneTransform, length, alpha))
            {
                return;
            }

            var boneColor         = Color.white.AlphaMultiplied(alpha);
            var boneNodeColor     = Color.gray.AlphaMultiplied(alpha);
            var hoveredBoneColor  = Handles.preselectionColor.AlphaMultiplied(alpha);
            var selectedBoneColor = Handles.selectedColor.AlphaMultiplied(alpha);

            Handles.matrix = boneTransform.localToWorldMatrix;
            var colorTmp = Handles.color;

            var position    = Vector3.zero;
            var endPosition = Vector3.right * length;
            var radius      = GetBoneRadius(position, endPosition);
            var color       = boneColor;

            if (IsSelected(boneTransform))
            {
                color = selectedBoneColor;
            }

            if (IsActionActive(boneTransform, BoneGizmoAction.Rotate))
            {
                color = hoveredBoneColor;
            }

            Handles.color = ToActiveColorSpace(color);
            CommonDrawingUtility.DrawSolidArc(position, Vector3.back, Vector3.Cross(endPosition - position, Vector3.forward), 180f, radius, 8);
            CommonDrawingUtility.DrawLine(position, endPosition, Vector3.back, radius * 2f, radius * 0.1f);

            if (IsActionActive(boneTransform, BoneGizmoAction.Move))
            {
                Handles.color = ToActiveColorSpace(hoveredBoneColor);
                CommonDrawingUtility.DrawSolidArc(position, Vector3.back, Vector3.Cross(endPosition - position, Vector3.forward), 360f, radius, 16);
            }

            Handles.color = ToActiveColorSpace(boneNodeColor);
            CommonDrawingUtility.DrawSolidArc(position, Vector3.back, Vector3.Cross(endPosition - position, Vector3.forward), 360f, radius * 0.55f, 16);

            Handles.color  = colorTmp;
            Handles.matrix = Matrix4x4.identity;
        }
Пример #12
0
        private void PrepareColors()
        {
            Debug.Assert(spriteMeshData != null);

            m_Colors.Clear();

            for (int i = 0; i < spriteMeshData.vertices.Count; ++i)
            {
                BoneWeight boneWeight = m_Weights[i];
                float      weightSum  = boneWeight.weight0 + boneWeight.weight1 + boneWeight.weight2 + boneWeight.weight3;

                var color = CommonDrawingUtility.CalculateNiceColor(boneWeight.boneIndex0, kNiceColorCount) * boneWeight.weight0 +
                            CommonDrawingUtility.CalculateNiceColor(boneWeight.boneIndex1, kNiceColorCount) * boneWeight.weight1 +
                            CommonDrawingUtility.CalculateNiceColor(boneWeight.boneIndex2, kNiceColorCount) * boneWeight.weight2 +
                            CommonDrawingUtility.CalculateNiceColor(boneWeight.boneIndex3, kNiceColorCount) * boneWeight.weight3;

                color.a = 1f;

                m_Colors.Add(Color.Lerp(Color.black, color, weightSum));
            }
        }
        public void OnGUI()
        {
            m_ControlID = GUIUtility.GetControlID("RectSelectionTool".GetHashCode(), FocusType.Passive);

            m_RectVertexSelector.selection = selection;
            m_RectVertexSelector.vertices  = vertices;
            m_RectVertexSelector.rect      = rect;

            Event     ev        = Event.current;
            EventType eventType = ev.GetTypeForControl(m_ControlID);

            if (GUIUtility.hotControl == 0 && HandleUtility.nearestControl == m_ControlID &&
                selection.Count > 0 && eventType == EventType.MouseDown && ev.button == 0 && !ev.alt && !ev.shift)
            {
                Undo.RegisterCompleteObjectUndo(selectionUndoableObject, "Rect Selection");
                selection.Clear();
            }

            if (GUIUtility.hotControl == m_ControlID && eventType == EventType.MouseUp && ev.button == 0)
            {
                Undo.RegisterCompleteObjectUndo(selectionUndoableObject, "Rect Selection");
                selection.EndSelection(true);
            }

            EditorGUI.BeginChangeCheck();

            rect = RectSlider.Do(m_ControlID);

            if (EditorGUI.EndChangeCheck())
            {
                selection.BeginSelection();
                m_RectVertexSelector.Select();
            }

            if (eventType == EventType.Repaint && GUIUtility.hotControl == m_ControlID)
            {
                CommonDrawingUtility.DrawRect(rect, Vector3.zero, Quaternion.identity, new Color(0f, 1f, 1f, 1f), 0.05f, 0.8f);
            }
        }
 public void DrawVertexSelected(Vector2 position)
 {
     CommonDrawingUtility.DrawGUIStyleCap(0, position, Quaternion.identity, 1f, styles.pointSelectedStyle);
 }