I have a set of transform objects with tag = “waypoint” and i have a enemy gameobject.
Now when ever i duplicate a waypoint transform in editor it should automatically add to the enemy script which has a list of transform.
Is this achievable through editor scripting.
I am new to editor scripting and using this code.
public class EnemyTest : MonoBehaviour {
public List<Transform> wayPointList;
}
[CustomEditor(typeof(EnemyTest))]
public class EnemyPathEditor : Editor {
public override void OnInspectorGUI (){
DrawDefaultInspector();
EnemyTest enemy = target as EnemyTest;
GameObject [] wayPoint = GameObject.FindGameObjectsWithTag("Waypoint");
for(int i=0; i<wayPoint.Length; i++){
GameObject wayPointGameObj = EditorGUILayout.ObjectField(wayPoint*, typeof(GameObject), true) as GameObject;*
-
enemy.wayPointList.Add(wayPointGameObj.transform);*
-
}*
- }*
}
Now whenever i am clicking on enemy the waypoint transforms are getting added continuously.
First i want it to add only the given amount of waypoints which is there in the scene.
Second i want the list to add waypoint automatically whenever i duplicate a gameobject.