Skip to content

Commit

Permalink
Merge pull request #108 from AnnulusGames/add-default-scheduler
Browse files Browse the repository at this point in the history
Add: MotionScheduler.DefaultScheduler
  • Loading branch information
AnnulusGames committed Mar 17, 2024
2 parents cf2aa69 + 52c55e3 commit 83b455a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,14 @@ static string GetTimeKindName(MotionTimeKind motionTimeKind)
}
if (scheduler == null)
{
#if UNITY_EDITOR
if (isCreatedOnEditor)
{
scheduler = MotionScheduler.Update;
scheduler = MotionScheduler.DefaultScheduler;
}
else
{
scheduler = EditorMotionScheduler.Update;
}
#else
scheduler = MotionScheduler.Update;
#endif
}

return scheduler switch
Expand All @@ -153,7 +149,7 @@ protected override TreeViewItem BuildRoot()
foreach (var tracking in MotionTracker.Items)
{
children.Add(new MotionTrackerViewItem(id)
{
{
MotionType = $"[{tracking.ValueType.Name}, {tracking.OptionsType.Name}, {tracking.AdapterType.Name}]",
SchedulerType = GetSchedulerName(tracking.Scheduler, tracking.CreatedOnEditor),
Elapsed = (DateTime.UtcNow - tracking.CreationTime).TotalSeconds.ToString("00.00"),
Expand Down
10 changes: 2 additions & 8 deletions src/LitMotion/Assets/LitMotion/Runtime/MotionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,14 @@ internal readonly MotionHandle Schedule(IMotionScheduler scheduler, ref MotionDa
#if UNITY_EDITOR
if (!UnityEditor.EditorApplication.isPlaying)
{
// Inlined EditorUpdateMotionScheduler
handle = EditorMotionDispatcher.Schedule<TValue, TOptions, TAdapter>(data, callbackData);
}
else
{
// Inlined PlayerLoopMotionScheduler
data.TimeKind = MotionTimeKind.Time;
handle = MotionDispatcher.Schedule<TValue, TOptions, TAdapter>(data, callbackData, PlayerLoopTiming.Update);
handle = MotionScheduler.DefaultScheduler.Schedule<TValue, TOptions, TAdapter>(ref data, ref callbackData);
}
#else
// Inlined PlayerLoopMotionScheduler
data.TimeKind = MotionTimeKind.Time;
handle = MotionDispatcher.Schedule<TValue, TOptions, TAdapter>(data, callbackData, PlayerLoopTiming.Update);
handle = MotionScheduler.DefaultScheduler.Schedule<TValue, TOptions, TAdapter>(ref data, ref callbackData);
#endif
}
else
Expand Down Expand Up @@ -383,7 +378,6 @@ internal MotionCallbackData BuildCallbackData()
return callbacks;
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal MotionCallbackData BuildCallbackData(Action<TValue> action)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ namespace LitMotion
/// </summary>
public static class MotionScheduler
{
static MotionScheduler()
{
DefaultScheduler = Update;
}

/// <summary>
/// Default scheduler used if not specified
/// </summary>
public static IMotionScheduler DefaultScheduler { get; set; }

/// <summary>
/// Scheduler that updates motion at Initialization.
/// </summary>
Expand Down

0 comments on commit 83b455a

Please sign in to comment.