public virtual void SetMahjongScript() { if (_box == null) { if (gameObject.GetComponent <BoxCollider>()) { _box = gameObject.GetComponent <BoxCollider>(); } else { _box = gameObject.AddComponent <BoxCollider>(); } _box.size = MahjongManager.MagjongSize; } if (_icon == null) { if (gameObject.GetComponent <MahjongIcon>()) { _icon = gameObject.GetComponent <MahjongIcon>(); } else { _icon = gameObject.AddComponent <MahjongIcon>(); } } if (_uc == null) { if (gameObject.GetComponent <UserContorl>()) { _uc = gameObject.GetComponent <UserContorl>(); } else { _uc = gameObject.AddComponent <UserContorl>(); } } if (_roll == null) { if (gameObject.GetComponent <MouseRoll>()) { _roll = gameObject.GetComponent <MouseRoll>(); } else { _roll = gameObject.AddComponent <MouseRoll>(); } _roll.Target = Model.transform; } }
public void RemoveMahjongScript() { if (_roll != null) { DestroyImmediate(_roll); _roll = null; } if (_uc != null) { DestroyImmediate(_uc); _uc = null; } if (_box != null) { DestroyImmediate(_box); _box = null; } if (_icon != null) { _icon.OnRemoveComponent(); DestroyImmediate(_icon); _icon = null; } else { //删除复制出来的麻将的 听或游金Icon for (int i = 0; i < transform.childCount; i++) { var obj = transform.GetChild(i); if (obj.name.Contains("Clone")) { DestroyImmediate(obj.gameObject); } } } }