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

83 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using Mono.Event;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Playables;
namespace UnityTest.ZXL
{
public abstract class ProcessBase : SerializedMonoBehaviour
{
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
protected virtual void OnInit()
{
EventManager.Instance.Subscribe(ConstEventArgs.EventId, ConstEventLogic);
EventManager.Instance.Subscribe(ClickObjectEventArgs.EventId, ClickObjectEvent);
EventManager.Instance.Subscribe(PlayableStoppedEventArgs.EventId, PlayableStoppedEvent);
}
protected virtual void OnUpdate()
{
}
protected virtual void OnLevel()
{
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;
}
private void Awake()
{
OnInit();
}
private void Update()
{
OnUpdate();
}
private void OnDestroy()
{
OnLevel();
}
}
public enum ProcessType
{
_,
_,
_,
_,
}
}