Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Problem : ArgumentExeption: The Object that you want to instantiate is null.

Discussion in 'Scripting' started by Loup62, Apr 1, 2023.

  1. Loup62

    Loup62

    Joined:
    Jan 23, 2022
    Posts:
    4
    Hello,
    Im trying to do a game and im actually learning.
    Im doing a clicker game (to learn how to do a game) and im trying to do a small popup of the damage i deal to the monster each time i click but i've a problem and i can't figure out how to fix it... Here's some screenshot of the problem and related function to it.

    Quick note: i know that im not doing what i want to, for the test, im just trying to summon the popup when i launch the game.

    Thanks in advance for your help !

    upload_2023-4-1_23-5-24.png
    upload_2023-4-1_23-5-46.png
    upload_2023-4-1_23-6-11.png
    upload_2023-4-1_23-6-30.png
    upload_2023-4-1_23-6-45.png
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,903
    The answer to these questions is to debug. For example, use Debug.Log() liberally in your code and find what was null. Don't try to do multiple things in one line of code, so that you can debug it step by step.

    My money is on GameAssets.cs line 13, the .Load method is returning null.
     
    Loup62 likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,947
    Loup62 likes this.
  4. Loup62

    Loup62

    Joined:
    Jan 23, 2022
    Posts:
    4
    My apology for that, thank you for your answer.
    I will now do that like you said for my future post.
     
  5. Loup62

    Loup62

    Joined:
    Jan 23, 2022
    Posts:
    4
    Thanks for your answer !
    I will do as you said with the Debug.Log()