public void removeCallBackAllChildren(ValueChangeCallBack valueChangeCallBack) { foreach (WrapProperty property in this.pts) { if (Generic.IsAddCallBackInterface(property.getValueType())) { property.allRemoveCallBack(valueChangeCallBack); } } }
public static void replaceCallBack <T>(ValueChangeCallBack callBack, List <Sync <T> > syncs) { for (int syncCount = 0; syncCount < syncs.Count; syncCount++) { Sync <T> sync = syncs[syncCount]; switch (sync.getType()) { case Sync <T> .Type.Set: { SyncSet <T> syncSet = (SyncSet <T>)sync; if (syncSet.olds.Count == syncSet.news.Count) { for (int i = 0; i < syncSet.olds.Count; i++) { // od value RemoveCallBack(callBack, syncSet.olds[i]); // add new value AddCallBack(callBack, syncSet.news[i]); } } else { Logger.LogError("count error: " + syncSet.olds.Count + "; " + syncSet.news.Count); } } break; case Sync <T> .Type.Add: { SyncAdd <T> syncAdd = (SyncAdd <T>)sync; for (int i = 0; i < syncAdd.values.Count; i++) { T value = syncAdd.values[i]; AddCallBack(callBack, value); } } break; case Sync <T> .Type.Remove: { SyncRemove <T> syncRemove = (SyncRemove <T>)sync; for (int i = 0; i < syncRemove.values.Count; i++) { T value = syncRemove.values[i]; RemoveCallBack(callBack, value); } } break; default: Logger.LogError("unknown type: " + sync.getType()); break; } } }
public override void allRemoveCallBack(ValueChangeCallBack callBack) { if (this.v != null) { ((AddCallBackInterface)this.v).removeCallBack(callBack); } else { // Debug.LogError ("data null: " + this); } }
public static void removeParentCallBack <T>(Data data, ValueChangeCallBack callBack, ref T thisParent) where T : Data { if (thisParent != null) { thisParent.removeCallBack(callBack); thisParent = null; } else { // Debug.LogError ("parent null: " + data + "; " + callBack); } }
public void removeCallBack(ValueChangeCallBack callBack, bool isHide = false) { if (callBacks.Remove(callBack)) { // Debug.Log ("Remove callback success: " + callBack + ", " + this); callBack.onRemoveCallBack(this, isHide); } else { // Debug.LogError ("strange, cannot find callBack: " + this + ", " + callBack); } }
public override void allRemoveCallBack(ValueChangeCallBack callBack) { foreach (T t in this.vs) { if (t != null) { t.removeCallBack(callBack); } else { Logger.LogError("data null: " + callBack + "; " + this + "; " + typeof(T)); } } }
public static void AddCallBack <T>(ValueChangeCallBack callBack, T value) { if (value != null) { if (Generic.IsAddCallBackInterface <T>()) { ((AddCallBackInterface)value).addCallBack(callBack); } else { Logger.LogError("value error: " + value + ", " + callBack); } } else { // Logger.Log("value null: " + value + "; " + callBack); } }
public void removeCallBack(ValueChangeCallBack callBack, bool isHide = false) { if (Generic.IsAddCallBackInterface <T>()) { if (this.data != null) { ((AddCallBackInterface)this.data).removeCallBack(callBack); } else { // Debug.LogError ("data null: " + this); } } else { Logger.LogError("why not data: " + this); } }
public void addCallBack(ValueChangeCallBack callBack) { if (callBack == null) { Logger.LogError("callBack null: " + this); return; } // Add if (!callBacks.Contains(callBack)) { callBacks.Add(callBack); callBack.onAddCallBack(this); } else { // TODO Tam bo Debug.LogError ("Cannot add this callBack: " + this + ", " + callBack); } }
public override void allRemoveCallBack(ValueChangeCallBack callBack) { if (IsAddCallBackInterface) { if (this.v != null) { ((AddCallBackInterface)this.v).removeCallBack(callBack); } else { // Debug.LogError ("data null: " + this); } } else { Logger.LogError("why not data: " + callBack + ";\n " + this + "; " + typeof(T)); } }
public int removeCallBackAndRemoveComponent(System.Type type) { int ret = 0; // Search for (int i = callBacks.Count - 1; i >= 0; i--) { ValueChangeCallBack callBack = callBacks[i]; // Check correct type bool correctType = false; { System.Type callBackType = callBack.GetType(); if (callBackType == type || callBackType.IsSubclassOf(type)) { correctType = true; } if (!correctType) { if (Data.IsSubclassOfRawGeneric(type, callBackType)) { // Debug.LogError ("removeCallBackAndDestroy: correctType: " + type + "; " + callBackType); correctType = true; } } } // Process if (correctType) { this.removeCallBack(callBack); if (callBack is Component) { Component component = callBack as Component; GameObject.Destroy(component); } else { Logger.LogError("Why isn't Component: " + this + "; " + type); } ret++; } } // Return return(ret); }
/** Add neu nhieu cai cung 1 bien thi co the co van de*/ public static T addParentCallBack <T>(Data data, ValueChangeCallBack callBack, ref T thisParent) where T : Data { T ret = null; if (data != null) { T parent = data.findDataInParent <T>(); if (parent != null) { // Set { if (thisParent != parent) { // remove old if (thisParent != null) { // Debug.LogError("Why have old parent: " + thisParent + "; " + data + "; " + callBack); thisParent.removeCallBack(callBack); } // set new thisParent = parent; } else { // Debug.LogError("the same: " + callBack); } } // Add parent.addCallBack(callBack); // return ret = parent; } else { // Debug.LogError ("parent null: " + data + "; " + callBack); } } else { // Debug.LogError ("why data null: " + callBack + "; " + typeof(T)); } return(ret); }
public override void allRemoveCallBack(ValueChangeCallBack callBack) { if (IsAddCallBackInterface) { foreach (T t in this.vs) { if (t != null) { ((AddCallBackInterface)t).removeCallBack(callBack); } else { Logger.LogError("data null: " + callBack + "; " + this + "; " + typeof(T)); } } } else { Logger.LogError("why not data: " + callBack + "; " + this + "; " + typeof(T)); } }
public int removeCallBackAndDestroy(System.Type type) { int ret = 0; // Search for (int i = callBacks.Count - 1; i >= 0; i--) { // check index correct /*{ * if (i < 0 || i >= callBacks.Count) * { * Debug.LogError("callBacks index error: " + i); * continue; * } * }*/ // process ValueChangeCallBack callBack = callBacks[i]; // Check correct type bool correctType = false; { System.Type callBackType = callBack.GetType(); if (callBackType == type || callBackType.IsSubclassOf(type)) { correctType = true; } if (!correctType) { if (Data.IsSubclassOfRawGeneric(type, callBackType)) { // Debug.LogError ("removeCallBackAndDestroy: correctType: " + type + "; " + callBackType); correctType = true; } } } // Process if (correctType) { // Debug.LogError("removeCallBackAndDestroy: " + callBack); // remove this.removeCallBack(callBack); // destroy if (callBack is Component) { Component component = callBack as Component; if (component != null) { GameObject.Destroy(component.gameObject); } else { // Debug.LogError("why component null, cannot destroy: " + this); } } else { Logger.LogError("Why isn't Component: " + this + "; " + type); } ret++; } } // Return return(ret); }
public abstract void allAddCallBack(ValueChangeCallBack callBack);
public abstract void allRemoveCallBack(ValueChangeCallBack callBack);
public void Initialize(string[] stringArray, ValueChangeCallBack callBack = null) { valueChangeCB = callBack; InstantiateData(stringArray); }