SOLVED Replace the WayPoints with a GameObject
Hello. I am trying to replace the WayPoints with a GameObject public variable. But I can't get it using the following line.
public GameObject CustomWayPoints;
newPath.GetComponent<PathManager>().replaceObject = CustomWayPoints;
The new object appears inside the ReplaceObject but the "Replace Now" button needs to be activated with the script. How can I activate "Replace Now"?
the "replaceObject" is only used for the editor script, PathEditor. Setting this via code, but not using the editor inspector will not have any effect.
If you would like to run the code behind it on your own, you could have a look at the "Replace Now" code for reference. It starts in the PathEditor script at line 544.
Note: the PathManager.waypoints variable is an array of Transforms. Basically you need to replace these Transforms with your own waypoints (or copy and modify the "Replace Now" code as mentioned before).