using UdonSharp; using UnityEngine; using VRC.SDK3.Data; using VRC.SDK3.StringLoading; using VRC.SDKBase; using VRC.Udon; using VRC.Udon.Common.Interfaces; [UdonBehaviourSyncMode(BehaviourSyncMode.Manual)] public class CaseManager : UdonSharpBehaviour { [SerializeField] protected VRCUrl _QuestionURL; [SerializeField] private GameManagerRound1 _Round1Manager; [SerializeField] private GameManagerRound2 _Round2Manager; //[SerializeField] private GameManagerRound3 _Round3Manager; void Start() { // Download our test question. VRCStringDownloader.LoadUrl(_QuestionURL, (IUdonEventReceiver)this); } public override void OnStringLoadSuccess(IVRCStringDownload DownloadedString) { string ErrorString = ""; string JSONString = DownloadedString.Result; if (VRCJson.TryDeserializeFromJson(JSONString, out DataToken JSONResult)) { if (JSONResult.TokenType == TokenType.DataDictionary) { DataDictionary Dict = JSONResult.DataDictionary; if (!Dict.ContainsKey("Round 1") || !Dict.ContainsKey("Round 2")/* || !Dict.ContainsKey("Round 3")*/) { ErrorString = "Could not find all the necessary keys for game rounds."; } else { // Attempt to load Round 1 data if (Dict["Round 1"].TokenType == TokenType.DataList) { _Round1Manager.LoadQuestionData(Dict["Round 1"]); } else { ErrorString = "Ensure the 'Round 1' entry is an array of dictionaries."; } // Attempt to load Round 2 data if (Dict["Round 2"].TokenType == TokenType.DataDictionary) { _Round2Manager.LoadQuestionData(Dict["Round 2"]); } else { ErrorString = "Ensure the 'Round 2' entry is a dictionary with a location name and a list of landmarks."; } //// Attempt to load Round 3 data //if (Dict["Round 3"].TokenType == TokenType.DataList) //{ // LoadQuestionData(Dict["Round 3"].DataList); //} //else //{ // ErrorString = "Ensure the 'Round 3' dictionary entry is a list of dictionaries."; //} } if (Dict.ContainsKey("Round 1")) { } else { ErrorString = "Ensure the first element is a dictionary, containing 'Round 1', 'Round 2', and 'Round 3' entries."; } if (Dict.ContainsKey("Round 2")) { } } else { ErrorString = "Ensure the first element is a dictionary"; } } if (ErrorString != "") { Debug.LogError("Malformed case file. " + ErrorString); } } }