private void GenerateOptions(CharacterBoardEntity character, bool first = true) { charContainer = character.GetComponent <CharContainer>(); List <TMP_Dropdown.OptionData> options = new List <TMP_Dropdown.OptionData>(); selectOption = new TMP_Dropdown.OptionData("Select a skill"); options.Add(selectOption); TMP_Dropdown.OptionData option; foreach (Skill skill in character.Skills) { option = new TMP_Dropdown.OptionData(skill.GetTitle()); optionToSkill.Add(option, skill); options.Add(option); } foreach (Passive p in character.Passives) { if (!(p is Talent)) { option = new TMP_Dropdown.OptionData(p.GetTitleHelper()); optionToPassive.Add(option, p); options.Add(option); } } dropDown.options = options; }
void LoadListMap() { if (!LibPlacenote.Instance.Initialized()) { Debug.Log("SDK not yet initialized"); return; } LibPlacenote.Instance.ListMaps((mapList) => { TMP_Dropdown.OptionData nullData = new TMP_Dropdown.OptionData(); nullData.text = "none"; dropdownList.options.Add(nullData); // add null choice to dropdown foreach (LibPlacenote.MapInfo mapInfoItem in mapList) { if (mapInfoItem.metadata.userdata != null) { TMP_Dropdown.OptionData data = new TMP_Dropdown.OptionData(); data.text = mapInfoItem.metadata.name; dropdownList.options.Add(data); //add other map to choices to dropdown } } }); dropdownList.RefreshShownValue(); }
public void UpdateList() { if (dropdown == null) { Debug.LogError("Dropdown is null!!"); return; } dropdown.options.Clear(); var emptyOption = new TMP_Dropdown.OptionData() { text = "-- unfollowing --" }; dropdown.options.Add(emptyOption); if (modelRoot != null) { foreach (var modelPlugin in modelRoot.GetComponentsInChildren <ModelPlugin>()) { if (modelPlugin.IsTopModel && !(modelPlugin.isStatic)) { var newOption = new TMP_Dropdown.OptionData(); newOption.text = modelPlugin.name; dropdown.options.Add(newOption); } } } dropdown.value = 0; dropdown.Select(); dropdown.RefreshShownValue(); }
private void ProcessDropDowns(int index) { foreach (DropDownAnswer dropDown in levels[index].dropDownAnswers) { GameObject temporaryDropDown = Instantiate(dropDown.dropDownPrefab, transform); RectTransform dropDownTransform = temporaryDropDown.GetComponent <RectTransform>(); if (dropDownTransform != null) { dropDownTransform.position = dropDown.dropDownLocation; dropDownTransform.localScale = new Vector3(dropDown.width, dropDown.height, 1); } TMP_Dropdown dropdownElement = temporaryDropDown.GetComponent <TMP_Dropdown>(); if (dropdownElement != null) { dropdownElement.options.Clear(); List <TMP_Dropdown.OptionData> optionDataList = new List <TMP_Dropdown.OptionData>(); for (int i = 0; i < dropDown.answerTexts.Length; i++) { TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData(); optionData.text = dropDown.answerTexts[i]; dropdownElement.options.Add(optionData); } } } }
public static IDisposable BindOptionsTo(this TMP_Dropdown input, IReactiveCollection <string> options) { var addSubscription = options.ObserveAdd().Subscribe(x => { var newOption = new TMP_Dropdown.OptionData { text = x.Value }; input.options.Insert(x.Index, newOption); }); var updateSubscription = options.ObserveReplace().Subscribe(x => { var existingOption = input.options[x.Index]; existingOption.text = x.NewValue; }); var removeSubscription = options.ObserveRemove().Subscribe(x => input.options.RemoveAt(x.Index)); input.options.Clear(); foreach (var option in options) { var newOption = new TMP_Dropdown.OptionData { text = option }; input.options.Add(newOption); } return(new CompositeDisposable(addSubscription, updateSubscription, removeSubscription).AddTo(input)); }
void DrawItemTypeDropDown() { ItemTypeDropDown.onValueChanged.RemoveAllListeners(); ItemTypeDropDown.ClearOptions(); if (CurrentStation == null) { return; } List <TMP_Dropdown.OptionData> options = new List <TMP_Dropdown.OptionData>(); foreach (ItemSystem.ItemTypes type in ValidTypes) { TMP_Dropdown.OptionData data = new TMP_Dropdown.OptionData(); data.text = type.ToString(); options.Add(data); } ItemTypeDropDown.AddOptions(options); ItemTypeDropDown.onValueChanged.AddListener(delegate { SelectItemType(); }); if (ItemTypeDropDown.options.Count > 0) { SelectItemType(); } else { DrawBlank(); } }
/// <summary> /// 実質的な初期化関数 /// </summary> private void OnInitializeServoDefines() { uguiController.Initialize(_preMaidPoseController.Servos); uguiController.OnChangeValue += OnUguiSliderValueChange; if (dropdown == null) { Debug.LogError("シリアルポートを選択するDropDownが指定されていません"); return; } List <TMP_Dropdown.OptionData> serialPortNamesList = new List <TMP_Dropdown.OptionData>(); var portNames = SerialPort.GetPortNames(); foreach (var VARIABLE in portNames) { TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData(VARIABLE); serialPortNamesList.Add(optionData); Debug.Log(VARIABLE); } dropdown.ClearOptions(); dropdown.AddOptions(serialPortNamesList); _preMaidPoseController.OnContinuousModeChange += OnContinuousModeChange; continuousToggle.onValueChanged.AddListener(SetContinuousModeFromGui); }
public void fillCharDropdown() { TMP_Dropdown m_Dropdown; //Fetch the Dropdown GameObject the script is attached to m_Dropdown = GameObject.Find(CharacterDropdownName).GetComponent <TMP_Dropdown>(); List <string> options = videoData.getVideoOptions(); //Clear the old options of the Dropdown menu m_Dropdown.ClearOptions(); for (int i = 0; i < options.Count; i++) { TMP_Dropdown.OptionData m_NewData = new TMP_Dropdown.OptionData(); m_NewData.text = "Playing as<b> " + options[i] + " </b>"; m_Dropdown.options.Add(m_NewData); } m_Dropdown.value = 0; m_Dropdown.captionText.text = "Playing as<b> " + options[0] + " </b>"; }
void GenerateDropdownContent() { dropDown.ClearOptions(); dropDown.options = new List <TMP_Dropdown.OptionData>(); List <TMP_Dropdown.OptionData> optionsList = new List <TMP_Dropdown.OptionData>(); foreach (DCLBuilderInWorldEntity entity in entitiesList) { var item = new TMP_Dropdown.OptionData(); item.text = entity.GetDescriptiveName(); if (entitySpriteDict.ContainsKey(entity)) { item.image = entitySpriteDict[entity]; } optionsList.Add(item); } dropDown.AddOptions(optionsList); string value = (string)GetParameterValue(); for (int i = 0; i < entitiesList.Count; i++) { if (entitiesList[i].rootEntity.entityId == value) { dropDown.SetValueWithoutNotify(i); } } }
/// <summary> /// This is a best guess attempt for users but it is not fast and does not pick up on entries changing, just the count changing /// </summary> public static IDisposable BindOptionsTo <T>(this TMP_Dropdown input, ICollection <T> options, Func <T, string> textLocator, Func <T, Sprite> spriteLocator = null) { var lastCount = options.Count; return(Observable.EveryUpdate() .TakeWhile(x => lastCount != options.Count) .Subscribe(x => { input.options.Clear(); foreach (var option in options) { var newOption = new TMP_Dropdown.OptionData { text = textLocator(option) }; if (spriteLocator != null) { newOption.image = spriteLocator(option); } input.options.Add(newOption); } }).AddTo(input)); }
void CreateRaces() { raceDropdown.ClearOptions(); var newOptions = new List <TMP_Dropdown.OptionData>(); foreach (var id in Library.races.Keys) { var data = new TMP_Dropdown.OptionData(Library.races[id].name); newOptions.Add(data); } raceDropdown.AddOptions(newOptions); raceDropdown.onValueChanged.AddListener((x) => { var raceName = raceDropdown.options[x].text; foreach (var id in Library.races.Keys) { var libRace = Library.races[id]; if (libRace.name == raceName) { var newRuler = Ruler.CreateRuler(); newRuler.name = ruler.name; ruler = newRuler; UpdateDisplay(); return; } } }); }
public override void Setup() { base.Setup(); // Clear any existing data dropdown.ClearOptions(); optionCategoryMap.Clear(); foreach (ItemID id in GetItemIDs()) { // Get the current option ItemData data = ItemRegistry.Get(id); TMP_Dropdown.OptionData option = new TMP_Dropdown.OptionData(data.Name.Get(itemDisplayName), data.ShopItem.Icon); // Add the option to the dropdown and the dictionary dropdown.options.Add(option); optionCategoryMap.Add(option, id); } // Setup the value changed callback dropdown.onValueChanged.AddListener(SetDropdownValue); // Setup the value to the first one if (dropdown.options.Count > 0) { SetDropdownValueWithoutNotify(0); } }
private bool SetResearchCategoryHelper(ItemID id, UnityAction <int> valueSetter) { // Find the first value in the list that matches TMP_Dropdown.OptionData selection = optionCategoryMap.FirstOrDefault(kvp => kvp.Value == id).Key; if (selection != null) { int value = dropdown.options.FindIndex(option => option == selection); // If the option was found, then invoke the event if (value >= 0) { valueSetter.Invoke(value); return(true); } else { return(false); } } else { return(false); } }
private void InitializeCreatureList(Creature[] allThingsInArea) { if (initialized) { Debug.LogWarning("Initialize called on CreatureBrowser when already initialized"); } creatureDropDown.ClearOptions(); List <Creature> tempMap = new List <Creature>(); List <TMP_Dropdown.OptionData> options = new List <TMP_Dropdown.OptionData>(); for (int count = 0; count < allThingsInArea.Length; count++) { if (allThingsInArea[count].match(Thing.Base_Types.CREATURE)) { TMP_Dropdown.OptionData option = new TMP_Dropdown.OptionData(allThingsInArea[count].thingName); options.Add(option); tempMap.Add(allThingsInArea[count]); } } creatureMap = tempMap.ToArray(); creatureDropDown.AddOptions(options); currentWindow = CreatureBrowserWindow.Creature_Detail_List; OnDropDownChange(); initialized = true; }
private void FillDropdownConstructions(DataConstructionRequestGet[] arrayConstructions) { constructions = new Dictionary <string, int>(); for (int i = 0; i < arrayConstructions.Length; i++) { for (int j = i + 1; j < arrayConstructions.Length - 1; j++) { if (arrayConstructions[i].id < arrayConstructions[j + 1].id) { DataConstructionRequestGet tmp = arrayConstructions[i]; arrayConstructions[i] = arrayConstructions[j + 1]; arrayConstructions[j + 1] = tmp; } } } List <TMP_Dropdown.OptionData> listOptions = new List <TMP_Dropdown.OptionData>(); for (int i = 0; i < arrayConstructions.Length; i++) { TMP_Dropdown.OptionData newItem = new TMP_Dropdown.OptionData(); newItem.text = arrayConstructions[i].name; listOptions.Add(newItem); constructions.Add(arrayConstructions[i].name, arrayConstructions[i].id); } dropdownConstructions.ClearOptions(); dropdownConstructions.AddOptions(listOptions); }
public void Init(RoleAnimTestPanel panel) { m_Panel = panel; m_Dropdown.options.Clear(); for (int i = 0; i < (int)WeaponType.Length; i++) { TMP_Dropdown.OptionData data = new TMP_Dropdown.OptionData(); data.text = ((WeaponType)i).ToString(); m_Dropdown.options.Add(data); } m_Dropdown.value = 0; m_Dropdown.onValueChanged.AddListener(ChooseWeapon); m_BtnWeaponEquip.onClick.AddListener(OnClickEquip); m_BtnWeaponUnEquip.onClick.AddListener(OnClickUnEquip); m_BtnUnSheath.onClick.AddListener(OnClickUnSheath); m_BtnSheath.onClick.AddListener(OnClickSheath); m_BtnBlock.onClick.AddListener(OnClickBlock); m_BtnUnBlock.onClick.AddListener(OnClickUnBlock); m_Weapon = m_Panel.role.equipComponent.GetWeapon(); UpdateBtn(); role.controlComponent.onWeaponSwitchComplete += () => { UpdateBtn(); }; }
// World public void gpWorldMapSizeChanged(int value) { _maps = new List <MapFile>(); if (value == 0) { _maps = Runner.Instance.smallMaps; } else if (value == 1) { _maps = Runner.Instance.mediumMaps; } else if (value == 2) { _maps = Runner.Instance.largeMaps; } gpDropdownWorldMap.ClearOptions(); foreach (MapFile m in _maps) { TMP_Dropdown.OptionData option = new TMP_Dropdown.OptionData(); option.text = m.name; gpDropdownWorldMap.options.Add(option); } gpDropdownWorldMap.value = 0; gpDropdownWorldMap.RefreshShownValue(); }
private void fillSceneDropdown() { TMP_Dropdown m_Dropdown; //Fetch the Dropdown GameObject the script is attached to m_Dropdown = GameObject.Find(SceneDropdownName).GetComponent <TMP_Dropdown>(); List <string> options = videoData.getScenesOptions(); //Clear the old options of the Dropdown menu m_Dropdown.ClearOptions(); for (int i = 0; i < options.Count; i++) { TMP_Dropdown.OptionData m_NewData = new TMP_Dropdown.OptionData(); m_NewData.text = options[i]; m_Dropdown.options.Add(m_NewData); } m_Dropdown.value = 0; m_Dropdown.captionText.text = options[0]; fillCharDropdown(); }
private void GenerateEntityDropdownContent() { entityDropDown.ClearOptions(); entityDropDown.options = new List <TMP_Dropdown.OptionData>(); List <TMP_Dropdown.OptionData> optionsList = new List <TMP_Dropdown.OptionData>(); int index = 0; int indexToUse = 0; foreach (DCLBuilderInWorldEntity entity in filteredList) { var item = new TMP_Dropdown.OptionData(); item.text = entity.GetDescriptiveName(); if (entitySpriteDict.ContainsKey(entity)) { item.image = entitySpriteDict[entity]; } optionsList.Add(item); if (!string.IsNullOrEmpty(actionEvent.smartItemActionable.entityId) && entity.rootEntity.entityId == actionEvent.smartItemActionable.entityId) { indexToUse = index; } index++; } entityDropDown.AddOptions(optionsList); entityDropDown.SetValueWithoutNotify(indexToUse); }
public override void Setup() { base.Setup(); // Setup the bookmark target to get-set the enclosure id bookmarkTarget.Setup(() => CurrentLevelID, x => CurrentLevelID = (LevelID)x); // Clear out any existing options levelDropdown.ClearOptions(); enclosureDropdown.ClearOptions(); // Loop through all enclosure id's and add them to the list foreach (LevelID id in UIParent.Data.Levels) { TMP_Dropdown.OptionData option = LevelNumberToOptionData(id.LevelNumber); // If no option with the same text yet exists, then add it to the dropdown if (levelDropdown.options.FindIndex(x => x.text == option.text) < 0) { levelDropdown.options.Add(option); } } // Update the level dropdown to reflect the current level LevelID currentLevel = LevelID.Current(); levelDropdown.value = currentLevel.LevelNumber; levelDropdown.RefreshShownValue(); OnLevelDropdownValueChanged(levelDropdown.value); // Add listeners for the value changed events levelDropdown.onValueChanged.AddListener(OnLevelDropdownValueChanged); enclosureDropdown.onValueChanged.AddListener(OnEnclosureDropdownValueChanged); }
private NeedType OptionDataToNeedType(TMP_Dropdown.OptionData option) { int endIndex = option.text.IndexOf(suffix); string substring = option.text.Substring(0, endIndex); NeedType need = (NeedType)System.Enum.Parse(typeof(NeedType), substring); return(need); }
public void UpdateLocalization() { var dropdown = GetComponent <TMP_Dropdown>(); var dOptions = dropdown.options; if (options != null) { for (var i = 0; i < options.Count; i++) { var option = options[i]; var dOption = default(TMP_Dropdown.OptionData); if (dOptions.Count == i) { dOption = new TMP_Dropdown.OptionData(); dOptions.Add(dOption); } else { dOption = dOptions[i]; } var stringTranslation = LeanLocalization.GetTranslation(option.StringTranslationName); // Use translation? if (stringTranslation != null && stringTranslation.Data is string) { dOption.text = LeanTranslation.FormatText((string)stringTranslation.Data, dOption.text, this, gameObject); } // Use fallback? else { dOption.text = LeanTranslation.FormatText(option.FallbackText, dOption.text, this, gameObject); } var spriteTranslation = LeanLocalization.GetTranslation(option.StringTranslationName); // Use translation? if (spriteTranslation != null && spriteTranslation.Data is Sprite) { dOption.image = (Sprite)spriteTranslation.Data; } // Use fallback? else { dOption.image = option.FallbackSprite; } } } else { dOptions.Clear(); } dropdown.options = dOptions; }
/// <summary> ///Function for the dropdownt to push its selection /// </summary> /// <param name="optionIndex">the return index from the Dropdown</param> public void SelectedMatchmaking(int optionIndex) { TMP_Dropdown.OptionData selectedData = matchmakeConfigDropdown.options[optionIndex]; MatchmakingConfigAsset selectedAsset = _optionConfigAssetDict[selectedData]; Debug.LogFormat("Selected: {0} URLUPID: {1} FleetID: {2} ", selectedAsset.name, selectedAsset.URLAndUPID(), selectedAsset.MultiplayFleetID); SetMatchmakingConfigAsset(selectedAsset); }
public void ChangeSODK() { for (int val = 0; val < AV.surface_sodk.Count; val++) { var optionData = new TMP_Dropdown.OptionData(AV.surface_sodk[val].value); SODK.options.Add(optionData); } SODK.RefreshShownValue(); }
public void ChangeWetGround() { for (int val = 0; val < AV.surface_humidity.Count; val++) { var optionData = new TMP_Dropdown.OptionData(AV.surface_humidity[val].value); wetGround.options.Add(optionData); } wetGround.RefreshShownValue(); }
/// <summary> /// /// </summary> /// <param name="parent"></param> /// <param name="data"></param> public void Set(UIAutofillInputField parent, TMP_Dropdown.OptionData data) { lableText.text = data.text; button.onClick.AddListener(() => { parent.Value = lableText.text; parent.OnItemSelected(data); }); }
void Start() { if (dropdown != null) { dropdown.onValueChanged.AddListener(OnDropDownValueChanged); emptyOption = new TMP_Dropdown.OptionData("-- unfollowing --"); } }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Space) && Input.GetKey(KeyCode.E) && Input.GetKeyDown(KeyCode.D) && easterEggActivated == false) { TMP_Dropdown.OptionData demoModeOption = new TMP_Dropdown.OptionData("Demo Mode"); dropdown.options.Add(demoModeOption); easterEggActivated = true; } }
private void OnEnclosureDropdownValueChanged(int value) { TMP_Dropdown.OptionData levelOptionSelected = levelDropdown.options[levelDropdown.value]; TMP_Dropdown.OptionData enclosureOptionSelected = enclosureDropdown.options[value]; LevelID levelSelected = new LevelID(OptionDataToLevelNumber(levelOptionSelected), OptionDataToEnclosureNumber(enclosureOptionSelected)); onLevelIDPicked.Invoke(levelSelected); UIParent.OnContentChanged.Invoke(); }
// Load Decks in the DropDown public void LoadDecks() { // Clear Dropdown deckPicker.ClearOptions(); List <TMP_Dropdown.OptionData> decks_list_drop = new List <TMP_Dropdown.OptionData>(); List <string> deck_paths_list; switch (deckController.my_deck.Faction) { case "NR": deck_paths_list = deckController.NRDecks; break; case "NF": deck_paths_list = deckController.NFDecks; break; case "SC": deck_paths_list = deckController.SCDecks; break; case "M": deck_paths_list = deckController.MDecks; break; default: deck_paths_list = deckController.NRDecks; break; } myDecks.Clear(); myPaths.Clear(); // Add decks to options and to global deck list foreach (string path in deck_paths_list) { Deck auxdeck = deckController.LoadDeckFromPath(path); TMP_Dropdown.OptionData dropItem = new TMP_Dropdown.OptionData(auxdeck.Name); myDecks.Add(auxdeck); myPaths.Add(path); decks_list_drop.Add(dropItem); } deckPicker.AddOptions(decks_list_drop); // Reload the first deck just in case if (deck_paths_list.Count > 0) { deckCollection.OnDeckChange(myDecks[0], myPaths[0]); } else { // Clear the collection (my_deck is empty at this point: Cleared from UpdateSelectedFaction) deckCollection.OnDeckChange(deckController.my_deck, Path.Combine(Application.streamingAssetsPath, "__empty__.json")); } InitializeDeck(); }