Hello everyone.
I made a custom editor script.
The script is meant to go over all gameObject that has a specified tag and do something to them.
I want to let the user tell me what was the tag he used for the gameObject that my code will modify.
Here is what I did:
[CustomEditor(typeof(myScript))]
public class myScriptEditor : Editor {
private string Tag1,Tag2 = "";
private GameObject[] GO1,GO1;
public override void OnInspectorGUI() {
Tag1 = EditorGUILayout.TagField("Tag for GO1:",Tag1);
Tag2 = EditorGUILayout.TagField("Tag for GO2:",Tag2);
GO1 = GameObject.FindGameObjectsWithTag(Tag1);
GO2 = GameObject.FindGameObjectsWithTag(Tag2);
}
}
**myScript is just a newly created c# script (empty) that I placed on a gameObject.
My problem is that once I chose a tag then select a different gameObject (that has nothing to do with this), when I select the first gameObject, the tags are empty again.
I want the tags to stay as I selected them before.
I’m very new to creating custom editor so I’m clueless.
Thanks.