Exemple #1
0
        void DrawVertices()
        {
            var  vertices = mesh.vertices;
            var  colors   = mesh.colors32;
            int  count    = vertices.Length;
            bool hasColor = (colors != null && colors.Length == count);

            Rect rect = new Rect(0, 0, verticesScreenSize, verticesScreenSize);

            Handles.BeginGUI();
            GUIKit.RecordAndSetColor(verticesColor);

            for (int i = 0; i < count; i++)
            {
                if (hasColor)
                {
                    GUI.color = colors[i];
                }

                rect.position = verticesScreenOffset +
                                HandleUtility.WorldToGUIPoint(transform.TransformPoint(vertices[i]));

                GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture);
            }

            GUIKit.RestoreColor();
            Handles.EndGUI();
        }
Exemple #2
0
        void DrawBounds()
        {
            GUIKit.RecordAndSetHandlesMatrix(transform.localToWorldMatrix);

            GUIKit.RecordAndSetHandlesColor(boundsColor);
            GUIKit.HandlesDrawWireLocalBounds(mesh.bounds);
            GUIKit.RestoreHandlesColor();

            GUIKit.RestoreHandlesMatrix();
        }
        void OnSceneGUI()
        {
            var rigidbody = target as Rigidbody;

            Vector3 center     = rigidbody.worldCenterOfMass;
            Vector3 normal     = SceneView.currentDrawingSceneView.rotation * Vector3.back;
            float   handleSize = HandleUtility.GetHandleSize(center);

            GUIKit.RecordAndSetHandlesColor(bigDiscColor);
            Handles.DrawSolidDisc(center, normal, bigDiscSize * handleSize);
            GUIKit.RestoreHandlesColor();

            GUIKit.RecordAndSetHandlesColor(smallDiscColor);
            Handles.DrawSolidDisc(center, normal, smallDiscSize * handleSize);
            GUIKit.RestoreHandlesColor();
        }
Exemple #4
0
        void DrawNormals()
        {
            GUIKit.RecordAndSetHandlesMatrix(transform.localToWorldMatrix);

            var normals = mesh.normals;

            if (!Kit.IsNullOrEmpty(normals))
            {
                int count    = normals.Length;
                var vertices = mesh.vertices;

                GUIKit.RecordAndSetHandlesColor(normalsColor);
                for (int i = 0; i < count; i++)
                {
                    GUIKit.HandlesDrawAALine(vertices[i], vertices[i] + normals[i] * normalsSize);
                }
                GUIKit.RestoreHandlesColor();
            }

            GUIKit.RestoreHandlesMatrix();
        }