Files
unity-application/Assets/SpellingBee/Scripts/ThemeLoader.cs
2023-03-06 12:14:25 +00:00

30 lines
715 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// JSON structure containing all themes/words
[System.Serializable]
public class ThemeList
{
public Theme[] themes;
}
// Object representing part of the JSON containing word data
[System.Serializable]
public class Theme
{
public string name;
public string description;
public string[] words;
}
public class ThemeLoader : MonoBehaviour
{
// Loads the JSON file containing all of the themes
public static ThemeList LoadJson()
{
TextAsset themeJson = Resources.Load<TextAsset>("SpellingBee/words");
return JsonUtility.FromJson<ThemeList>(themeJson.text);
}
}