public void Bind() { if (!this.isBound && (!(this.DataSource is dfDataObjectProxy) || (((dfDataObjectProxy)this.DataSource).Data != null))) { dfScriptEngineSettings settings2 = new dfScriptEngineSettings(); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("Application", typeof(Application)); dictionary.Add("Color", typeof(Color)); dictionary.Add("Color32", typeof(Color32)); dictionary.Add("Random", typeof(UnityEngine.Random)); dictionary.Add("Time", typeof(Time)); dictionary.Add("ScriptableObject", typeof(ScriptableObject)); dictionary.Add("Vector2", typeof(Vector2)); dictionary.Add("Vector3", typeof(Vector3)); dictionary.Add("Vector4", typeof(Vector4)); dictionary.Add("Quaternion", typeof(Quaternion)); dictionary.Add("Matrix", typeof(Matrix4x4)); dictionary.Add("Mathf", typeof(Mathf)); settings2.Constants = dictionary; dfScriptEngineSettings settings = settings2; if (this.DataSource is dfDataObjectProxy) { dfDataObjectProxy dataSource = this.DataSource as dfDataObjectProxy; settings.AddVariable(new dfScriptVariable("source", null, dataSource.DataType)); } else { settings.AddVariable(new dfScriptVariable("source", this.DataSource)); } this.compiledExpression = dfScriptEngine.CompileExpression(this.expression, settings); this.targetProperty = this.DataTarget.GetProperty(); this.isBound = (this.compiledExpression != null) && (this.targetProperty != null); } }
public void Bind() { if (this.isBound) { return; } if (!this.IsDataSourceValid()) { Debug.LogError(string.Format("Invalid data binding configuration - Source:{0}, Target:{1}", this.DataSource, this.DataTarget)); return; } if (!this.DataTarget.IsValid) { Debug.LogError(string.Format("Invalid data binding configuration - Source:{0}, Target:{1}", this.DataSource, this.DataTarget)); return; } dfDataObjectProxy component = this.DataSource.Component as dfDataObjectProxy; this.sourceProperty = component.GetProperty(this.DataSource.MemberName); this.targetProperty = this.DataTarget.GetProperty(); this.isBound = (this.sourceProperty == null ? false : this.targetProperty != null); if (this.isBound) { this.targetProperty.Value = this.sourceProperty.Value; } this.attachEvent(); }
private void detachEvent() { if (this.eventsAttached) { this.eventsAttached = false; dfDataObjectProxy component = this.DataSource.Component as dfDataObjectProxy; if (component != null) { component.DataChanged -= new dfDataObjectProxy.DataObjectChangedHandler(this.handle_DataChanged); } } }
private void attachEvent() { if (this.eventsAttached) { return; } this.eventsAttached = true; dfDataObjectProxy component = this.DataSource.Component as dfDataObjectProxy; if (component != null) { component.DataChanged += new dfDataObjectProxy.DataObjectChangedHandler(this.handle_DataChanged); } }
public void Bind() { if (this.isBound) { return; } if (this.DataSource is dfDataObjectProxy && ((dfDataObjectProxy)this.DataSource).Data == null) { return; } dfScriptEngineSettings dfScriptEngineSetting = new dfScriptEngineSettings(); Dictionary <string, object> strs = new Dictionary <string, object>() { { "Application", typeof(Application) }, { "Color", typeof(Color) }, { "Color32", typeof(Color32) }, { "Random", typeof(UnityEngine.Random) }, { "Time", typeof(Time) }, { "ScriptableObject", typeof(ScriptableObject) }, { "Vector2", typeof(Vector2) }, { "Vector3", typeof(Vector3) }, { "Vector4", typeof(Vector4) }, { "Quaternion", typeof(Quaternion) }, { "Matrix", typeof(Matrix4x4) }, { "Mathf", typeof(Mathf) } }; dfScriptEngineSetting.Constants = strs; dfScriptEngineSettings dfScriptEngineSetting1 = dfScriptEngineSetting; if (!(this.DataSource is dfDataObjectProxy)) { dfScriptEngineSetting1.AddVariable(new dfScriptVariable("source", this.DataSource)); } else { dfDataObjectProxy dataSource = this.DataSource as dfDataObjectProxy; dfScriptEngineSetting1.AddVariable(new dfScriptVariable("source", null, dataSource.DataType)); } this.compiledExpression = dfScriptEngine.CompileExpression(this.expression, dfScriptEngineSetting1); this.targetProperty = this.DataTarget.GetProperty(); this.isBound = (this.compiledExpression == null ? false : this.targetProperty != null); }
void Start() { selectedItemProxy = GetComponent<dfDataObjectProxy>(); var container = GetComponent<dfControl>(); if( container == null ) return; container = container.GetRootContainer(); container.EnterFocus += ( sender, args ) => { StartCoroutine( PopulateGrid() ); }; container.LeaveFocus += ( sender, args ) => { StopAllCoroutines(); isGridPopulated = false; for( int i = 0; i < rows.Count; i++ ) { rows[ i ].RemoveAllEventHandlers(); dfPoolManager.Pool[ "Browse" ].Despawn( rows[ i ].gameObject ); } rows.Clear(); }; }