Sunday, November 6, 2022
HomeGame DevelopmentWhy is my object null?

Why is my object null? [closed]


That is my Participant class:

public class Participant : Unit{

[SerializeField]
non-public InventoryHandler inventoryHandler;

non-public static Participant _instance;

public static Participant Occasion { get { return _instance; } }

non-public void Awake()
{
    if (_instance != null && _instance != this)
    {
        Destroy(this.gameObject);
        return;
    }

    _instance = this;
    DontDestroyOnLoad(this.gameObject);
}

public override string ToString()
{
    return inventoryHandler.ToString();
}

public InventoryHandler InventoryHandler { get; }}

InventoryHandler is an inserted ScriptableObject, when I’m making an attempt to entry it, it returns null worth.
In scene view, Participant has it

That is exmaple class, when i’m calling it:

public class check : MonoBehaviour{
non-public Participant participant;
void Begin()
{
    participant = GameObject.Discover("Participant").GetComponent<Participant>();
    Debug.Log(participant.InventoryHandler);
}}

If I name Participant.ToString(), InventoryHandler is there with all the information;

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments