Last active
October 1, 2015 19:44
Revisions
-
oskar-szulc revised this gist
Oct 1, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,9 @@ void Awake() TargetProperty = tempTarget.FirstOrDefault(); SourceProperty = tempSource.FirstOrDefault(); #endif } void Start() { SourceProperty.ObserveEveryValueChanged(x => x.GetValue(Source, null)).Subscribe(UpdateTargetProperty); } -
oskar-szulc created this gist
Oct 1, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ [HideInInspector] public PropertyInfo SourceProperty; [HideInInspector] public PropertyInfo TargetProperty; [HideInInspector] public string SourcePropertyName; [HideInInspector] public string TargetPropertyName; public MonoBehaviour Source; public MonoBehaviour Target; void Awake() { #if !UNITY_EDITOR var tempTarget = from targetProp in Target.GetType().GetProperties() where targetProp.Name == TargetPropertyName select targetProp; var tempSource = from sourceProp in Source.GetType().GetProperties() where sourceProp.Name == SourcePropertyName select sourceProp; TargetProperty = tempTarget.FirstOrDefault(); SourceProperty = tempSource.FirstOrDefault(); #endif SourceProperty.ObserveEveryValueChanged(x => x.GetValue(Source, null)).Subscribe(UpdateTargetProperty); }