/// <summary> /// 绑定 /// </summary> /// <param name="target"></param> protected virtual void OnBinding(GameObject target) { this.target = target; name = target.name; viewBaseBinding = target.AddComponent <DestroyMonitor>(); viewBaseBinding.onDestroy = OnTargetDestroy; }
/// <summary> /// 去除绑定 /// </summary> /// <param name="target"></param> protected virtual void OnUnBinding(GameObject target) { if (target) { viewBaseBinding = target.GetComponent <DestroyMonitor>(); if (viewBaseBinding) { GameObject.Destroy(viewBaseBinding); } } this.target = null; }