예제 #1
0
        public void Binding(UIBehaviour uiComponent, UIBindingComponent bindingComponent, IUILogicalNode target)
        {
            Text = uiComponent as Text;
            string path = bindingComponent.GetBindingPath("Text");

            target.BindingComponent(path, this);
            Text.text = target.DataContext.GetData(path) as string;
        }
예제 #2
0
        public void Binding(UIBehaviour uiComponent, UIBindingComponent bindingComponent, IUILogicalNode target)
        {
            tmpro = uiComponent as TextMeshProUGUI;
            string path = bindingComponent.GetBindingPath("TMPro");

            target.BindingComponent(path, this);
            tmpro.text = target.DataContext.GetData(path) as string;
        }
예제 #3
0
        private void OnEnable()
        {
            UINodeBase uiNode = target as UINodeBase;

            if (uiNode.actionComponents == null)
            {
                uiNode.actionComponents = new ObservableDictionary <string, bool>("");
                uiNode.actionComponents.CollectionChanged += (e) =>
                {
                    //KeyValuePair<string, bool> oldItem = ((KeyValuePair<string, bool>)e.OldItem);
                    //KeyValuePair<string, bool> newItem = ((KeyValuePair<string, bool>)e.NewItem);

                    switch (e.Action)
                    {
                    case CollectionChangedAction.Add:
                        if (((KeyValuePair <string, bool>)e.NewItem).Value == true && uiNode.GetComponents <UIBindingComponent>().Where(x => x.targetComponent == ((KeyValuePair <string, bool>)e.NewItem).Key).Count() == 0)
                        {
                            UIBindingComponent attributes = uiNode.gameObject.AddComponent <UIBindingComponent>();
                            attributes.targetComponent = ((KeyValuePair <string, bool>)e.NewItem).Key;
                        }
                        break;

                    case CollectionChangedAction.Remove:
                        foreach (UIBindingComponent attributes in uiNode.GetComponents <UIBindingComponent>().Where(x => x.targetComponent == ((KeyValuePair <string, bool>)e.OldItem).Key))
                        {
                            Destroy(attributes);
                        }
                        break;

                    case CollectionChangedAction.Replace:
                        if (((KeyValuePair <string, bool>)e.NewItem).Value == true)
                        {
                            if (uiNode.GetComponents <UIBindingComponent>().Where(x => x.targetComponent == ((KeyValuePair <string, bool>)e.NewItem).Key).Count() == 0)
                            {
                                UIBindingComponent attributes = uiNode.gameObject.AddComponent <UIBindingComponent>();
                                attributes.targetComponent = ((KeyValuePair <string, bool>)e.NewItem).Key;
                            }
                        }
                        else
                        {
                            List <UIBindingComponent> attributes = uiNode.GetComponents <UIBindingComponent>().Where(x => x.targetComponent == ((KeyValuePair <string, bool>)e.NewItem).Key).ToList();
                            while (attributes.Count > 0)
                            {
                                DestroyImmediate(attributes[0]);
                                attributes.RemoveAt(0);
                            }
                        }
                        break;
                    }
                };
            }
        }
예제 #4
0
 public void Binding(UIBehaviour uiComponent, UIBindingComponent bindingComponent, IUILogicalNode target)
 {
     button = uiComponent as Button;
     button.onClick.AddListener(() => { target.ExecuteCommand(bindingComponent.GetBindingPath("OnClick"), null); });
 }