So I have the following in an OnGUI function:
if(GUI.Button(Rect((Screen.width/2)-50,(Screen.height/2)-yPos, 100, 20), tower.GetComponent("Name").myName+" "+count,"button")){
if(canSummon){
selected = tower;
var targetPos = selected.transform.position;
targetPos.y += selected.transform.localScale.y;
Instantiate(selectron,targetPos,selected.transform.rotation);
}
}
Later in the script I use “selected” to do stuff and that all works just fine. The problem is with the Instantiated selectron object. It’s currently just a cylinder mesh. When I click the button, I see the selectron for about 1/2 second and then it just disappears… I even tried having the button call on a separate function that instantiates the selectron but with the exact same results. Why is my selectron getting destroyed almost the instant it is created??