So i’m new here.
I instantiate a product by clicking on an item. this makes product(clone) in my game from a prefab.
but the destroy won’t work when I press a button in my GUI window. all code is in the same script.
private GameObject product;
void OnMouseDown(){
GameObject product = (GameObject)Instantiate(productPrefab, new Vector3(24.98F, 32.76F, 16.5464F), Quaternion.identity);
}
public void DoMyWindow (int windowID)
{
if (GUI.Button (new Rect (30,160,100,20), "More info")){
//
}
if (GUI.Button (new Rect (30,180,100,20), "Close window")){
showWindow = false;
GameObject.Find("ProductCamera").camera.enabled = false;
Destroy(product);
}
}
}