Пример #1
0
        public QuickCheckbox(string name = "QuickCheckbox", Transform parent = null, UIOptionsTag prototype = null)
        {
            IEDebug.Log("Creating Checkbox : {0}", name);
            var chBox = (UIOptionsTag)Object.Instantiate(prototype ?? Prototype);

            chBox.transform.parent = parent;
            chBox.name             = name;

            chBox.transform.localScale    = new Vector3(1, 1, 1);
            chBox.transform.localPosition = new Vector3(0, 0, 0);
            GameObject      = chBox.gameObject;
            GameObject.name = name;
            IEDebug.Log("IEMod created: " + chBox.name);
            IsChecked = BindingValue.Member(() => this.isChecked).ToBindable();
            chBox.Checkbox.onStateChange += (a, b) => {
                IsChecked.NotifyChange();
            };
        }
Пример #2
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);
        }
Пример #3
0
 public static IBindingValue <T> Bind <T>(this Bindable <T> bindable, Expression <Func <T> > memberExpr, BindingMode mode = BindingMode.TwoWay)
 {
     return(bindable.Bind(BindingValue.Member(memberExpr)));
 }