This is the first question for Unity and C # beginners.
I am making a game of neglecting "Unity Terakoya" Chapter 2 in Unity.

* Production screen/Playing

The following problem/error message occurred while implementing the function to delete the object (virtual) traced by dragging.

Error message

The object traced by dragging doesn't disappear, and the following error message is generated instead.

NullReferenceException: Object reference not set to an instance of an object
OrbManager.TouchOrb () (at Assets/Scripts/OrbManager.cs: 24)
UnityEngine.Events.InvokableCall.Invoke () (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent.cs:166)
UnityEngine.Events.UnityEvent1 [T0] .Invoke (.T0 arg0) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent_1.cs:63) UnityEngine.EventSystems.EventTrigger.Execute (EventTriggerType id, UnityEngine.EventSystems.BaseEventData eventData) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/EventTrigger.cs:67) UnityEngine.EventSystems.EventTrigger.OnPointerEnter (UnityEngine.EventSystems.PointerEventData eventData) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/EventTrigger.cs:73) UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerEnterHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:22) UnityEngine.EventSystems.ExecuteEvents.Execute [IPointerEnterHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction1 functor) (at/Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs: 261)

Here is the source code where the error occurred.
`` `using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OrbManager: MonoBehaviour {

private GameObject gameManager;

// Use this for initialization
void Start () {
gameManager = GameObject.Find ("GameMnager");

// Update is called once per frame
void Update () {


public void TouthOrb () {
if (Input.GetMouseButton (0) == false) (

gameManager.GetComponent<GameManager>() .GetOrb ();
Destroy (this.gameObject);


Applicable source code

gameManager.GetComponent<GameManager>() .GetOrb ();

Tried, current situation

● Restart
● There was information that the above error occurred for some reason when Prefab was selected.

We have arrived at the information that there is an unreferenced object in TouthOrb and that the variable should not be null, but it is not null. I don't know what to do, and I'm at a loss.

I don't know exactly what to do (in what part, for what reason, what code to write, or work outside the code), so I can teach you. Fortunately.

Thank you very much.

Supplemental information (FW/tool version etc.)

Version 2018,2,5f1 Personal

HighSierra Version10.13.6

  • Answer # 1

    As far as you can see the beginning of the error, but as the cause
    -There is an uninitialized variable in the GetOrb function in GameManager
    ・ GameManager is not attached to gameManager in the first place


    void Start () {
    gameManager = GameObject.Find ("GameMnager");

    I misspelled it with GameMnager, which may also be the cause.

  • Answer # 2

    GameObject.Find ("GameMnager")
    GameObject.Find ("GameManager")
    Is n’t it?
    First of all, you should try to translate and search for errors.

  • Answer # 3

    void Start () {
    gameManager = GameObject.Find ("GameMnager");

    Is this a spelling mistake for"GameManager" ;?