Beispiel #1
0
        void OnSceneGUI(SceneView sceneView)
        {
            sceneManipulator.OnSceneGUI(sceneView);

            // Do your drawing here using Handles.
            Handles.BeginGUI();
            // Do your drawing here using GUI.

            //	Gizmos.DrawCube(Vector3.zero, Vector3.one);

            Handles.EndGUI();
        }
Beispiel #2
0
        void OnSceneGUI(SceneView sceneView)
        {
            sceneManipulator.OnSceneGUI(sceneView);

            if (Event.current.type == EventType.Repaint)
            {
                if (sceneManipulator.GetCurrentTool() == ToolSelection.TrianglePainting)
                {
                    Handles.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);

                    int pickRadius = sceneManipulator.GetBrushPixelSize();

                    Ray centerRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                    Ray rightRay  = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition + new Vector2(pickRadius, 0.0f));
                    Ray upRay     = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition + new Vector2(0.0f, pickRadius));

                    Vector3 centerPos = centerRay.origin + centerRay.direction;
                    Vector3 upPos     = upRay.origin + upRay.direction;
                    Vector3 rightPos  = rightRay.origin + rightRay.direction;

                    Vector3 upVec    = upPos - centerPos;
                    Vector3 rightVec = rightPos - centerPos;

                    List <Vector3> points = new List <Vector3>();

                    int numSegments = 20;

                    for (int i = 0; i < numSegments; i++)
                    {
                        float angle0 = (float)i / (float)numSegments * Mathf.PI * 2.0f;
                        float angle1 = (float)(i + 1) / (float)numSegments * Mathf.PI * 2.0f;

                        Vector3 p0 = centerPos + (rightVec * Mathf.Cos(angle0)) + (upVec * Mathf.Sin(angle0));
                        Vector3 p1 = centerPos + (rightVec * Mathf.Cos(angle1)) + (upVec * Mathf.Sin(angle1));

                        points.Add(p0);
                        points.Add(p1);
                    }

                    Handles.DrawLines(points.ToArray());
                }
            }
        }