using System.Collections; using System.Collections.Generic; using UnityEngine; using AX.MessageSystem; public abstract class BaseInstanceMono : MonoBehaviour { public CloneObjType type; public GameObject ChooseObj; /// /// 打开面板 /// public virtual void OpenPanel() { gameObject.SetActive(true); LoadObjData(ChooseObj); } /// /// 读取物体身上存储的数据 /// public abstract void LoadObjData(GameObject chooseObj); /// /// 重置物体属性 /// /// 需要重置属性的物体 public abstract void ResetData(GameObject dataObj); /// /// 上传照片成功后修改图片id /// /// public virtual void UpLoadImageData(long imageID) { } /// /// 图片获取 /// /// public virtual void GetTexture2D(Texture2D texture) { } /// /// 编辑权限 /// public abstract void EditorRight(); public virtual void OnEnable() { MessageDispatcher.AddListener("RADIO_SELECTED_COMMAND", RadioSelect);//单选选中处理 MessageDispatcher.AddListener("CANCEL_SELECTED_COMMAND", Close);//ESC取消选中处理 // MessageDispatcher.SendMessage("CANCEL_CLONEBTN_SELECTED_COMMAND"); MessageDispatcher.AddListener("DELETE_ALL_COMMAND", Close); MessageDispatcher.AddListener("DELETE_COMMAND", Close); } public virtual void OnDisable() { MessageDispatcher.RemoveListener("CANCEL_SELECTED_COMMAND", Close);//ESC取消选中处理 MessageDispatcher.RemoveListener("DELETE_ALL_COMMAND", Close); MessageDispatcher.RemoveListener("DELETE_COMMAND", Close); MessageDispatcher.RemoveListener("RADIO_SELECTED_COMMAND", RadioSelect);//单选选中处理 } private void OnDestroy() { MessageDispatcher.RemoveListener("RADIO_SELECTED_COMMAND", RadioSelect); MessageDispatcher.RemoveListener("CANCEL_SELECTED_COMMAND", Close);//ESC取消选中处理 MessageDispatcher.RemoveListener("DELETE_ALL_COMMAND", Close); MessageDispatcher.RemoveListener("DELETE_COMMAND", Close); } private void Close(IMessage msg) { Clear(); } /// /// 获取图片错误处理 /// /// /// /*public virtual void Error(int errorCode, string error) { if (errorCode == WebRequestManager.networkError) { ResourceLoadWindow.Instance.LoadTextHintWindow("获取图片失败,请检查您的网络!", 3f); } else if (errorCode >= WebRequestManager.responseCode400 && errorCode <= WebRequestManager.responseCode599) { // Debug.Log(errorCode); ResourceLoadWindow.Instance.LoadTextHintWindow("获取图片失败!", 3f); } }*/ public virtual void Clear() { ChooseObj = null; gameObject.SetActive(false); } public virtual void RadioSelect(IMessage obj) { var gameObjID = (long)obj.Sender; var hitObj = EntitiesManager.Instance.GetEntityByID(gameObjID); //不同类型 if (hitObj.GetComponent().gameObjType != type) return; //属性面板打开 if (gameObject.activeInHierarchy) { //不同的对象 if (ChooseObj != hitObj) { ResetData(ChooseObj); } } ChooseObj = hitObj; OpenPanel(); } }