Hi all
I am making a toggle script so when you click on the toggle you can hide/show objects.
However I am getting this error:
MissingReferenceException: The object of type ‘Object’ has been destroyed but you are still trying to access it.
Here is the code:
public GameObject[] objects;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
foreach (GameObject go in objects) {
bool active=GUILayout.Toggle (go.activeSelf, go.name);
if (active != go.activeSelf)
go.SetActive (active);
}
}
}
I need help in identifying and solving the problem.
Thanks