Z
Z
Zefirot2021-06-30 13:25:45
C++ / C#
Zefirot, 2021-06-30 13:25:45

Why can't I use another class dictionary?

here i have a class

public class InfoTest : MonoBehaviour{
  public Dictionary<string, string> ArrayInfo = new Dictionary<string, string>();
  public static InfoTest instance;
  private void Awake(){
    instance = this;
    ArrayInfo.Add("Test1", "..........................");
    ArrayInfo.Add("Test2", "..........................");
...................

And tryna get it in another class
private void Test(){
    foreach(KeyValuePair<string, string> kv in InfoTest.instance.ArrayInfo){
..........................

well i got a mistake
NullReferenceException: Object reference not set to an instance of an object

What is wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-06-30
@Zefirot

most likely instance == null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question