Hi,
Through the inspector I can set the size of the number of waypoints per path. How can I initialize it through code. I am stuck on how get the AddWaypoints() to change the element size of the waypoint array per path.
Ultimately I am trying to make an editor script that allows me to click in the scene view and generate way points that will be fed into the way points array of each path. This is triggered by a button in the inspector. And it happens with play mode OFF.
Any help is appreciated. These are the 2 classes:
using System;
using UnityEngine;
[Serializable]
public class PatrolPath
{
public Transform[] waypoints;
}
The other 1 is:
using UnityEngine;
public class UnitSpawner : MonoBehaviour
{
public PatrolPath[] paths;
private int _pathCount = 0;
private int _waypointCount = 0;
public void CreateNewPath()
{
_pathCount++;
// Generate a new path object
paths = new PatrolPath[_pathCount];
}
public void AddWaypoints()
{
_waypointCount++;
// Waypoint array is size 0 right now
// Increase array size somehow???
new paths[_pathCount].wayPoints[_waypointCount];
}
}