예제 #1
0
    private void CreateMidpoint(Waypoint a, Waypoint b)
    {
        if (waypoint.waypointPrefab != null)
        {
            Waypoint c = Object.Instantiate(waypoint.gameObject, (a.transform.position + b.transform.position) / 2, Quaternion.identity, a.transform.parent).GetComponent <Waypoint>();
            if (a.neighbors.Contains(b))
            {
                a.Remove(b);
            }
            if (b.neighbors.Contains(a))
            {
                b.Remove(a);
            }
            c.neighbors = new List <Waypoint>();
            c.Add(a);
            c.Add(b);

            if (!c.oneWay)
            {
                a.Add(c);
                b.Add(c);
            }

            Selection.activeGameObject = c.gameObject;
        }
    }
    public override void OnInspectorGUI()
    {
        serializedTarget.Update();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Waypoint", GUILayout.Width(120)))
        {
            Point.Add();
        }
        if (GUILayout.Button("Remove Waypoint", GUILayout.Width(120)))
        {
            Point.Remove();
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.PropertyField(isLoop);

        ShowIndexManipulate = EditorGUILayout.Foldout(ShowIndexManipulate, "Index-based Insert/Remove");
        if (ShowIndexManipulate)
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(listIndex);
            if (GUILayout.Button("Add at Index", GUILayout.Width(120)))
            {
                Point.Insert();
            }
            if (GUILayout.Button("Remove at Index", GUILayout.Width(120)))
            {
                Point.RemoveAt();
            }
            GUILayout.EndHorizontal();
        }

        ShowColorsMenu = EditorGUILayout.Foldout(ShowColorsMenu, "Color Settings");
        if (ShowColorsMenu)
        {
            EditorGUILayout.PropertyField(lineColor);
            EditorGUILayout.PropertyField(gizmoColor);
        }
        ShowLineMenu = EditorGUILayout.Foldout(ShowLineMenu, "Line Settings");
        if (ShowLineMenu)
        {
            EditorGUILayout.PropertyField(lineType);
            EditorGUILayout.PropertyField(lineSpacing);
        }
        ShowGUIMenu = EditorGUILayout.Foldout(ShowGUIMenu, "GUI Settings");
        if (ShowGUIMenu)
        {
            EditorGUILayout.PropertyField(fontSize);
            EditorGUILayout.PropertyField(gizmoSize);
        }

        EditorGUILayout.PropertyField(PointList);

        serializedTarget.ApplyModifiedProperties();
    }
예제 #3
0
    public void CreateNeighbor()
    {
        if (Selection.objects.Length > 1)
        {
            Debug.Log("Too many waypoints selected, adjacent nodes would be ambiguous.");
            return;
        }
        Waypoint newPoint = Object.Instantiate(waypointPrefab, transform.parent).GetComponent <Waypoint>();

        newPoint.neighbors = new List <Waypoint>();
        newPoint.Add(this);
        if (!oneWay)
        {
            Add(newPoint);
        }
        Selection.activeGameObject = newPoint.gameObject;
    }