I’m looking to generate an array of Vector3 using an Editor extension script, then use that generated array in RunTime.
As it stands I can generate a array using an Editor script no problem, however as soon as that function completes the array is not “saved” for use in RunTime.
Editor Extension Script
[CustomEditor( typeof(GridTest) )]
public class GridTestEditor : Editor {
GridTest gd;
public int gridSize = 10;
// Use this for initialization
void OnEnable () {
gd = (GridTest)target;
}
// Update is called once per frame
override public void OnInspectorGUI() {
gridSize = EditorGUILayout.IntField(gridSize);
if(GUILayout.Button("Generate Grid")){
GenerateGrid();
}
}
void GenerateGrid(){
gd.gridData.Clear();
for(int x = 0;x < gridSize;x++){
for(int z = 0;z < gridSize;z++){
GridPoint gp = new GridPoint();
gp.position = new Vector3(x,0,z);
gd.gridData.Add(gp);
Debug.Log(gp.position);
}
}
}
}
Grid class and GridPoint Object
public class GridTest : MonoBehaviour {
public List<GridPoint> gridData = new List<GridPoint>();
// Use this for initialization
void Start () {
foreach(GridPoint gridPoint in gridData){
Debug.Log(gridPoint.position);
}
}
}
public class GridPoint : Object {
public Vector3 position;
}
On start up the GridPoint objects loose there assigned Vector3
Could anyone point me towards what I need to be doing in order to use this generated array?
Cheers, C.