Пример #1
0
        public void AssignFromText(string text)
        {
            //TMPro.TMP_InputField input = GetComponent<TMPro.TMP_InputField>();
            //Show.Log("assign "+text+" instead of "+input.text);
            UnityDataSheet uds = GetComponentInParent <UnityDataSheet>();

            if (uds == null)
            {
                // this happens the first instant that the input field is created, before it is connected to the UI properly
                //Show.Log("missing "+nameof(UnityDataSheet)+" for "+transform.HierarchyPath());
                return;
            }
            int col = transform.GetSiblingIndex();
            int row = uds.GetRowIndex(transform.parent.gameObject);

            Udash.ColumnSetting column = uds.GetColumn(col);
            if (column.canEdit)
            {
                object value           = text;
                bool   validAssignment = true;
                if (column.type != null)
                {
                    if (!CodeConvert.Convert(ref value, column.type))
                    {
                        errorMessage = "could not assign \"" + text + "\" to " + column.type;
                        uds.errLog.AddError(-1, errorMessage);
                        validAssignment = false;
                        uds.popup.Set("err", gameObject, errorMessage);
                    }
                }
                if (validAssignment)
                {
                    ITokenErrLog errLog = new TokenErrorLog();
                    validAssignment = column.SetValue(uds.GetItem(row), value, errLog);
                    if (errLog.HasError())
                    {
                        errorMessage    = errLog.GetErrorString();
                        validAssignment = false;
                        uds.popup.Set("err", gameObject, errorMessage);
                    }
                }

                if (validAssignment)
                {
                    uds.data.Set(row, col, value);
                    if (errorMessage == uds.popup.Message)
                    {
                        uds.popup.Hide();
                    }
                }
            }
        }
        public void ColumnRemove()
        {
            ModalConfirmation ui = confirmRemoveUi;

            if (ui == null)
            {
                ui = Global.GetComponent <ModalConfirmation>();
            }
            Udash.ColumnSetting cS = uds.GetColumn(column);
            ui.OkCancel("Are you sure you want to delete column \"" + cS.data.label + "\"?", () => {
                uds.RemoveColumn(column);
                Close();
            });
            uds.RefreshUi();
        }