mirror of https://github.com/Cysharp/UniTask
[PlayerLoop]:Add Manual Loop Timing
parent
18f2746f0d
commit
4f292b57e7
|
@ -140,6 +140,9 @@ namespace Cysharp.Threading.Tasks.Internal
|
||||||
LastTimeUpdate();
|
LastTimeUpdate();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case PlayerLoopTiming.Manual:
|
||||||
|
ManualUpdate();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +169,7 @@ namespace Cysharp.Threading.Tasks.Internal
|
||||||
void TimeUpdate() => RunCore();
|
void TimeUpdate() => RunCore();
|
||||||
void LastTimeUpdate() => RunCore();
|
void LastTimeUpdate() => RunCore();
|
||||||
#endif
|
#endif
|
||||||
|
void ManualUpdate() => RunCore();
|
||||||
|
|
||||||
[System.Diagnostics.DebuggerHidden]
|
[System.Diagnostics.DebuggerHidden]
|
||||||
void RunCore()
|
void RunCore()
|
||||||
|
|
|
@ -126,6 +126,9 @@ namespace Cysharp.Threading.Tasks.Internal
|
||||||
LastTimeUpdate();
|
LastTimeUpdate();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case PlayerLoopTiming.Manual:
|
||||||
|
ManualUpdate();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -152,6 +155,7 @@ namespace Cysharp.Threading.Tasks.Internal
|
||||||
void TimeUpdate() => RunCore();
|
void TimeUpdate() => RunCore();
|
||||||
void LastTimeUpdate() => RunCore();
|
void LastTimeUpdate() => RunCore();
|
||||||
#endif
|
#endif
|
||||||
|
void ManualUpdate() => RunCore();
|
||||||
|
|
||||||
[System.Diagnostics.DebuggerHidden]
|
[System.Diagnostics.DebuggerHidden]
|
||||||
void RunCore()
|
void RunCore()
|
||||||
|
|
|
@ -96,6 +96,8 @@ namespace Cysharp.Threading.Tasks
|
||||||
TimeUpdate = 14,
|
TimeUpdate = 14,
|
||||||
LastTimeUpdate = 15,
|
LastTimeUpdate = 15,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Manual
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
@ -393,13 +395,12 @@ namespace Cysharp.Threading.Tasks
|
||||||
|
|
||||||
public static void Initialize(ref PlayerLoopSystem playerLoop, InjectPlayerLoopTimings injectTimings = InjectPlayerLoopTimings.All)
|
public static void Initialize(ref PlayerLoopSystem playerLoop, InjectPlayerLoopTimings injectTimings = InjectPlayerLoopTimings.All)
|
||||||
{
|
{
|
||||||
#if UNITY_2020_2_OR_NEWER
|
var manualIndex = (int)PlayerLoopTiming.Manual;
|
||||||
yielders = new ContinuationQueue[16];
|
yielders = new ContinuationQueue[manualIndex+1];
|
||||||
runners = new PlayerLoopRunner[16];
|
runners = new PlayerLoopRunner[manualIndex+1];
|
||||||
#else
|
|
||||||
yielders = new ContinuationQueue[14];
|
yielders[manualIndex] = new ContinuationQueue(PlayerLoopTiming.Manual);
|
||||||
runners = new PlayerLoopRunner[14];
|
runners[manualIndex] = new PlayerLoopRunner(PlayerLoopTiming.Manual);
|
||||||
#endif
|
|
||||||
|
|
||||||
var copyList = playerLoop.subSystemList.ToArray();
|
var copyList = playerLoop.subSystemList.ToArray();
|
||||||
|
|
||||||
|
@ -485,6 +486,27 @@ namespace Cysharp.Threading.Tasks
|
||||||
PlayerLoop.SetPlayerLoop(playerLoop);
|
PlayerLoop.SetPlayerLoop(playerLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ManualUpdate()
|
||||||
|
{
|
||||||
|
if (yielders != null)
|
||||||
|
{
|
||||||
|
var item = yielders[(int)PlayerLoopTiming.Manual];
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
item.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runners != null)
|
||||||
|
{
|
||||||
|
var item = runners[(int)PlayerLoopTiming.Manual];
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
item.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddAction(PlayerLoopTiming timing, IPlayerLoopItem action)
|
public static void AddAction(PlayerLoopTiming timing, IPlayerLoopItem action)
|
||||||
{
|
{
|
||||||
var runner = runners[(int)timing];
|
var runner = runners[(int)timing];
|
||||||
|
|
Loading…
Reference in New Issue