Beispiel #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        if (manager == null)
        {
            manager = target as MultiPathManager;
        }


        showPoints = EditorGUILayout.Foldout(showPoints, "Paths");

        if (showPoints)
        {
            if (points != null)
            {
                for (int i = 0; i < points.arraySize; i++)
                {
                    DrawPathEditor(manager.GetPathAtIndex(i), i);
                }
            }

            if (GUILayout.Button("Add Path"))
            {
                Undo.RegisterCompleteObjectUndo(manager, "Add Path");

                GameObject pathObject = new GameObject("Path" + points.arraySize);
                pathObject.transform.parent        = manager.transform;
                pathObject.transform.localPosition = Vector3.zero;
                PathCreator pc = pathObject.AddComponent <PathCreator>();
                points.InsertArrayElementAtIndex(points.arraySize);
                points.GetArrayElementAtIndex(points.arraySize - 1).objectReferenceValue = pc;

                if (pc.path == null)
                {
                    pc.CreatePath();
                }
            }
        }

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(target);
        }

        //foreach (PathCreator pc in manager.paths)
        //{
        //    //draw a custom creation thing here
        //    for (int i = 0; i < pc.path.NumSegments; i++)
        //    {
        //        Vector2[] points = pc.path.GetPointsInSegment(i);
        //        Handles.DrawBezier(points[0], points[3], points[1], points[2], Color.green, null, 2);
        //    }
        //}
    }
Beispiel #2
0
 private void Start()
 {
     manager = GetComponent <MultiPathManager>();
 }
Beispiel #3
0
 public void OnEnable()
 {
     manager = target as MultiPathManager;
     points  = serializedObject.FindProperty("paths");
 }