Ejemplo n.º 1
0
        public CharacterResponse GetSelectedCharacterData()
        {
            List <CharacterToggleElement> characterToggles =
                toggleGroup.GetComponentsInChildren <CharacterToggleElement>().ToList();
            CharacterToggleElement toggledElement = characterToggles.FirstOrDefault(characterToggle =>
            {
                Toggle toggle = characterToggle.GetComponent <Toggle>();
                return(toggle.isOn);
            });

            if (toggledElement && characterDictionary.ContainsKey(toggledElement.Id))
            {
                return(characterDictionary[toggledElement.Id]);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public void LoadCharacters(List <CharacterResponse> characters)
        {
            ClearCharacterList();

            if (characters.Count == 0)
            {
                DisplayErrorMessage("No characters found.");
                return;
            }

            characters.ForEach(character =>
            {
                CharacterToggleElement characterToggleElement = Instantiate(togglePrefab, toggleGroup.transform);
                Toggle toggle         = characterToggleElement.GetComponent <Toggle>();
                TextMeshProUGUI label = toggle.GetComponentInChildren <TextMeshProUGUI>();
                label.text            = character.name;
                toggle.group          = toggleGroup;
                characterDictionary.Add(Int32.Parse(character.id), character);
                LoginWindow loginWindow = transform.root.GetComponentInChildren <LoginWindow>();
                characterToggleElement.Register(Int32.Parse(character.id), loginWindow);
            });
        }