Files
JJBB/Assets/Project/Script/SceneMovie/MovieEventSend.cs

67 lines
1.4 KiB
C#
Raw Permalink Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using Games.Events;
using System.Collections;
using System.Collections.Generic;
public class EventSenderInfo
{
public int _SendID;
public bool _State;
public List<MovieEventSend.EventInfo> Events = new List<MovieEventSend.EventInfo>();
}
public class MovieEventSend : MonoBehaviour
{
public enum EventType
{
None,
ChangeMesh,
AddMesh,
DoAction,
StartTimeLine,
Dissolve,
ShowGameObj,
HideGameObj,
DestroyObj,
}
[System.Serializable]
public class EventInfo
{
public EventType EventType;
public int EveneID = -1;
}
public bool RemoveOnDisable = true;
public bool SendOnAwake = false;
public EventInfo[] Events;
public void OnEnable()
{
if(SendOnAwake)
Send(true);
}
public void OnDisable()
{
if(RemoveOnDisable)
Send(false);
}
public void Send(bool state)
{
EventSenderInfo info = new EventSenderInfo();
info._SendID = gameObject.GetInstanceID();
info._State = state;
for (int i=0;i<Events.Length;i++)
{
EventInfo even = Events[i];
if(even.EveneID!=-1 && even.EventType != EventType.None)
info.Events.Add(even);
}
EventDispatcher.Instance.Dispatch(Games.Events.EventId.MovieEvent, info);
}
}