贺州人民医院电子沙盘
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.7 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AX.MessageSystem;
public abstract class BaseInstanceMono : MonoBehaviour
{
public CloneObjType type;
public GameObject ChooseObj;
/// <summary>
/// 打开面板
/// </summary>
public virtual void OpenPanel()
{
gameObject.SetActive(true);
LoadObjData(ChooseObj);
}
/// <summary>
/// 读取物体身上存储的数据
/// </summary>
public abstract void LoadObjData(GameObject chooseObj);
/// <summary>
/// 重置物体属性
/// </summary>
/// <param name="dataObj">需要重置属性的物体</param>
public abstract void ResetData(GameObject dataObj);
/// <summary>
/// 上传照片成功后修改图片id
/// </summary>
/// <param name="imageID"></param>
public virtual void UpLoadImageData(long imageID) { }
/// <summary>
/// 图片获取
/// </summary>
/// <param name="tex"></param>
public virtual void GetTexture2D(Texture2D texture) { }
/// <summary>
/// 编辑权限
/// </summary>
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();
}
/// <summary>
/// 获取图片错误处理
/// </summary>
/// <param name="errorCode"></param>
/// <param name="error"></param>
/*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<BaseGameObjInfo>().gameObjType != type)
return;
//属性面板打开
if (gameObject.activeInHierarchy)
{
//不同的对象
if (ChooseObj != hitObj)
{
ResetData(ChooseObj);
}
}
ChooseObj = hitObj;
OpenPanel();
}
}