- Home /
Allocating Game Object name dynamically using Find
Hello,
I am having a problem accessing Game objects dynamically.
I have created a dictionary containing all game objects names, as well as the new instances I will be creating at run time.
The following error occurs at run time: " NullReference Exception: Object Reference not set in an instance of an object...etc"
I am trying to execute a code similar to this:
string name=checkDictionary(Id); // returns the name of a game object
Debug.Log(name); // prints the name correctly, the GameObject exists
Transform x = GameObject.Find(name).transform;
The above code works if I explicitly indicate the name of the game object, GameObject.Find("SomeName").transform;
I appreciate the help...Thanks in advance,
Regards
Your answer
Follow this Question
Related Questions
How to use if statement properly 1 Answer
NullReferenceException 2 Answers
NullReferenceException in follow function 0 Answers
Why does this Instantiate give a Null Reference Exception? 1 Answer
node null reference 1 Answer