Last active
January 17, 2017 07:25
-
-
Save oskar-szulc/9fa1368651cae313ba68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HideInInspector] public PropertyInfo SourceProperty; | |
[HideInInspector] public PropertyInfo TargetProperty; | |
void Start() | |
{ | |
SourceProperty.ObserveEveryValueChanged(x => x.GetValue(Source, null)).Subscribe(UpdateTargetProperty); | |
} | |
private void UpdateTargetProperty(object value) | |
{ | |
if (TargetProperty.PropertyType == typeof(string)) | |
{ | |
TargetProperty.SetValue( | |
Target, | |
string.Format(FormatString, value), | |
null | |
); | |
} | |
else //we can assign 1:1 | |
{ | |
TargetProperty.SetValue( | |
Target, | |
value, | |
null | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment