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.
74 lines
2.1 KiB
74 lines
2.1 KiB
using AX.MessageSystem; |
|
using AX.NetworkSystem; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class ObjDelete : MonoBehaviour |
|
{ |
|
|
|
// Use this for initialization |
|
void Start() |
|
{ |
|
MessageDispatcher.AddListener("ReplayEvent", ReplayEventDelete); |
|
} |
|
|
|
|
|
|
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
|
|
} |
|
|
|
void OnEnable() |
|
{ |
|
MessageDispatcher.AddListener("DELETE_COMMAND", ObjDeleted); |
|
} |
|
|
|
void OnDisable() |
|
{ |
|
MessageDispatcher.RemoveListener("DELETE_COMMAND", ObjDeleted); |
|
} |
|
|
|
void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("DELETE_COMMAND", ObjDeleted); |
|
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventDelete); |
|
} |
|
|
|
protected virtual void ObjDeleted(IMessage obj) |
|
{ |
|
if (SelectedObjs.selectedObj == gameObject) |
|
{ |
|
ResourceLoadWindow.Instance.LoadTipWindow("确定删除物体?", () => |
|
{ |
|
MessageDispatcher.SendMessage("DeleteObj", gameObject); |
|
EntitiesManager.Instance.DeleteObj(gameObject); |
|
AddRecordEventDelete(); |
|
}, null); |
|
} |
|
} |
|
public void AddRecordEventDelete() |
|
{ |
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) |
|
{ |
|
var eventData = new EventData(); |
|
eventData.time = RecordManager.Instance.RecordTimer; |
|
eventData.cloneObjType = GetComponent<BaseGameObjInfo>().gameObjType; |
|
eventData.eventType = RecordEventType.Delete; |
|
string json = gameObject.name; |
|
eventData.json = json; |
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData); |
|
} |
|
} |
|
private void ReplayEventDelete(IMessage data) |
|
{ |
|
var eventData = (EventData)data.Data; |
|
if (eventData.json == gameObject.name && eventData.eventType == RecordEventType.Delete) |
|
{ |
|
EntitiesManager.Instance.DeleteObj(gameObject); |
|
} |
|
} |
|
}
|
|
|