1
0
Fork 0
LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/Process/ProcessBase.cs

83 lines
2.1 KiB
C#
Raw Normal View History

2023-09-13 15:04:19 +08:00
using System;
2023-09-17 01:22:28 +08:00
using System.Collections.Generic;
using Mono.Event;
2023-09-13 15:04:19 +08:00
using Sirenix.OdinInspector;
2023-09-17 01:22:28 +08:00
using UnityEngine;
using UnityEngine.Playables;
2023-09-12 23:57:06 +08:00
namespace UnityTest.ZXL
{
public abstract class ProcessBase : SerializedMonoBehaviour
{
2023-09-17 01:22:28 +08:00
public ProcessType processType;
public List<PlayableDirector> playableDirectors = new List<PlayableDirector>();
#if UNITY_EDITOR
[Button]
void Add(GameObject go)
{
var list = go.GetComponentAllChild<PlayableDirector>();
playableDirectors = new List<PlayableDirector>(list);
}
#endif
2023-09-13 15:04:19 +08:00
protected virtual void OnInit()
{
2023-09-17 01:22:28 +08:00
EventManager.Instance.Subscribe(ConstEventArgs.EventId, ConstEventLogic);
EventManager.Instance.Subscribe(ClickObjectEventArgs.EventId, ClickObjectEvent);
EventManager.Instance.Subscribe(PlayableStoppedEventArgs.EventId, PlayableStoppedEvent);
2023-09-13 15:04:19 +08:00
}
protected virtual void OnUpdate()
{
}
protected virtual void OnLevel()
{
2023-09-17 01:22:28 +08:00
EventManager.Instance.Unsubscribe(ConstEventArgs.EventId, ConstEventLogic);
EventManager.Instance.Unsubscribe(ClickObjectEventArgs.EventId, ClickObjectEvent);
EventManager.Instance.Unsubscribe(PlayableStoppedEventArgs.EventId, PlayableStoppedEvent);
}
public virtual void ConstEventLogic(object sender, GameEventArgs e)
{
var args = e as ConstEventArgs;
}
public virtual void PlayableStoppedEvent(object sender, GameEventArgs e)
{
var args = e as PlayableStoppedEventArgs;
}
public virtual void ClickObjectEvent(object sender, GameEventArgs e)
{
var args = e as ClickObjectEventArgs;
2023-09-13 15:04:19 +08:00
}
2023-09-17 01:22:28 +08:00
2023-09-13 15:04:19 +08:00
private void Awake()
{
OnInit();
}
private void Update()
{
OnUpdate();
}
2023-09-17 01:22:28 +08:00
private void OnDestroy()
{
OnLevel();
}
}
public enum ProcessType
{
_,
_,
_,
_,
2023-09-12 23:57:06 +08:00
}
}