1
This commit is contained in:
82
Src/Unity/Scripts/Tick/UnityTickService.cs
Normal file
82
Src/Unity/Scripts/Tick/UnityTickService.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks.Triggers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
|
||||
public class UnityUpdateTick:IMainTicker
|
||||
{
|
||||
public ulong TickCount { get; set; }
|
||||
public void Add(Action action)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Add(Action<float> action)=>UnityTickService.UpdateTick += action;
|
||||
|
||||
public void Remove(Action<float> action)=>UnityTickService.UpdateTick -= action;
|
||||
|
||||
public void ManualTick(float delta)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class UnityFixedUpdateTick:IFixedTicker
|
||||
{
|
||||
public ulong TickCount { get; set; }
|
||||
public void Add(Action action)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Add(Action<float> action)=>UnityTickService.FixedUpdateTick += action;
|
||||
|
||||
public void Remove(Action<float> action)=>UnityTickService.FixedUpdateTick -= action;
|
||||
|
||||
public void ManualTick(float delta)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class UnityLateUpdateTick:IAfterTicker
|
||||
{
|
||||
public ulong TickCount { get; set; }
|
||||
public void Add(Action action)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Add(Action<float> action)=>UnityTickService.LateUpdateTick += action;
|
||||
|
||||
public void Remove(Action<float> action)=>UnityTickService.LateUpdateTick -= action;
|
||||
|
||||
public void ManualTick(float delta)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class UnityTickService : MonoBehaviour
|
||||
{
|
||||
public static event Action<float> UpdateTick;
|
||||
public static event Action<float> FixedUpdateTick;
|
||||
public static event Action<float> LateUpdateTick;
|
||||
private void Update()
|
||||
{
|
||||
UpdateTick?.Invoke(Time.deltaTime);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
FixedUpdateTick?.Invoke(Time.fixedDeltaTime);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
LateUpdateTick?.Invoke(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user