Esempio n. 1
0
    void AddWaypoint()
    {
        AutoWaypoint[] waypoints    = PathFinder.AllWayPoints();
        string         waypointName = "Waypoint XXX";

        for (int i = 0; i < 1000; ++i)
        {
            waypointName = String.Format("Waypoint{0:0##}", i);
            bool found = false;
            foreach (AutoWaypoint wp in waypoints)
            {
                if (wp.name == waypointName)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                break;
            }
        }

        GameObject waypoint = new GameObject(waypointName, new Type[] { typeof(AutoWaypoint) });

        waypoint.transform.position            = new Vector3(waypoint.transform.position.x, 0.0f, waypoint.transform.position.z);
        waypoint.transform.parent              = this.transform;
        UnityEditor.Selection.activeGameObject = waypoint;
    }