public void OnSrcUpdated() { try { if (_converters != null && _converters.Length > 0) { DstTarget.SetValue(_converters.ChainConvert(SrcTarget.GetValue(), DstTarget.property.PropertyType, null)); } else if (SrcTarget.property.PropertyType == DstTarget.property.PropertyType) { DstTarget.SetValue(SrcTarget.GetValue()); } else if (SrcTarget.GetValue() is IConvertible) { DstTarget.SetValue(Convert.ChangeType(SrcTarget.GetValue(), DstTarget.property.PropertyType)); } else { DstTarget.SetValue(SrcTarget.GetValue()); } } catch (Exception e) { Debug.LogError($"Data binding error in: {OwnerObject.name}: {e}", OwnerObject); if (e.InnerException != null) { Debug.LogErrorFormat("Inner Exception: {0}", e.InnerException); } } }
public void DstUpdated() { if (_converters != null && _converters.Length > 0) { SrcTarget.SetValue(_converters.ChainConvertBack(DstTarget.GetValue(), SrcTarget.property.PropertyType, null)); } else if (SrcTarget.property.PropertyType == DstTarget.property.PropertyType) { SrcTarget.SetValue(DstTarget.GetValue()); } else { SrcTarget.SetValue(Convert.ChangeType(DstTarget.GetValue(), SrcTarget.property.PropertyType)); } }