void OnDestroy() { if (null != this.GameControllerEvents) { this.DetachEventHandler(ac.isReadyCallback); } if (ac != null) { ac.DetachEventCallback(this.ControllEventCallback); for (int col = 0; col < this.mCol; col++) { for (int row = 0; row < this.mRow; row++) { Candy item = getCandy(col, row); if (null != item) { item.DetachEventCallback(ac.ExchangeEventCallback); DestroyCandy(item); item = null; } } } for (int index = 0; index < this.RecycleList.Count; index++) { Candy temp = RecycleList[index]; temp.DetachEventCallback(ac.ExchangeEventCallback); DestroyCandy(temp); temp = null; } } }