/// <summary> /// 绑定物体DataModelBehaviour的数据实体,如果不能获取,则抛出异常; /// </summary> /// <param name="observer"></param> /// <param name="subject"></param> public void Binding(DataModelBehaviour observer, BaseDataModelEntity subject) { if (observer != null && subject != null) { observer.Watch(subject); } else { throw new BindingException("observer or subject could not be found."); } }
/// <summary> /// 绑定物体,本函数中自动获取gameObject的DataModelBehaviour对象, /// 如果不能获取,则抛出异常; /// </summary> /// <param name="goObserver"></param> /// <param name="goSubject"></param> public void Binding(GameObject goObserver, GameObject goSubject) { DataModelBehaviour observer = null; DataModelBehaviour subject = null; observer = goObserver.GetComponent <DataModelBehaviour>(); subject = goSubject.GetComponent <DataModelBehaviour>(); if (observer != null && subject != null) { observer.Watch(subject); } else { throw new BindingException("observer or subject could not be found."); } }