private void SetDropdownValueUnnotified(Dropdown field, int value) { Dropdown.DropdownEvent eventBackup = field.onValueChanged; field.onValueChanged = null; field.value = value; field.onValueChanged = eventBackup; }
public static void SetValue(this Dropdown instance, int value) { Dropdown.DropdownEvent originalEvent = instance.onValueChanged; instance.onValueChanged = emptyDropdownFieldEvent; instance.value = value; instance.onValueChanged = originalEvent; }
// Start is called before the first frame update void Start() { //メインカメラを取得 UnityEngine.Camera mainCamera = UnityEngine.Camera.main; //メインカメラのTransformのクローンを生成して子オブジェクトにまとめる Transform mainCameraTransform = new GameObject("MainCamera").transform; mainCameraTransform.parent = this.transform; mainCameraTransform.position = mainCamera.transform.position; mainCameraTransform.rotation = mainCamera.transform.rotation; mainCameraTransform.localScale = mainCamera.transform.localScale; //子オブジェクトのTransform(CameraSwitch対象のTransform)を列挙 IReadOnlyList <Transform> cameraPoss = this.transform.Cast <Transform>().ToList(); //DropDownの項目に追加 m_cameraCombobox.options = cameraPoss.Select(tr => new Dropdown.OptionData(tr.name)).ToList(); //DropDownのOnChangedイベントを設定 var ddEvent = new Dropdown.DropdownEvent(); //DropDownが変更されたら、そのTransformにカメラを移動させる ddEvent.AddListener(index => mainCamera.transform.DOMove(cameraPoss[index].position, 0.5f) .SetEase(Ease.OutCirc)); m_cameraCombobox.onValueChanged = ddEvent; }
void Awake() { #if UNITY_EDITOR #endif m_OnValueChanged = GetComponentInChildren <Dropdown>().onValueChanged; m_OnValueChanged.AddListener((val) => { m_VisualsDirty = true; }); }
public static int constructor(IntPtr l) { int result; try { Dropdown.DropdownEvent o = new Dropdown.DropdownEvent(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
// Use this for initialization void Start() { m_Dropdown = GetComponentInChildren <Dropdown>(); // Event var e = new Dropdown.DropdownEvent(); e.AddListener(DropdownCallback); m_Dropdown.onValueChanged = e; // Set Placeholder switch (Setting) { case Settings.SpriteSources: SetPlaceholder(scr_InputManager.SpriteSource.ToString()); break; default: break; } }
// Use this for initialization void Start() { m_Dropdown = GetComponent <Dropdown>(); // Set Dropdown values to Race names var raceNames = new List <string>(); int optionNr = 0; for (int i = 0; i < SceneManager.sceneCountInBuildSettings; ++i) { string path = SceneUtility.GetScenePathByBuildIndex(i); string fullName = path.Substring(path.LastIndexOf('/') + 1); if (!fullName.Contains("Race_")) { continue; } string name = fullName.Substring(5, fullName.LastIndexOf('.') - 5); raceNames.Add(name); m_RaceBuildIndices.Add(optionNr, i); m_RaceNames.Add(optionNr, name); ++optionNr; } m_Dropdown.ClearOptions(); m_Dropdown.AddOptions(raceNames); // Add Dropdown select event var dropdownEvent = new Dropdown.DropdownEvent(); dropdownEvent.AddListener(DropdownCallback); m_Dropdown.onValueChanged = dropdownEvent; // Load Race Info LoadRaceInfo(); // Show Race ShowRace(); }
// Use this for initialization void Start() { //initialization for dropdown menu var de = new Dropdown.DropdownEvent(); de.AddListener(selectSong); dropdownSongList.onValueChanged = de; dropdownSongList.ClearOptions(); //Adds the names of the songs to the dropdown menu List <string> clipsString = new List <string>(); foreach (AudioClip clip in clips) { clipsString.Add(clip.name); } dropdownSongList.AddOptions(clipsString); audioSource = GetComponent <AudioSource>(); selectSong(0); endGameScreen.SetActive(false); }
public static void Add(this Dropdown.DropdownEvent dropdownEvent, Action action) { dropdownEvent.AddListener((index) => { action(); }); }