So I’m making a debug script so I can have it output into my VR headset and see the log without taking the headset off.
This is the script that is managing the log (it is not attached to any gameobject and is just in a folder):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class NDebug {
public static List<string> log;
public static void Log(string content) {
log.Add(content);
}
public static List<string> GetLog() {
return log;
}
}
But when a script tries to call Log
it gives an error:
NullReferenceException: Object reference not set to an instance of an object
NDebug.Log (System.String content) (at Assets/NDebug/NDebug.cs:10)
SeatScript.OnEnable () (at Assets/Scripts/SeatScript.cs:21)
and so this is my question: can static non-instanced lists exist? Is there a way for me to do what I’m trying to do without adding anything to my scene?
Thanks in advance.