[ad_1]
This is my Player class:
public class Player : Unit{
[SerializeField]
personal InventoryHandler inventoryHandler;
personal static Player _instance;
public static Player Instance { get { return _instance; } }
personal 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 attempting to entry it, it returns null worth.
In scene view, Player has it
This is exmaple class, when i’m calling it:
public class take a look at : MonoBehaviour{
personal Player participant;
void Start()
{
participant = GameObject.Find("Player").GetComponent<Player>();
Debug.Log(participant.InventoryHandler);
}}
If I name Player.ToString(), InventoryHandler is there with all the info;
[ad_2]