private void LoadGameData() { // Path.Combine combines strings into a file path // Application.StreamingAssets points to Assets/StreamingAssets in the Editor, and the StreamingAssets folder in a build string filePath = Path.Combine(Application.dataPath, gameDataFileName); Debug.Log(filePath); if (File.Exists(filePath)) { // Read the json from the file into a string string dataAsJson = File.ReadAllText(filePath); // Pass the json to JsonUtility, and tell it to create a GameData object from it p = JsonUtility.FromJson <CitizenDataHandler>(dataAsJson); Debug.Log(p.names[9]); //Debug.Log(p.happy[2]); } else { Debug.LogError("Cannot load game data!"); } }
void Start() { p = new CitizenDataHandler(); //DontDestroyOnLoad(gameObject); LoadGameData(); }