Example #1
0
        public QuickDropdown(Transform parent = null, string name = "QuickDropdown", GameObject altPrototype = null)
        {
            var exampleDropdown = altPrototype ?? Prefabs.QuickDropdown;

            if (exampleDropdown == null)
            {
                throw IEDebug.Exception(null, "You must initialize the ExampleDropdown to create a dropdown.", null);
            }
            GameObject = (GameObject)Object.Instantiate(exampleDropdown);
            GameObject.transform.parent = parent;
            GameObject.name             = name;
            //! You have to explicitly set localPosition and localScale to something after Instantiate!!!
            //! Otherwise, the UI will broken, but no exception will be reported.
            GameObject.transform.localPosition = Vector3.zero;
            GameObject.transform.localScale    = Vector3.one;

            SelectedValue = BindingValue.Member(() => this.selectedValue).ToBindable();
            Options       = new List <DropdownChoice <T> >();
            DropdownComponent.OnDropdownOptionChangedEvent += x => SelectedValue.NotifyChange();
            IEDebug.Log("Created: " + name);
        }