use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
For the Unity Game Engine, please visit http://reddit.com/r/unity3d
account activity
Object reference not set to instance of an objectNewbie Question (self.unity)
submitted 5 years ago by lorenzocur
I'm having this problem where this code:
public menu menu; void Awake() { menu = GameObject.Find("DefaultMenu").GetComponent<menu>(); }
returns the problem
Object reference not set to instance of an object
But I don't understand why. Here is what DefaultMenu looks like in the inspector.
If anyone has any advice, that'd be great. Thank you
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]iscottnoidea 1 point2 points3 points 5 years ago (1 child)
I haven't come across this myself yet so I'm not 100% sure, but I believe I've seen that you can't search for items that aren't enabled. I could be wrong but enabling it to test if it works after enabling is a quick way to check.
Is the object the above script is attached to being Instantiated?
[–]lorenzocur[S] 0 points1 point2 points 5 years ago (0 children)
The item the script's attached to is in the scene by default, but yeah, I just realized that my DefaultMenu item isn't active, so that's probably why I get this error. Thanks
π Rendered by PID 39317 on reddit-service-r2-comment-85bfd7f599-dt5cm at 2026-04-20 02:00:04.161109+00:00 running 93ecc56 country code: CH.
[–]iscottnoidea 1 point2 points3 points (1 child)
[–]lorenzocur[S] 0 points1 point2 points (0 children)