void DeserializeAndLoad() { string json = PlayerPrefs.GetString("fizz-meta-143", GetDefaultUser()); JSONNode jsonClass = JSONClass.Parse(json); userIdInput.text = jsonClass["userId"].Value; userNameInput.text = jsonClass["userName"].Value; translationToggle.isOn = jsonClass["translation"].AsBool; JSONArray channels = jsonClass["channels"].AsArray; int count = channels.Count; int index = 0; foreach (JSONNode node in channels) { string channelId = node["channelId"].Value; string channelName = node["channelName"].Value; UITestChannel testChannel = CreateTestChannel(channelId, channelName); index++; } }
void OnChannelAddButtonPressed() { if (string.IsNullOrEmpty(channelIdInput.text) || string.IsNullOrEmpty(channelNameInput.text)) { return; } UITestChannel channel = CreateTestChannel(channelIdInput.text, channelNameInput.text); FizzService.Instance.AddChannel(channel.GetMeta()); SerializeAndSave(BuildMeta()); }
UITestChannel CreateTestChannel(string channeId, string channelName) { TestChannelMeta meta = new TestChannelMeta() { channelId = channeId, channelName = channelName }; UITestChannel testChannel = Instantiate(dafaultChannel); testChannel.gameObject.SetActive(true); testChannel.transform.SetParent(channelScrollRect.content); testChannel.transform.localScale = Vector3.one; testChannel.transform.SetAsLastSibling(); testChannel.SetRemoveButtonActive(true); testChannel.PopulateData(meta); return(testChannel); }