Resolve WES-76 "87 themeselection"
This commit is contained in:
36
Assets/Common/Scripts/ThemeLoader.cs
Normal file
36
Assets/Common/Scripts/ThemeLoader.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user