Files
Main/Assets/Launcher/ExternalLibs/TimelineTrack/PushEventTrack/PushEventBehaviour.cs

51 lines
1.4 KiB
C#
Raw Normal View History

2025-01-25 04:38:09 +08:00
using System;
using UnityEngine;
using UnityEngine.Gonbest.MagicCube;
using UnityEngine.Playables;
namespace Thousandto.Launcher.ExternalLibs
{
/// <summary>
/// 触发消息的处理逻辑
/// </summary>
[Serializable]
public class PushEventBehaviour : PlayableBehaviour
{
//记录触发次数
private int _triggerCount = 0;
//是否为全局触发,没有特定的事件接收者
public bool IsGlobal = false;
//是否为多次触发 -- 没帧都会触发
public bool IsMultiple = false;
//事件ID
public int EventID = -1;
//事件参数
public string EventParams = string.Empty;
/// <summary>
/// 触发
/// </summary>
/// <param name="go"></param>
public void DoTrigger(GameObject go)
{
if ((_triggerCount <= 0 || IsMultiple) && EventID > 0)
{
_triggerCount++;
EventManager.SharedInstance.PushFixEvent(EventID, EventParams, null, (IsGlobal ? null : go));
Debug.Log("通过Timeline进行发送消息:ID=" + EventID + ";;Param=" + (EventParams == null ? "NULL" : EventParams));
}
}
/// <summary>
/// 复位
/// </summary>
public void Reset()
{
_triggerCount = 0;
}
}
}