-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using EcsRx.Infrastructure.Dependencies; | ||
using EcsRx.Infrastructure.Extensions; | ||
using EcsRx.Scheduling; | ||
using EcsRx.Unity.Scheduling; | ||
|
||
namespace EcsRx.Unity.Modules | ||
{ | ||
public class UnityOverrideModule : IDependencyModule | ||
{ | ||
public void Setup(IDependencyContainer container) | ||
{ | ||
container.Unbind<IUpdateScheduler>(); | ||
container.Bind<IUpdateScheduler, UnityUpdateScheduler>(x => x.AsSingleton()); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using EcsRx.Scheduling; | ||
using UniRx; | ||
using UnityEngine; | ||
|
||
namespace EcsRx.Unity.Scheduling | ||
{ | ||
public class UnityUpdateScheduler : IUpdateScheduler | ||
{ | ||
public ElapsedTime ElapsedTime { get; private set; } | ||
|
||
private readonly Subject<ElapsedTime> _onPreUpdate = new Subject<ElapsedTime>(); | ||
private readonly Subject<ElapsedTime> _onUpdate = new Subject<ElapsedTime>(); | ||
private readonly Subject<ElapsedTime> _onPostUpdate = new Subject<ElapsedTime>(); | ||
private readonly IDisposable _everyUpdateSub; | ||
|
||
public IObservable<ElapsedTime> OnPreUpdate => _onPreUpdate; | ||
public IObservable<ElapsedTime> OnUpdate => _onUpdate; | ||
public IObservable<ElapsedTime> OnPostUpdate => _onPostUpdate; | ||
|
||
public UnityUpdateScheduler() | ||
{ | ||
_everyUpdateSub = Observable.EveryUpdate().Subscribe(x => | ||
{ | ||
var deltaTime = TimeSpan.FromSeconds(Time.deltaTime); | ||
var totalTime = ElapsedTime.TotalTime + deltaTime; | ||
ElapsedTime = new ElapsedTime(deltaTime, totalTime); | ||
|
||
_onPreUpdate?.OnNext(ElapsedTime); | ||
_onUpdate?.OnNext(ElapsedTime); | ||
_onPostUpdate.OnNext(ElapsedTime); | ||
}); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_everyUpdateSub.Dispose(); | ||
_onPreUpdate?.Dispose(); | ||
_onPostUpdate?.Dispose(); | ||
_onUpdate?.Dispose(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.