I have two scripts, JSONManager and UIManager.
JSONManager looks like this (Removed some irrelevant code):
public class JSONManager : MonoBehaviour
{
public TextAsset MyJSONFile;
public static Root questionJson;
public static GetJson()
{
questionJson = JsonConvert.DeserializeObject<Root>(MyJSONFile.text);
return questionJson
}
}
I want to access questionJson from UIManager, but I don’t understand how to do it. When I looked at examples of accessing one script from another, they generally do something like private JSONManager jsonManager to define an instance of the script, then access the properties from that script.
But since jsonManager uses a class that’s in that script (Root, which contains other classes as well that isn’t in the code snippet I included), how do I define what type of object questionJson is in UIManager? I only need to get questionJson one time from UIManager, but am unsure how to store the variable.
I’m also not sure what the method name should be. public static GetJson() returns the error “access modifiers are not allowed on static constructors” and “Method must have a return type.”
public root Json() returns “The name ‘questionJson’ does not exist in the current context”