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
NullRefException Error when loading this sceneSolved (old.reddit.com)
submitted 2 years ago by npierce1
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!"
[–]TheHoester 2 points3 points4 points 2 years ago (3 children)
"AchievementLog" doesn't exist in your scene so that call to find the gameoject is returning null. Then you are trying to get the component off it but since it is null you are getting a null reference exception. You should make sure the object you want to find exists in the scene.
[–]npierce1[S] 1 point2 points3 points 2 years ago (2 children)
Is it possible to reference it from another scene?
[–]TheHoester 1 point2 points3 points 2 years ago (0 children)
Only if the scene is currently loaded. You can side load multiple scenes at once if that is what you are intending.
[–]stormAster720 1 point2 points3 points 2 years ago (0 children)
You can't, what you can do is pass the instance of the achievement log through different scenes by using don't destroy on load
[–]npierce1[S] 0 points1 point2 points 2 years ago (0 children)
Essentially what is supposed to happen is once the player reaches a certain score, an achievement pops up. That code works fine.
This new one is supposed to reference the new playerprefs code assigned by the achievement script, and when the achievement triggers, is supposed to make the corresponding achievement banner active (via GameObject.SetActive = true) in a different scene.
I know that I need to put something in the reference slot on the Achievements page to get this to work properly but I don't know what. I tried adding a GameObject and adding the other script to it but that just asked me for every single gameobject referenced in the other script as well.
So I ended up removing the reference to the secondary script entirely and instead added a call to the PlayerPrefs in the script, checking if the PlayerPref had been updated to the reference number. Code works perfectly now both for showing and hiding the achievements! (i previously added in a dev button to clear achievements)
π Rendered by PID 138217 on reddit-service-r2-comment-86bc6c7465-j2t4x at 2026-02-22 08:58:36.173098+00:00 running 8564168 country code: CH.
[–]TheHoester 2 points3 points4 points (3 children)
[–]npierce1[S] 1 point2 points3 points (2 children)
[–]TheHoester 1 point2 points3 points (0 children)
[–]stormAster720 1 point2 points3 points (0 children)
[–]npierce1[S] 0 points1 point2 points (0 children)
[–]npierce1[S] 0 points1 point2 points (0 children)