Example #1
0
        protected virtual void OnSceneGUI()
        {
            ExamplePath ep = target as ExamplePath;

            if (!ep)
            {
                return;
            }

            if (!ep.viewHandles)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            for (int i = 0; i < ep.points.Count; ++i)
            {
                Vector3 epAsV3 = new Vector3(ep.points[i].x, ep.points[i].y, 0);
                epAsV3       = ep.transform.InverseTransformPoint(Handles.PositionHandle(ep.transform.TransformPoint(epAsV3), Quaternion.identity));
                ep.points[i] = new Vector2(epAsV3.x, epAsV3.y);
            }
            if (EditorGUI.EndChangeCheck())
            {
            }
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            ExamplePath ep = target as ExamplePath;

            if (!ep)
            {
                return;
            }

            if (GUILayout.Button("Add vertex"))
            {
                Undo.RecordObject(ep, "Add vertex to path");
                ep.__AddPoint();
                repaintScene();
            }
            if (GUILayout.Button("Reset vertices"))
            {
                Undo.RecordObject(ep, "Reset path vertices");
                ep.__Reset();
                repaintScene();
            }
            if (GUILayout.Button("Triangulate"))
            {
                Undo.RecordObject(ep, "Triangulate path");
                ep.__Triangulate();
                repaintScene();
            }
            GUILayout.Label("Vertex count: " + ep.points.Count);
            GUILayout.Label("Triangle count: " + ep.triangles.Count);
        }