Files
unity-application/Assets/Common/Scripts/ThemeLoader.cs
2023-03-13 21:49:40 +00:00

37 lines
814 B
C#

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