void Start() { utils.getQuestion += LoadJson; questionStruct = new QuestionStruct(); //StartCoroutine(LoadJson()); slider.minValue = 0; slider.maxValue = 1; source = GetComponent <AudioSource>(); //StartCoroutine(GetAudio()); //StartCoroutine(GetAudioClip()); //EventManager.GetInstance().AddListener<ActiveChallenge>(LoadJson); }
//public IEnumerator LoadJson(Action<Question[]> onComplete) //{ // ResourceRequest LoadRequest = Resources.LoadAsync("SongInfo"); // yield return LoadRequest; // data = LoadRequest.asset as TextAsset; // if (data != null) // { // questionStruct = JsonUtility.FromJson<QuestionStruct>(data.text); // } // if (questionStruct.status > 0) // { // for (int i = 0; i < questionStruct.status; i++) // { // string options = questionStruct.questions[i].options; // string[] optionArry = options.Split(','); // questionStruct.questions[i].option = optionArry; // } // } // onComplete(questionStruct.questions); //} public void LoadJson(Action <Question[]> onComplete) { data = Resources.Load("SongInfo") as TextAsset; if (data != null) { questionStruct = JsonUtility.FromJson <QuestionStruct>(data.text); } if (questionStruct.status > 0) { for (int i = 0; i < questionStruct.status; i++) { string options = questionStruct.questions[i].options; string[] optionArry = options.Split(','); questionStruct.questions[i].option = optionArry; } } onComplete(questionStruct.questions); }
public void ReFreshen() { var textString = Resources.Load <TextAsset>("json/question_" + FileNameIdx); curQuestionStruct = JsonUtility.FromJson <QuestionStruct>(textString.text); }