//更新源 public void UpdateSource() { if (!isBound) { Debug.LogErrorFormat("invalide source {0}", this.path); return; } ExpressionUtility.UpdateSourceValue(target, propertyName, m_Context, m_LastPart, format, convert); }
public bool TryGetValue(bool needSubscribe, out object value) { value = source; if (value != null) { value = ExpressionUtility.GetSourcePropertyValue(value, this, needSubscribe); return(true); } return(false); }
//更新源 public void UpdateSource() { if (!isBound) { Debug.LogErrorFormat("invalide source {0}", this.path); return; } #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.BeginSample(GetProfilerName() + ".UpdateSource"); #endif ExpressionUtility.UpdateSourceValue(target, propertyName, m_Context, m_LastPart, format, convert); #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.EndSample(); #endif }
//更新源 public void UpdateSource() { if (!isBound) { #if UNITY_EDITOR Debug.LogWarningFormat("invalide source {0}.{1}", this.m_Context, this.path); #endif return; } #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.BeginSample("Binding.UpdateSource"); #endif ExpressionUtility.UpdateSourceValue(target, propertyName, m_Context, m_LastPart, format, convert); #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.EndSample(); #endif }
//绑定目标 public void Apply(object context, bool invoke = true) { if (!m_IsApplied) { ParsePath(); m_IsApplied = true; } if (isBound) { Unapply(); } object bindingContext = context; if (source) { bindingContext = source; } m_Context = bindingContext; if (m_Context == null) { return; } object m_Current = bindingContext; #if false ExpressionUtility.ApplyByLua(this, m_Current); #else bool needSubscribe = this.needSubscribe; BindingPathPart part = null; for (var i = 0; i < m_Parts.Count; i++) { part = m_Parts[i]; part.SetSource(m_Current); // if (!part.isSelf && m_Current != null) { if (i < m_Parts.Count - 1) { part.TryGetValue(needSubscribe && part.nextPart != null, out m_Current); //lua NofityObject对象通过此方法在BindingExpression.get_property中订阅 } } if (!part.isSelf && m_Current == null) { break; } if (part.nextPart != null && needSubscribe) { if (m_Current is INotifyPropertyChanged) { part.Subscribe((INotifyPropertyChanged)m_Current); } } } SetLastPart(); if (invoke) { //初始化值 InitValue(); } #endif }
//绑定目标 public void Apply(object context, bool invoke = true) { if (!m_IsApplied) { #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.BeginSample(GetProfilerName() + ".ParsePath"); #endif ParsePath(); #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.EndSample(); #endif m_IsApplied = true; } if (isBound) { #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.BeginSample(GetProfilerName() + ".Unapply"); #endif Unapply(); #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.EndSample(); #endif } object bindingContext = context; if (source) { bindingContext = source; } m_Context = bindingContext; if (m_Context == null) { Unapply(); return; } object m_Current = bindingContext; #if false ExpressionUtility.ApplyByLua(this, m_Current); #else #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.BeginSample(GetProfilerName() + ".Part.TryGetValue"); #endif bool needSubscribe = this.needSubscribe; BindingPathPart part = null; for (var i = 0; i < m_Parts.Count; i++) { part = m_Parts[i]; part.SetSource(m_Current); // if (!part.isSelf && m_Current != null) { if (i < m_Parts.Count - 1) { part.TryGetValue(needSubscribe && part.nextPart != null, out m_Current); //lua NofityObject对象通过此方法在BindingExpression.get_property中订阅 } } if (!part.isSelf && m_Current == null) { break; } if (part.nextPart != null && needSubscribe) { if (m_Current is INotifyPropertyChanged) { part.Subscribe((INotifyPropertyChanged)m_Current); } } } SetLastPart(); #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.EndSample(); #endif if (invoke) { #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.BeginSample(GetProfilerName() + ".InitValue"); #endif //初始化值 InitValue(); #if LUA_PROFILER_DEBUG UnityEngine.Profiling.Profiler.EndSample(); #endif } #endif }