Beispiel #1
0
        public void Setup(OutPort Port, NodeInfoDialog NodeInfoDialog)
        {
            this.Port     = Port;
            PortName.text = Port.Name;
            PortType.text = Port.TypesToString();

            PortNameButton.onClick.AddListener(() => NodeInfoDialog.SelectDetailsModeFor(this));
        }
Beispiel #2
0
        public void Setup(InPort Port, NodeInfoDialog NodeInfoDialog)
        {
            this.Port     = Port;
            PortName.text = Port.Name;
            PortType.text = Port.TypesToString();

            PortNameButton.onClick.AddListener(() => NodeInfoDialog.SelectDetailsModeFor(this));

            bool contentHasChanged = false;

            DefaultValueInput.gameObject.AddComponent <UIEventRedirector>().Setup(() => {
                if (UpdateDV())
                {
                    DefaultValueInput.text = DataTreatment.GetDataEditable(dv.Data);
                }
                contentHasChanged = false;
            }, null);

            DefaultValueInput.onEndEdit.AddListener((s) => {
                if (contentHasChanged)
                {
                    //if (s == "") {
                    // TODO Delete default value
                    //    Port.Component.Graph.RemoveDefaultValue(Port);
                    //    Debug.Log("removing dv from port: " + Port.Name);
                    //} else {
                    // TODO Check data types, if string, ok.
                    // If number, try to parse.

                    if (UpdateDV())
                    {
                        dv.SetData(s);
                        RefreshDefaultValueShown();
                    }
                    else
                    {
                        Port.Component.Graph.AddDefaultValue(s, Port);
                        RefreshDefaultValueShown();
                    }
                    //}
                }
                else
                {
                    RefreshDefaultValueShown();
                }
            });

            DefaultValueInput.onValueChanged.AddListener((s) => {
                contentHasChanged = true;
            });

            SelectVariable.onClick.AddListener(() => {
                NodeInfoDialog.SelectVariableModeFor(this);
            });

            ClearVariable.onClick.AddListener(() => {
                Port.Component.Graph.RemoveDefaultValue(Port);
                RefreshDefaultValueShown();
            });

            RefreshDefaultValueShown();
        }