Skip to content

Commit b333205

Browse files
authored
fix: YieldPool unsupported code for Unity 2019 is now only available in UNITY_2020_1_OR_NEWER (#95)
1 parent 4720e55 commit b333205

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Runtime/Async/Coroutine/Pooled YieldInstruction/WaitForSecondsPooled.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if UNITY_2020_1_OR_NEWER
12
using UnityEngine;
23

34
namespace StansAssets.Foundation.Async
@@ -34,3 +35,4 @@ public WaitForSecondsPooled Wait(float time)
3435
}
3536
}
3637
}
38+
#endif

Runtime/Async/Coroutine/Pooled YieldInstruction/WaitForSecondsRealtimePooled.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if UNITY_2020_1_OR_NEWER
12
using UnityEngine;
23

34
namespace StansAssets.Foundation.Async
@@ -34,3 +35,4 @@ public WaitForSecondsRealtimePooled Wait(float time)
3435
}
3536
}
3637
}
38+
#endif

Runtime/Async/Coroutine/Pooled YieldInstruction/YieldPool.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ public static class YieldPool
1212
static YieldPool()
1313
{
1414
s_Instructions = new Dictionary<Type, ObjectPool<PooledYieldInstruction>>();
15-
Add<WaitForSecondsPooled>();
15+
1616
Add<WaitUntilPooled>();
1717
Add<WaitWhilePooled>();
18+
#if UNITY_2020_1_OR_NEWER
19+
Add<WaitForSecondsPooled>();
1820
Add<WaitForSecondsRealtimePooled>();
21+
#endif
1922
}
2023

2124
static void Add<T>() where T : PooledYieldInstruction, new()
@@ -34,6 +37,7 @@ internal static void BackToPool<T>(T pooled) where T : PooledYieldInstruction
3437
return (T)s_Instructions[typeof(T)].Get();
3538
}
3639

40+
#if UNITY_2020_1_OR_NEWER
3741
/// <summary>
3842
/// Wait for a given number of seconds using scaled time.
3943
/// <param name="seconds">Delay execution by the amount of time in seconds.</param>
@@ -51,6 +55,7 @@ public static WaitForSecondsRealtimePooled WaitForSecondsRealtime(float seconds)
5155
{
5256
return GetFromPool<WaitForSecondsRealtimePooled>().Wait(seconds);
5357
}
58+
#endif
5459

5560
/// <summary>
5661
/// Suspends the coroutine execution until the supplied delegate evaluates to false.

0 commit comments

Comments
 (0)