private void ChangeLiteralValue(bool applyValue) { if (SuppressLiteralEvaluation) { return; } var text = LiteralValueInputFieldComponent.text; object result = null; var success = text.StringToValueOfType(Type, ref result); if (applyValue) { UndoLord.Instance.Push(new MutableFieldChange(this, MutableField, "Literal." + text)); } if (success && applyValue) { IndicateError = !MutableField.SetLiteralValueAsObject(result); } else { IndicateError = !success; } }
public void DoUndo(bool toLiteral, string value) { if (LiteralValueDisplayPanel.activeInHierarchy != toLiteral) { if (toLiteral) { SwitchDisplayToLiteralValue(); } else { SwitchDisplayToMutableValue(); } } if (toLiteral) { LiteralValueInputFieldComponent.text = value; object result = null; var success = value.StringToValueOfType(Type, ref result); if (success) { IndicateError = !MutableField.SetLiteralValueAsObject(result); } } else //This was a Mutable { var segmentCount = value.Count(c => c.Equals('.')) + 1; GetComponent <LayoutElement>().preferredHeight = segmentCount * 16; SetSelectedMutableText(value); var schemaSource = value.StartsWith("Local") ? SchemaSource.Mutable : SchemaSource.Global; value = value.Substring(value.IndexOf(".", StringComparison.CurrentCulture) + 1); // ArraySuffix never leaves this class! var arrayFreeText = value.Replace(ArraySuffix, ""); SchemaProvider.CacheSchema(); MutableField.AbsoluteKey = arrayFreeText; MutableField.SchemaSource = schemaSource; bool fieldValid; try { fieldValid = MutableField.ValidateKey(SchemaProvider.Schema); } catch (NullReferenceException) { fieldValid = false; } SchemaProvider.UnCacheSchema(); IndicateError = !fieldValid; SwitchDisplayToMutableValue(); } }