Edit String of instantiated Object then save it.

First Post!

I have a user instantiating an object at the location they are looking using ray casting.
Once the object is placed they can click on it which opens a GUI box were they can input text into a string.

Here is the problem:
After I instantiate one I can click on it and edit the string, no problem. After the second one is placed. I can click on it, and it opens the for mentioned GUI text box, i enter text into the text box, and it changes the string for the first one i created, leaving the second still set to null.


function OnGUI()
    if(editingHotspot == true)
    		//The Box
    		GUI.Box(Rect(0,0,Screen.width+10,Screen.height+10),"Hotspot Editor");
    		//Exit Button
    		if (GUI.Button(Rect(Screen.width/2 - 150,Screen.height/2 + 20,120,30),"Save and Exit"))
    			editingHotspot = false;
    		GUI.Label(Rect(Screen.width/2-400,Screen.height/2-230, 100, 30), "Enter Name:");
    		hotspotName = GUI.TextField(Rect(Screen.width/2-400,Screen.height/2-200, 200, 25), hotspotName, 40);

FIXED: the editingHotspot variable was static and because of that ALL of the GUI function were getting triggered to true, causing them to draw over each other. I just never realized it. This is also why i could only change the first one.

Thanks for everybody’s time.