Forum begins after the advertisement:


[Part 5] Null Reference Exception on the Scene Fader

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 5] Null Reference Exception on the Scene Fader

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #11665
    Kiefer Neo
    Level 12
    Moderator
    Helpful?
    Up
    0
    ::

    If you are experiencing a null reference exception on your scene fader, this is probably due to the Scene Fader prefab’s active state being set to false.

    To fix this simply set the Scene Fader prefab to active and the Null Reference Exception should be fixed.

    #11930
    Paul Forkus
    Level 2
    Participant
    Helpful?
    Up
    0
    ::

    Im having a null exception error on the scene faders, yet my prefab of scene fader is active. The console is pointing me towards this line:
    fadeOutUIImage.color = new Color(fadeOutUIImage.color.r, fadeOutUIImage.color.g, fadeOutUIImage.color.b, _alpha);
    However, i put a debug line in the update function and its showing that fadeOutUIImage is not null, but when i put one in the SetColorImage function, it returned null. Could it be a script execution issue, or could there be something in the inspector I’m overlooking?

    #11932
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Paul,

    This may be being caused by you having scripts attached to GameObjects that should not have the script. To check this, you can type in t:YourScriptName into the Hierarchy search textbox at the top of the window and see if there are any GameObjects that should not have the script which has it.

    Let me know if this works.

    #11958
    Paul Forkus
    Level 2
    Participant
    Helpful?
    Up
    0
    ::

    Turned out to be moving fadeOutUIImage = GetComponent<Image>(); from the Start function to the Awake solved the issue. Thanks again!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: