I am encountering a bug in a game I am trying to make. I am getting the following error.
NullReferenceException: Object reference not set to an instance of an object
This same code works fine in one of my other scripts but in this one it continues to through this error. I thought I set it to an instance of the object but I guess not.
UnityEngine.Component book001GUIOld = GameObject.FindWithTag("Book001Canvas").GetComponent("Canvas");
UnityEngine.Behaviour book001GUI = (UnityEngine.Behaviour)book001GUIOld;
Any Suggestions? Let me know if you need more of the code. I have also tried.
UnityEngine.Behaviour book001GUI = GameObject.FindWithTag("Book001Canvas").GetComponent("Canvas") as behaviour;