complete implementation(triggers and etc...)
parent
7bc9ef90f1
commit
b8d1a09224
|
@ -101,12 +101,12 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var a = UniTask.FromResult(999);
|
||||
var b = UniTask.Yield(PlayerLoopTiming.Update, CancellationToken.None).AsAsyncUnitUniTask();
|
||||
var c = UniTask.DelayFrame(99);
|
||||
var c = UniTask.DelayFrame(99).AsAsyncUnitUniTask();
|
||||
|
||||
var (a2, b2, c2) = await UniTask.WhenAll(a, b, c);
|
||||
a2.Should().Be(999);
|
||||
b2.Should().Be(AsyncUnit.Default);
|
||||
c2.Should().Be(99);
|
||||
c2.Should().Be(AsyncUnit.Default);
|
||||
});
|
||||
|
||||
[UnityTest]
|
||||
|
@ -114,14 +114,11 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var a = UniTask.FromResult(999);
|
||||
var b = UniTask.Yield(PlayerLoopTiming.Update, CancellationToken.None).AsAsyncUnitUniTask();
|
||||
var c = UniTask.DelayFrame(99);
|
||||
var c = UniTask.DelayFrame(99).AsAsyncUnitUniTask();
|
||||
|
||||
var (win, a2, b2, c2) = await UniTask.WhenAny(a, b, c);
|
||||
win.Should().Be(0);
|
||||
a2.hasResult.Should().Be(true);
|
||||
a2.result0.Should().Be(999);
|
||||
b2.hasResult.Should().Be(false);
|
||||
c2.hasResult.Should().Be(false);
|
||||
a2.Should().Be(999);
|
||||
});
|
||||
|
||||
[UnityTest]
|
||||
|
@ -151,7 +148,7 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
bool t = false;
|
||||
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => t = true).Forget();
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(() => t = true).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitUntil(() => t, PlayerLoopTiming.EarlyUpdate);
|
||||
|
@ -165,7 +162,7 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
bool t = true;
|
||||
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => t = false).Forget();
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(() => t = false).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitWhile(() => t, PlayerLoopTiming.EarlyUpdate);
|
||||
|
@ -179,7 +176,7 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var v = new MyMyClass { MyProperty = 99 };
|
||||
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => v.MyProperty = 1000).Forget();
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(() => v.MyProperty = 1000).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitUntilValueChanged(v, x => x.MyProperty, PlayerLoopTiming.EarlyUpdate);
|
||||
|
@ -269,10 +266,10 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
UniTask.DelayFrame(10).ContinueWith(_ => cts.Cancel()).Forget();
|
||||
UniTask.DelayFrame(10).ContinueWith(() => cts.Cancel()).Forget();
|
||||
|
||||
var first = Time.frameCount;
|
||||
var (canceled, value) = await UniTask.DelayFrame(100, cancellationToken: cts.Token).SuppressCancellationThrow();
|
||||
var canceled = await UniTask.DelayFrame(100, cancellationToken: cts.Token).SuppressCancellationThrow();
|
||||
|
||||
(Time.frameCount - first).Should().Be(11); // 10 frame canceled
|
||||
canceled.Should().Be(true);
|
||||
|
@ -283,12 +280,12 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
UniTask.DelayFrame(10).ContinueWith(_ => cts.Cancel()).Forget();
|
||||
UniTask.DelayFrame(10).ContinueWith(() => cts.Cancel()).Forget();
|
||||
|
||||
bool occur = false;
|
||||
try
|
||||
{
|
||||
var value = await UniTask.DelayFrame(100, cancellationToken: cts.Token);
|
||||
await UniTask.DelayFrame(100, cancellationToken: cts.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -407,7 +404,7 @@ namespace UniRx.AsyncTests
|
|||
completedTaskObserver.OnCompletedCalled.Should().BeTrue();
|
||||
completedTaskObserver.OnErrorCalled.Should().BeFalse();
|
||||
|
||||
var delayFrameTaskObserver = new ToObservableObserver<int>();
|
||||
var delayFrameTaskObserver = new ToObservableObserver<AsyncUnit>();
|
||||
UniTask.DelayFrame(1).ToObservable().Subscribe(delayFrameTaskObserver);
|
||||
delayFrameTaskObserver.OnNextCalled.Should().BeFalse();
|
||||
delayFrameTaskObserver.OnCompletedCalled.Should().BeFalse();
|
||||
|
|
|
@ -101,12 +101,12 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var a = UniTask.FromResult(999);
|
||||
var b = UniTask.Yield(PlayerLoopTiming.Update, CancellationToken.None).AsAsyncUnitUniTask();
|
||||
var c = UniTask.DelayFrame(99);
|
||||
var c = UniTask.DelayFrame(99).AsAsyncUnitUniTask();
|
||||
|
||||
var (a2, b2, c2) = await UniTask.WhenAll(a, b, c);
|
||||
a2.Should().Be(999);
|
||||
b2.Should().Be(AsyncUnit.Default);
|
||||
c2.Should().Be(99);
|
||||
c2.Should().Be(AsyncUnit.Default);
|
||||
});
|
||||
|
||||
[UnityTest]
|
||||
|
@ -114,14 +114,11 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var a = UniTask.FromResult(999);
|
||||
var b = UniTask.Yield(PlayerLoopTiming.Update, CancellationToken.None).AsAsyncUnitUniTask();
|
||||
var c = UniTask.DelayFrame(99);
|
||||
var c = UniTask.DelayFrame(99).AsAsyncUnitUniTask();
|
||||
|
||||
var (win, a2, b2, c2) = await UniTask.WhenAny(a, b, c);
|
||||
win.Should().Be(0);
|
||||
a2.hasResult.Should().Be(true);
|
||||
a2.result0.Should().Be(999);
|
||||
b2.hasResult.Should().Be(false);
|
||||
c2.hasResult.Should().Be(false);
|
||||
a2.Should().Be(999);
|
||||
});
|
||||
|
||||
[UnityTest]
|
||||
|
@ -153,7 +150,7 @@ namespace UniRx.AsyncTests
|
|||
|
||||
await UniTask.Yield(PlayerLoopTiming.PostLateUpdate);
|
||||
|
||||
UniTask.DelayFrame(10,PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => t = true).Forget();
|
||||
UniTask.DelayFrame(10,PlayerLoopTiming.PostLateUpdate).ContinueWith(() => t = true).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitUntil(() => t, PlayerLoopTiming.EarlyUpdate);
|
||||
|
@ -167,7 +164,7 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
bool t = true;
|
||||
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => t = false).Forget();
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(() => t = false).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitWhile(() => t, PlayerLoopTiming.EarlyUpdate);
|
||||
|
@ -181,7 +178,7 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var v = new MyMyClass { MyProperty = 99 };
|
||||
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(_ => v.MyProperty = 1000).Forget();
|
||||
UniTask.DelayFrame(10, PlayerLoopTiming.PostLateUpdate).ContinueWith(() => v.MyProperty = 1000).Forget();
|
||||
|
||||
var startFrame = Time.frameCount;
|
||||
await UniTask.WaitUntilValueChanged(v, x => x.MyProperty, PlayerLoopTiming.EarlyUpdate);
|
||||
|
@ -271,10 +268,10 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
UniTask.DelayFrame(10).ContinueWith(_ => cts.Cancel()).Forget();
|
||||
UniTask.DelayFrame(10).ContinueWith(() => cts.Cancel()).Forget();
|
||||
|
||||
var first = Time.frameCount;
|
||||
var (canceled, value) = await UniTask.DelayFrame(100, cancellationToken: cts.Token).SuppressCancellationThrow();
|
||||
var canceled = await UniTask.DelayFrame(100, cancellationToken: cts.Token).SuppressCancellationThrow();
|
||||
|
||||
(Time.frameCount - first).Should().Be(11); // 10 frame canceled
|
||||
canceled.Should().Be(true);
|
||||
|
@ -285,12 +282,12 @@ namespace UniRx.AsyncTests
|
|||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
UniTask.DelayFrame(10).ContinueWith(_ => cts.Cancel()).Forget();
|
||||
UniTask.DelayFrame(10).ContinueWith(() => cts.Cancel()).Forget();
|
||||
|
||||
bool occur = false;
|
||||
try
|
||||
{
|
||||
var value = await UniTask.DelayFrame(100, cancellationToken: cts.Token);
|
||||
await UniTask.DelayFrame(100, cancellationToken: cts.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
|
|
@ -40,7 +40,11 @@ namespace UniRx.Async
|
|||
public static void RegisterRaiseCancelOnDestroy(this CancellationTokenSource cts, GameObject gameObject)
|
||||
{
|
||||
var trigger = gameObject.GetAsyncDestroyTrigger();
|
||||
trigger.AddCancellationTriggerOnDestroy(cts);
|
||||
trigger.CancellationToken.RegisterWithoutCaptureExecutionContext(state =>
|
||||
{
|
||||
var cts2 = (CancellationTokenSource)state;
|
||||
cts2.Cancel();
|
||||
}, cts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace UniRx.Async.Editor
|
|||
|
||||
var children = new List<TreeViewItem>();
|
||||
|
||||
TaskTracker2.ForEachActiveTask((trackingId, awaiterType, status, created, stackTrace) =>
|
||||
TaskTracker.ForEachActiveTask((trackingId, awaiterType, status, created, stackTrace) =>
|
||||
{
|
||||
children.Add(new UniTaskTrackerViewItem(trackingId) { TaskType = awaiterType, Status = status.ToString(), Elapsed = (DateTime.UtcNow - created).TotalSeconds.ToString("00.00"), Position = stackTrace });
|
||||
});
|
||||
|
|
|
@ -12,7 +12,6 @@ using UniRx.Async.Internal;
|
|||
|
||||
namespace UniRx.Async.Editor
|
||||
{
|
||||
// TODO:Remove
|
||||
public class UniTaskTrackerWindow : EditorWindow
|
||||
{
|
||||
static int interval;
|
||||
|
@ -171,202 +170,6 @@ namespace UniRx.Async.Editor
|
|||
static GUIStyle detailsStyle;
|
||||
Vector2 detailsScroll;
|
||||
|
||||
void RenderDetailsPanel()
|
||||
{
|
||||
if (detailsStyle == null)
|
||||
{
|
||||
detailsStyle = new GUIStyle(EditorStyles.wordWrappedLabel);
|
||||
detailsStyle.wordWrap = false;
|
||||
detailsStyle.stretchHeight = true;
|
||||
detailsStyle.margin.right = 15;
|
||||
}
|
||||
|
||||
string message = "";
|
||||
var selected = treeView.state.selectedIDs;
|
||||
if (selected.Count > 0)
|
||||
{
|
||||
var first = selected[0];
|
||||
var item = treeView.CurrentBindingItems.FirstOrDefault(x => x.id == first) as UniTaskTrackerViewItem;
|
||||
if (item != null)
|
||||
{
|
||||
message = item.Position;
|
||||
}
|
||||
}
|
||||
|
||||
detailsScroll = EditorGUILayout.BeginScrollView(this.detailsScroll, EmptyLayoutOption);
|
||||
var vector = detailsStyle.CalcSize(new GUIContent(message));
|
||||
EditorGUILayout.SelectableLabel(message, detailsStyle, new GUILayoutOption[]
|
||||
{
|
||||
GUILayout.ExpandHeight(true),
|
||||
GUILayout.ExpandWidth(true),
|
||||
GUILayout.MinWidth(vector.x),
|
||||
GUILayout.MinHeight(vector.y)
|
||||
});
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class UniTaskTrackerWindow2 : EditorWindow
|
||||
{
|
||||
static int interval;
|
||||
|
||||
static UniTaskTrackerWindow2 window;
|
||||
|
||||
// TODO:Remove 2
|
||||
[MenuItem("Window/UniTask Tracker 2")]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
if (window != null)
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
|
||||
// will called OnEnable(singleton instance will be set).
|
||||
GetWindow<UniTaskTrackerWindow2>("UniTask Tracker").Show();
|
||||
}
|
||||
|
||||
static readonly GUILayoutOption[] EmptyLayoutOption = new GUILayoutOption[0];
|
||||
|
||||
UniTaskTrackerTreeView treeView;
|
||||
object splitterState;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
window = this; // set singleton.
|
||||
splitterState = SplitterGUILayout.CreateSplitterState(new float[] { 75f, 25f }, new int[] { 32, 32 }, null);
|
||||
treeView = new UniTaskTrackerTreeView();
|
||||
TaskTracker2.EditorEnableState.EnableAutoReload = EditorPrefs.GetBool(TaskTracker2.EnableAutoReloadKey, false);
|
||||
TaskTracker2.EditorEnableState.EnableTracking = EditorPrefs.GetBool(TaskTracker2.EnableTrackingKey, false);
|
||||
TaskTracker2.EditorEnableState.EnableStackTrace = EditorPrefs.GetBool(TaskTracker2.EnableStackTraceKey, false);
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
// Head
|
||||
RenderHeadPanel();
|
||||
|
||||
// Splittable
|
||||
SplitterGUILayout.BeginVerticalSplit(this.splitterState, EmptyLayoutOption);
|
||||
{
|
||||
// Column Tabble
|
||||
RenderTable();
|
||||
|
||||
// StackTrace details
|
||||
RenderDetailsPanel();
|
||||
}
|
||||
SplitterGUILayout.EndVerticalSplit();
|
||||
}
|
||||
|
||||
#region HeadPanel
|
||||
|
||||
public static bool EnableAutoReload => TaskTracker2.EditorEnableState.EnableAutoReload;
|
||||
public static bool EnableTracking => TaskTracker2.EditorEnableState.EnableTracking;
|
||||
public static bool EnableStackTrace => TaskTracker2.EditorEnableState.EnableStackTrace;
|
||||
static readonly GUIContent EnableAutoReloadHeadContent = EditorGUIUtility.TrTextContent("Enable AutoReload", "Reload automatically.", (Texture)null);
|
||||
static readonly GUIContent ReloadHeadContent = EditorGUIUtility.TrTextContent("Reload", "Reload View.", (Texture)null);
|
||||
static readonly GUIContent GCHeadContent = EditorGUIUtility.TrTextContent("GC.Collect", "Invoke GC.Collect.", (Texture)null);
|
||||
static readonly GUIContent EnableTrackingHeadContent = EditorGUIUtility.TrTextContent("Enable Tracking", "Start to track async/await UniTask. Performance impact: low", (Texture)null);
|
||||
static readonly GUIContent EnableStackTraceHeadContent = EditorGUIUtility.TrTextContent("Enable StackTrace", "Capture StackTrace when task is started. Performance impact: high", (Texture)null);
|
||||
|
||||
// [Enable Tracking] | [Enable StackTrace]
|
||||
void RenderHeadPanel()
|
||||
{
|
||||
EditorGUILayout.BeginVertical(EmptyLayoutOption);
|
||||
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, EmptyLayoutOption);
|
||||
|
||||
if (GUILayout.Toggle(EnableAutoReload, EnableAutoReloadHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption) != EnableAutoReload)
|
||||
{
|
||||
TaskTracker2.EditorEnableState.EnableAutoReload = !EnableAutoReload;
|
||||
}
|
||||
|
||||
if (GUILayout.Toggle(EnableTracking, EnableTrackingHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption) != EnableTracking)
|
||||
{
|
||||
TaskTracker2.EditorEnableState.EnableTracking = !EnableTracking;
|
||||
}
|
||||
|
||||
if (GUILayout.Toggle(EnableStackTrace, EnableStackTraceHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption) != EnableStackTrace)
|
||||
{
|
||||
TaskTracker2.EditorEnableState.EnableStackTrace = !EnableStackTrace;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button(ReloadHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption))
|
||||
{
|
||||
TaskTracker2.CheckAndResetDirty();
|
||||
treeView.ReloadAndSort();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
if (GUILayout.Button(GCHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption))
|
||||
{
|
||||
GC.Collect(0);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TableColumn
|
||||
|
||||
Vector2 tableScroll;
|
||||
GUIStyle tableListStyle;
|
||||
|
||||
void RenderTable()
|
||||
{
|
||||
if (tableListStyle == null)
|
||||
{
|
||||
tableListStyle = new GUIStyle("CN Box");
|
||||
tableListStyle.margin.top = 0;
|
||||
tableListStyle.padding.left = 3;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginVertical(tableListStyle, EmptyLayoutOption);
|
||||
|
||||
this.tableScroll = EditorGUILayout.BeginScrollView(this.tableScroll, new GUILayoutOption[]
|
||||
{
|
||||
GUILayout.ExpandWidth(true),
|
||||
GUILayout.MaxWidth(2000f)
|
||||
});
|
||||
var controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[]
|
||||
{
|
||||
GUILayout.ExpandHeight(true),
|
||||
GUILayout.ExpandWidth(true)
|
||||
});
|
||||
|
||||
|
||||
treeView?.OnGUI(controlRect);
|
||||
|
||||
EditorGUILayout.EndScrollView();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (EnableAutoReload)
|
||||
{
|
||||
if (interval++ % 120 == 0)
|
||||
{
|
||||
if (TaskTracker2.CheckAndResetDirty())
|
||||
{
|
||||
treeView.ReloadAndSort();
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Details
|
||||
|
||||
static GUIStyle detailsStyle;
|
||||
Vector2 detailsScroll;
|
||||
|
||||
void RenderDetailsPanel()
|
||||
{
|
||||
if (detailsStyle == null)
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace UniRx.Async
|
|||
result.innerEnumerator = ConsumeEnumerator(innerEnumerator);
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -35,28 +35,28 @@ namespace UniRx.Async
|
|||
|
||||
public static class UniTaskStatusExtensions
|
||||
{
|
||||
/// <summary>!= Pending.</summary>
|
||||
/// <summary>status != Pending.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsCompleted(this UniTaskStatus status)
|
||||
{
|
||||
return status != UniTaskStatus.Pending;
|
||||
}
|
||||
|
||||
/// <summary>== Succeeded.</summary>
|
||||
/// <summary>status == Succeeded.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsCompletedSuccessfully(this UniTaskStatus status)
|
||||
{
|
||||
return status == UniTaskStatus.Succeeded;
|
||||
}
|
||||
|
||||
/// <summary>== Canceled.</summary>
|
||||
/// <summary>status == Canceled.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsCanceled(this UniTaskStatus status)
|
||||
{
|
||||
return status == UniTaskStatus.Canceled;
|
||||
}
|
||||
|
||||
/// <summary>== Faulted.</summary>
|
||||
/// <summary>status == Faulted.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsFaulted(this UniTaskStatus status)
|
||||
{
|
||||
|
|
|
@ -33,13 +33,8 @@ namespace UniRx.Async.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public static RentArray<T> Materialize<T>(IEnumerable<T> source)
|
||||
public static RentArray<T> CopyToRentArray<T>(IEnumerable<T> source)
|
||||
{
|
||||
if (source is T[] array)
|
||||
{
|
||||
return new RentArray<T>(array, array.Length, null);
|
||||
}
|
||||
|
||||
var defaultCount = 32;
|
||||
if (source is ICollection<T> coll)
|
||||
{
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Threading;
|
||||
|
||||
namespace UniRx.Async.Internal
|
||||
{
|
||||
internal static class CancellationTokenHelper
|
||||
{
|
||||
public static bool TrySetOrLinkCancellationToken(ref CancellationToken field, CancellationToken newCancellationToken)
|
||||
{
|
||||
if (newCancellationToken == CancellationToken.None)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (field == CancellationToken.None)
|
||||
{
|
||||
field = newCancellationToken;
|
||||
return true;
|
||||
}
|
||||
else if (field == newCancellationToken)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
field = CancellationTokenSource.CreateLinkedTokenSource(field, newCancellationToken).Token;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 53d1b536fc7e2d4458294ee2c7d9b743
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -8,8 +8,7 @@ using System.Runtime.CompilerServices;
|
|||
namespace UniRx.Async.Internal
|
||||
{
|
||||
// optimized version of Standard Queue<T>.
|
||||
// TODO: to internal.
|
||||
public class MinimumQueue<T>
|
||||
internal class MinimumQueue<T>
|
||||
{
|
||||
const int MinimumGrow = 4;
|
||||
const int GrowFactor = 200;
|
||||
|
@ -28,9 +27,7 @@ namespace UniRx.Async.Internal
|
|||
|
||||
public int Count
|
||||
{
|
||||
#if NET_4_6 || NET_STANDARD_2_0
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
get { return size; }
|
||||
}
|
||||
|
||||
|
@ -40,9 +37,7 @@ namespace UniRx.Async.Internal
|
|||
return array[head];
|
||||
}
|
||||
|
||||
#if NET_4_6 || NET_STANDARD_2_0
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public void Enqueue(T item)
|
||||
{
|
||||
if (size == array.Length)
|
||||
|
@ -55,9 +50,7 @@ namespace UniRx.Async.Internal
|
|||
size++;
|
||||
}
|
||||
|
||||
#if NET_4_6 || NET_STANDARD_2_0
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
public T Dequeue()
|
||||
{
|
||||
if (size == 0) ThrowForEmptyQueue();
|
||||
|
@ -102,9 +95,7 @@ namespace UniRx.Async.Internal
|
|||
tail = (size == capacity) ? 0 : size;
|
||||
}
|
||||
|
||||
#if NET_4_6 || NET_STANDARD_2_0
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
void MoveNext(ref int index)
|
||||
{
|
||||
int tmp = index + 1;
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UniRx.Async.Internal
|
||||
{
|
||||
internal static class PromiseHelper
|
||||
{
|
||||
internal static void TrySetResultAll<TPromise, T>(IEnumerable<TPromise> source, T value)
|
||||
where TPromise : class, IResolvePromise<T>
|
||||
{
|
||||
var rentArray = ArrayPoolUtil.Materialize(source);
|
||||
var clearArray = true;
|
||||
try
|
||||
{
|
||||
var array = rentArray.Array;
|
||||
var len = rentArray.Length;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
array[i].TrySetResult(value);
|
||||
array[i] = null;
|
||||
}
|
||||
clearArray = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
rentArray.DisposeManually(clearArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 173f9b763911bf847b7dfbf31ee87fc4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -5,12 +5,12 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using UniRx.Async.Internal;
|
||||
|
||||
namespace UniRx.Async.Internal
|
||||
namespace UniRx.Async
|
||||
{
|
||||
// public for add user custom.
|
||||
|
||||
// TODO: Remove
|
||||
public static class TaskTracker
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
@ -60,144 +60,6 @@ namespace UniRx.Async.Internal
|
|||
#endif
|
||||
|
||||
|
||||
static List<KeyValuePair<IAwaiter, (int trackingId, DateTime addTime, string stackTrace)>> listPool = new List<KeyValuePair<IAwaiter, (int trackingId, DateTime addTime, string stackTrace)>>();
|
||||
|
||||
static readonly WeakDictionary<IAwaiter, (int trackingId, DateTime addTime, string stackTrace)> tracking = new WeakDictionary<IAwaiter, (int trackingId, DateTime addTime, string stackTrace)>();
|
||||
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public static void TrackActiveTask(IAwaiter task, int skipFrame = 1)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
dirty = true;
|
||||
if (!EditorEnableState.EnableTracking) return;
|
||||
var stackTrace = EditorEnableState.EnableStackTrace ? new StackTrace(skipFrame, true).CleanupAsyncStackTrace() : "";
|
||||
tracking.TryAdd(task, (Interlocked.Increment(ref trackingId), DateTime.UtcNow, stackTrace));
|
||||
#endif
|
||||
}
|
||||
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public static void TrackActiveTask(IAwaiter task, string stackTrace)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
dirty = true;
|
||||
if (!EditorEnableState.EnableTracking) return;
|
||||
var success = tracking.TryAdd(task, (Interlocked.Increment(ref trackingId), DateTime.UtcNow, stackTrace));
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string CaptureStackTrace(int skipFrame)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!EditorEnableState.EnableTracking) return "";
|
||||
var stackTrace = EditorEnableState.EnableStackTrace ? new StackTrace(skipFrame + 1, true).CleanupAsyncStackTrace() : "";
|
||||
return stackTrace;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public static void RemoveTracking(IAwaiter task)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
dirty = true;
|
||||
if (!EditorEnableState.EnableTracking) return;
|
||||
var success = tracking.TryRemove(task);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool dirty;
|
||||
|
||||
public static bool CheckAndResetDirty()
|
||||
{
|
||||
var current = dirty;
|
||||
dirty = false;
|
||||
return current;
|
||||
}
|
||||
|
||||
/// <summary>(trackingId, awaiterType, awaiterStatus, createdTime, stackTrace)</summary>
|
||||
public static void ForEachActiveTask(Action<int, string, UniTaskStatus, DateTime, string> action)
|
||||
{
|
||||
lock (listPool)
|
||||
{
|
||||
var count = tracking.ToList(ref listPool, clear: false);
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
string typeName = null;
|
||||
var keyType = listPool[i].Key.GetType();
|
||||
if (keyType.IsNested)
|
||||
{
|
||||
typeName = keyType.DeclaringType.Name + "." + keyType.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
typeName = keyType.Name;
|
||||
}
|
||||
|
||||
action(listPool[i].Value.trackingId, typeName, listPool[i].Key.Status, listPool[i].Value.addTime, listPool[i].Value.stackTrace);
|
||||
listPool[i] = new KeyValuePair<IAwaiter, (int trackingId, DateTime addTime, string stackTrace)>(null, (0, default(DateTime), null)); // clear
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
listPool.Clear();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class TaskTracker2
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
static int trackingId = 0;
|
||||
|
||||
public const string EnableAutoReloadKey = "UniTaskTrackerWindow_EnableAutoReloadKey";
|
||||
public const string EnableTrackingKey = "UniTaskTrackerWindow_EnableTrackingKey";
|
||||
public const string EnableStackTraceKey = "UniTaskTrackerWindow_EnableStackTraceKey";
|
||||
|
||||
public static class EditorEnableState
|
||||
{
|
||||
static bool enableAutoReload;
|
||||
public static bool EnableAutoReload
|
||||
{
|
||||
get { return enableAutoReload; }
|
||||
set
|
||||
{
|
||||
enableAutoReload = value;
|
||||
UnityEditor.EditorPrefs.SetBool(EnableAutoReloadKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
static bool enableTracking;
|
||||
public static bool EnableTracking
|
||||
{
|
||||
get { return enableTracking; }
|
||||
set
|
||||
{
|
||||
enableTracking = value;
|
||||
UnityEditor.EditorPrefs.SetBool(EnableTrackingKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
static bool enableStackTrace;
|
||||
public static bool EnableStackTrace
|
||||
{
|
||||
get { return enableStackTrace; }
|
||||
set
|
||||
{
|
||||
enableStackTrace = value;
|
||||
UnityEditor.EditorPrefs.SetBool(EnableStackTraceKey, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static List<KeyValuePair<IUniTaskSource, (int trackingId, DateTime addTime, string stackTrace)>> listPool = new List<KeyValuePair<IUniTaskSource, (int trackingId, DateTime addTime, string stackTrace)>>();
|
||||
|
||||
static readonly WeakDictionary<IUniTaskSource, (int trackingId, DateTime addTime, string stackTrace)> tracking = new WeakDictionary<IUniTaskSource, (int trackingId, DateTime addTime, string stackTrace)>();
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncAnimatorTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<int> onAnimatorIK;
|
||||
AsyncTriggerPromiseDictionary<int> onAnimatorIKs;
|
||||
AsyncTriggerPromise<AsyncUnit> onAnimatorMove;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onAnimatorMoves;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onAnimatorIK, onAnimatorIKs, onAnimatorMove, onAnimatorMoves);
|
||||
}
|
||||
|
||||
|
||||
void OnAnimatorIK(int layerIndex)
|
||||
{
|
||||
TrySetResult(onAnimatorIK, onAnimatorIKs, layerIndex);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<int> OnAnimatorIKAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onAnimatorIK, ref onAnimatorIKs, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnAnimatorMove()
|
||||
{
|
||||
TrySetResult(onAnimatorMove, onAnimatorMoves, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnAnimatorMoveAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onAnimatorMove, ref onAnimatorMoves, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae912c37ac7f4cd42b25f22452435103
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,32 +1,54 @@
|
|||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
public static partial class AsyncTriggerExtensions
|
||||
{
|
||||
public static AsyncAwakeTrigger GetAsyncAwakeTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncAwakeTrigger>(gameObject);
|
||||
}
|
||||
|
||||
public static AsyncAwakeTrigger GetAsyncAwakeTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncAwakeTrigger();
|
||||
}
|
||||
}
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncAwakeTrigger : MonoBehaviour
|
||||
{
|
||||
bool called = false;
|
||||
UniTaskCompletionSource promise;
|
||||
TriggerEvent<AsyncUnit> triggerEvent;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
called = true;
|
||||
promise?.TrySetResult();
|
||||
triggerEvent?.TrySetResult(AsyncUnit.Default);
|
||||
triggerEvent = null;
|
||||
}
|
||||
|
||||
public UniTask AwakeAsync()
|
||||
{
|
||||
if (called) return UniTask.CompletedTask;
|
||||
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
return new UniTask(promise ?? (promise = new UniTaskCompletionSource()));
|
||||
|
||||
if (triggerEvent == null)
|
||||
{
|
||||
triggerEvent = new TriggerEvent<AsyncUnit>();
|
||||
}
|
||||
|
||||
return ((IAsyncOneShotTrigger)new AsyncTriggerHandler<AsyncUnit>(triggerEvent, true)).OneShotAsync();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
promise?.TrySetCanceled();
|
||||
triggerEvent?.TrySetCanceled(CancellationToken.None);
|
||||
}
|
||||
|
||||
class AwakeMonitor : IPlayerLoopItem
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncBeginDragTrigger : AsyncTriggerBase, IBeginDragHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onBeginDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onBeginDrags;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onBeginDrag, onBeginDrags);
|
||||
}
|
||||
|
||||
|
||||
void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onBeginDrag, onBeginDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onBeginDrag, ref onBeginDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 171fd2191eb22af4fbd92b51815ca757
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncCancelTrigger : AsyncTriggerBase, ICancelHandler
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onCancel;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onCancels;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onCancel, onCancels);
|
||||
}
|
||||
|
||||
|
||||
void ICancelHandler.OnCancel(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onCancel, onCancels, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCancel, ref onCancels, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 291886b6e5f2d044a85b2a4dedcaca97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncCanvasGroupChangedTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> onCanvasGroupChanged;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onCanvasGroupChangeds;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onCanvasGroupChanged, onCanvasGroupChangeds);
|
||||
}
|
||||
|
||||
|
||||
void OnCanvasGroupChanged()
|
||||
{
|
||||
TrySetResult(onCanvasGroupChanged, onCanvasGroupChangeds, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnCanvasGroupChangedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCanvasGroupChanged, ref onCanvasGroupChangeds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eddba832648f83046a320ffcacfc771d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncCollision2DTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<Collision2D> onCollisionEnter2D;
|
||||
AsyncTriggerPromiseDictionary<Collision2D> onCollisionEnter2Ds;
|
||||
AsyncTriggerPromise<Collision2D> onCollisionExit2D;
|
||||
AsyncTriggerPromiseDictionary<Collision2D> onCollisionExit2Ds;
|
||||
AsyncTriggerPromise<Collision2D> onCollisionStay2D;
|
||||
AsyncTriggerPromiseDictionary<Collision2D> onCollisionStay2Ds;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onCollisionEnter2D, onCollisionEnter2Ds, onCollisionExit2D, onCollisionExit2Ds, onCollisionStay2D, onCollisionStay2Ds);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionEnter2D(Collision2D coll)
|
||||
{
|
||||
TrySetResult(onCollisionEnter2D, onCollisionEnter2Ds, coll);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collision2D> OnCollisionEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionEnter2D, ref onCollisionEnter2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionExit2D(Collision2D coll)
|
||||
{
|
||||
TrySetResult(onCollisionExit2D, onCollisionExit2Ds, coll);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collision2D> OnCollisionExit2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionExit2D, ref onCollisionExit2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionStay2D(Collision2D coll)
|
||||
{
|
||||
TrySetResult(onCollisionStay2D, onCollisionStay2Ds, coll);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collision2D> OnCollisionStay2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionStay2D, ref onCollisionStay2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fbeb63f69bedec44f8003730887f914b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncCollisionTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<Collision> onCollisionEnter;
|
||||
AsyncTriggerPromiseDictionary<Collision> onCollisionEnters;
|
||||
AsyncTriggerPromise<Collision> onCollisionExit;
|
||||
AsyncTriggerPromiseDictionary<Collision> onCollisionExits;
|
||||
AsyncTriggerPromise<Collision> onCollisionStay;
|
||||
AsyncTriggerPromiseDictionary<Collision> onCollisionStays;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onCollisionEnter, onCollisionEnters, onCollisionExit, onCollisionExits, onCollisionStay, onCollisionStays);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
TrySetResult(onCollisionEnter, onCollisionEnters, collision);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collision> OnCollisionEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionEnter, ref onCollisionEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionExit(Collision collisionInfo)
|
||||
{
|
||||
TrySetResult(onCollisionExit, onCollisionExits, collisionInfo);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collision> OnCollisionExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionExit, ref onCollisionExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionStay(Collision collisionInfo)
|
||||
{
|
||||
TrySetResult(onCollisionStay, onCollisionStays, collisionInfo);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collision> OnCollisionStayAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionStay, ref onCollisionStays, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 72db4a683be8f6a428823502599014a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncDeselectTrigger : AsyncTriggerBase, IDeselectHandler
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onDeselect;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onDeselects;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onDeselect, onDeselects);
|
||||
}
|
||||
|
||||
|
||||
void IDeselectHandler.OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onDeselect, onDeselects, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDeselect, ref onDeselects, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 30faa9be5bd883e488bdc52f4825c4da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -2,18 +2,30 @@
|
|||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Threading;
|
||||
using UniRx.Async.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
public static partial class AsyncTriggerExtensions
|
||||
{
|
||||
public static AsyncDestroyTrigger GetAsyncDestroyTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncDestroyTrigger>(gameObject);
|
||||
}
|
||||
|
||||
public static AsyncDestroyTrigger GetAsyncDestroyTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncDestroyTrigger();
|
||||
}
|
||||
}
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncDestroyTrigger : MonoBehaviour
|
||||
{
|
||||
bool awakeCalled = false;
|
||||
bool called = false;
|
||||
UniTaskCompletionSource promise;
|
||||
CancellationTokenSource cancellationTokenSource; // main cancellation
|
||||
object canellationTokenSourceOrQueue; // external from AddCancellationTriggerOnDestroy
|
||||
TriggerEvent<AsyncUnit> triggerEvent;
|
||||
CancellationTokenSource cancellationTokenSource;
|
||||
|
||||
public CancellationToken CancellationToken
|
||||
{
|
||||
|
@ -27,64 +39,57 @@ namespace UniRx.Async.Triggers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
void Awake()
|
||||
{
|
||||
awakeCalled = true;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
called = true;
|
||||
promise?.TrySetResult();
|
||||
|
||||
triggerEvent?.TrySetResult(AsyncUnit.Default);
|
||||
cancellationTokenSource?.Cancel();
|
||||
cancellationTokenSource?.Dispose();
|
||||
if (canellationTokenSourceOrQueue != null)
|
||||
{
|
||||
if (canellationTokenSourceOrQueue is CancellationTokenSource cts)
|
||||
{
|
||||
cts.Cancel();
|
||||
cts.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
var q = (MinimumQueue<CancellationTokenSource>)canellationTokenSourceOrQueue;
|
||||
while (q.Count != 0)
|
||||
{
|
||||
var c = q.Dequeue();
|
||||
c.Cancel();
|
||||
c.Dispose();
|
||||
}
|
||||
}
|
||||
canellationTokenSourceOrQueue = null;
|
||||
}
|
||||
|
||||
triggerEvent = null;
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
public UniTask OnDestroyAsync()
|
||||
{
|
||||
if (called) return UniTask.CompletedTask;
|
||||
return new UniTask(promise ?? (promise = new UniTaskCompletionSource()));
|
||||
|
||||
if (!awakeCalled)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
}
|
||||
|
||||
/// <summary>Add Cancellation Triggers on destroy</summary>
|
||||
public void AddCancellationTriggerOnDestroy(CancellationTokenSource cts)
|
||||
if (triggerEvent == null)
|
||||
{
|
||||
if (called)
|
||||
{
|
||||
cts.Cancel();
|
||||
cts.Dispose();
|
||||
triggerEvent = new TriggerEvent<AsyncUnit>();
|
||||
}
|
||||
|
||||
if (canellationTokenSourceOrQueue == null)
|
||||
{
|
||||
canellationTokenSourceOrQueue = cts;
|
||||
return ((IAsyncOneShotTrigger)new AsyncTriggerHandler<AsyncUnit>(triggerEvent, true)).OneShotAsync();
|
||||
}
|
||||
else if (canellationTokenSourceOrQueue is CancellationTokenSource c)
|
||||
|
||||
class AwakeMonitor : IPlayerLoopItem
|
||||
{
|
||||
var q = new MinimumQueue<CancellationTokenSource>(4);
|
||||
q.Enqueue(c);
|
||||
q.Enqueue(cts);
|
||||
canellationTokenSourceOrQueue = q;
|
||||
readonly AsyncDestroyTrigger trigger;
|
||||
|
||||
public AwakeMonitor(AsyncDestroyTrigger trigger)
|
||||
{
|
||||
this.trigger = trigger;
|
||||
}
|
||||
else
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
((MinimumQueue<CancellationTokenSource>)canellationTokenSourceOrQueue).Enqueue(cts);
|
||||
if (trigger.called) return false;
|
||||
if (trigger == null)
|
||||
{
|
||||
trigger.OnDestroy();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncDragTrigger : AsyncTriggerBase, IDragHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onDrags;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onDrag, onDrags);
|
||||
}
|
||||
|
||||
|
||||
void IDragHandler.OnDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onDrag, onDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDrag, ref onDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 52242547ba60ea74f8a2e3bbab5fcdfa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncDropTrigger : AsyncTriggerBase, IDropHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onDrop;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onDrops;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onDrop, onDrops);
|
||||
}
|
||||
|
||||
|
||||
void IDropHandler.OnDrop(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onDrop, onDrops, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnDropAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDrop, ref onDrops, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 42d65fd5e4be25f41a927eca25b0acf7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,55 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncEnableDisableTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> onEnable;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onEnables;
|
||||
AsyncTriggerPromise<AsyncUnit> onDisable;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onDisables;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onEnable, onEnables, onDisable, onDisables);
|
||||
}
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
TrySetResult(onEnable, onEnables, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnEnableAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onEnable, ref onEnables, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
TrySetResult(onDisable, onDisables, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnDisableAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDisable, ref onDisables, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d0bf9142b63b4cb43b693f0b83b3dbe7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncEndDragTrigger : AsyncTriggerBase, IEndDragHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onEndDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onEndDrags;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onEndDrag, onEndDrags);
|
||||
}
|
||||
|
||||
|
||||
void IEndDragHandler.OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onEndDrag, onEndDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onEndDrag, ref onEndDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8298d43de348acc4aa4e7dbf30472dbf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,264 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncEventTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onDeselect;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onDeselects;
|
||||
AsyncTriggerPromise<AxisEventData> onMove;
|
||||
AsyncTriggerPromiseDictionary<AxisEventData> onMoves;
|
||||
AsyncTriggerPromise<PointerEventData> onPointerDown;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerDowns;
|
||||
AsyncTriggerPromise<PointerEventData> onPointerEnter;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerEnters;
|
||||
AsyncTriggerPromise<PointerEventData> onPointerExit;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerExits;
|
||||
AsyncTriggerPromise<PointerEventData> onPointerUp;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerUps;
|
||||
AsyncTriggerPromise<BaseEventData> onSelect;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onSelects;
|
||||
AsyncTriggerPromise<PointerEventData> onPointerClick;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerClicks;
|
||||
AsyncTriggerPromise<BaseEventData> onSubmit;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onSubmits;
|
||||
AsyncTriggerPromise<PointerEventData> onDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onDrags;
|
||||
AsyncTriggerPromise<PointerEventData> onBeginDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onBeginDrags;
|
||||
AsyncTriggerPromise<PointerEventData> onEndDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onEndDrags;
|
||||
AsyncTriggerPromise<PointerEventData> onDrop;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onDrops;
|
||||
AsyncTriggerPromise<BaseEventData> onUpdateSelected;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onUpdateSelecteds;
|
||||
AsyncTriggerPromise<PointerEventData> onInitializePotentialDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onInitializePotentialDrags;
|
||||
AsyncTriggerPromise<BaseEventData> onCancel;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onCancels;
|
||||
AsyncTriggerPromise<PointerEventData> onScroll;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onScrolls;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onDeselect, onDeselects, onMove, onMoves, onPointerDown, onPointerDowns, onPointerEnter, onPointerEnters, onPointerExit, onPointerExits, onPointerUp, onPointerUps, onSelect, onSelects, onPointerClick, onPointerClicks, onSubmit, onSubmits, onDrag, onDrags, onBeginDrag, onBeginDrags, onEndDrag, onEndDrags, onDrop, onDrops, onUpdateSelected, onUpdateSelecteds, onInitializePotentialDrag, onInitializePotentialDrags, onCancel, onCancels, onScroll, onScrolls);
|
||||
}
|
||||
|
||||
void OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onDeselect, onDeselects, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDeselect, ref onDeselects, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnMove(AxisEventData eventData)
|
||||
{
|
||||
TrySetResult(onMove, onMoves, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<AxisEventData> OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMove, ref onMoves, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerDown, onPointerDowns, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerDown, ref onPointerDowns, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerEnter, onPointerEnters, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerEnter, ref onPointerEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerExit, onPointerExits, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerExit, ref onPointerExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerUp, onPointerUps, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerUp, ref onPointerUps, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onSelect, onSelects, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onSelect, ref onSelects, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerClick, onPointerClicks, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerClick, ref onPointerClicks, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onSubmit, onSubmits, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onSubmit, ref onSubmits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onDrag, onDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDrag, ref onDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onBeginDrag, onBeginDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onBeginDrag, ref onBeginDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onEndDrag, onEndDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onEndDrag, ref onEndDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnDrop(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onDrop, onDrops, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnDropAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDrop, ref onDrops, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnUpdateSelected(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onUpdateSelected, onUpdateSelecteds, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onUpdateSelected, ref onUpdateSelecteds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnInitializePotentialDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onInitializePotentialDrag, onInitializePotentialDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onInitializePotentialDrag, ref onInitializePotentialDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCancel(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onCancel, onCancels, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCancel, ref onCancels, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onScroll, onScrolls, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onScroll, ref onScrolls, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 89997820797ad6d43b17971a8bd0d8fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncFixedUpdateTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> fixedUpdate;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> fixedUpdates;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(fixedUpdate, fixedUpdates);
|
||||
}
|
||||
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
TrySetResult(fixedUpdate, fixedUpdates, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask FixedUpdateAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref fixedUpdate, ref fixedUpdates, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c74b906c4294aaa4e900f6e7f8b36df6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncInitializePotentialDragTrigger : AsyncTriggerBase, IInitializePotentialDragHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onInitializePotentialDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onInitializePotentialDrags;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onInitializePotentialDrag, onInitializePotentialDrags);
|
||||
}
|
||||
|
||||
|
||||
void IInitializePotentialDragHandler.OnInitializePotentialDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onInitializePotentialDrag, onInitializePotentialDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onInitializePotentialDrag, ref onInitializePotentialDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae0733adc239a324f8b934ffb119abd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,55 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncJointTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<float> onJointBreak;
|
||||
AsyncTriggerPromiseDictionary<float> onJointBreaks;
|
||||
AsyncTriggerPromise<Joint2D> onJointBreak2D;
|
||||
AsyncTriggerPromiseDictionary<Joint2D> onJointBreak2Ds;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onJointBreak, onJointBreaks, onJointBreak2D, onJointBreak2Ds);
|
||||
}
|
||||
|
||||
|
||||
void OnJointBreak(float breakForce)
|
||||
{
|
||||
TrySetResult(onJointBreak, onJointBreaks, breakForce);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<float> OnJointBreakAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onJointBreak, ref onJointBreaks, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnJointBreak2D(Joint2D brokenJoint)
|
||||
{
|
||||
TrySetResult(onJointBreak2D, onJointBreak2Ds, brokenJoint);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Joint2D> OnJointBreak2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onJointBreak2D, ref onJointBreak2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 04dc74e7b2368094f9153921804a1fb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncLateUpdateTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> lateUpdate;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> lateUpdates;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(lateUpdate, lateUpdates);
|
||||
}
|
||||
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
TrySetResult(lateUpdate, lateUpdates, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask LateUpdateAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref lateUpdate, ref lateUpdates, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a4fb2b4c09cb4ec4a82b934f2038eb36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,129 +0,0 @@
|
|||
|
||||
#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO)
|
||||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncMouseTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> onMouseDown;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onMouseDowns;
|
||||
AsyncTriggerPromise<AsyncUnit> onMouseDrag;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onMouseDrags;
|
||||
AsyncTriggerPromise<AsyncUnit> onMouseEnter;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onMouseEnters;
|
||||
AsyncTriggerPromise<AsyncUnit> onMouseExit;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onMouseExits;
|
||||
AsyncTriggerPromise<AsyncUnit> onMouseOver;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onMouseOvers;
|
||||
AsyncTriggerPromise<AsyncUnit> onMouseUp;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onMouseUps;
|
||||
AsyncTriggerPromise<AsyncUnit> onMouseUpAsButton;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onMouseUpAsButtons;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onMouseDown, onMouseDowns, onMouseDrag, onMouseDrags, onMouseEnter, onMouseEnters, onMouseExit, onMouseExits, onMouseOver, onMouseOvers, onMouseUp, onMouseUps, onMouseUpAsButton, onMouseUpAsButtons);
|
||||
}
|
||||
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
TrySetResult(onMouseDown, onMouseDowns, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMouseDownAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMouseDown, ref onMouseDowns, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnMouseDrag()
|
||||
{
|
||||
TrySetResult(onMouseDrag, onMouseDrags, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMouseDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMouseDrag, ref onMouseDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnMouseEnter()
|
||||
{
|
||||
TrySetResult(onMouseEnter, onMouseEnters, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMouseEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMouseEnter, ref onMouseEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnMouseExit()
|
||||
{
|
||||
TrySetResult(onMouseExit, onMouseExits, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMouseExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMouseExit, ref onMouseExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnMouseOver()
|
||||
{
|
||||
TrySetResult(onMouseOver, onMouseOvers, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMouseOverAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMouseOver, ref onMouseOvers, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnMouseUp()
|
||||
{
|
||||
TrySetResult(onMouseUp, onMouseUps, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMouseUpAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMouseUp, ref onMouseUps, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnMouseUpAsButton()
|
||||
{
|
||||
TrySetResult(onMouseUpAsButton, onMouseUpAsButtons, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMouseUpAsButtonAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMouseUpAsButton, ref onMouseUpAsButtons, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57ad5120e9c4d424484c963791467272
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncMoveTrigger : AsyncTriggerBase, IMoveHandler
|
||||
{
|
||||
AsyncTriggerPromise<AxisEventData> onMove;
|
||||
AsyncTriggerPromiseDictionary<AxisEventData> onMoves;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onMove, onMoves);
|
||||
}
|
||||
|
||||
|
||||
void IMoveHandler.OnMove(AxisEventData eventData)
|
||||
{
|
||||
TrySetResult(onMove, onMoves, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<AxisEventData> OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMove, ref onMoves, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1699926e875c24d4aa34bc8817f96f0e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncParticleTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<GameObject> onParticleCollision;
|
||||
AsyncTriggerPromiseDictionary<GameObject> onParticleCollisions;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onParticleCollision, onParticleCollisions);
|
||||
}
|
||||
|
||||
|
||||
void OnParticleCollision(GameObject other)
|
||||
{
|
||||
TrySetResult(onParticleCollision, onParticleCollisions, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<GameObject> OnParticleCollisionAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onParticleCollision, ref onParticleCollisions, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27d3f2efd47fb1d4fb2e9130f97ea8aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncPointerClickTrigger : AsyncTriggerBase, IPointerClickHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerClick;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerClicks;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerClick, onPointerClicks);
|
||||
}
|
||||
|
||||
|
||||
void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerClick, onPointerClicks, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerClick, ref onPointerClicks, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f8865abf2db3d248b3730cdb18bb8b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncPointerDownTrigger : AsyncTriggerBase, IPointerDownHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerDown;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerDowns;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerDown, onPointerDowns);
|
||||
}
|
||||
|
||||
|
||||
void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerDown, onPointerDowns, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerDown, ref onPointerDowns, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c5132395605eaa498a7efedee5acdd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncPointerEnterTrigger : AsyncTriggerBase, IPointerEnterHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerEnter;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerEnters;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerEnter, onPointerEnters);
|
||||
}
|
||||
|
||||
|
||||
void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerEnter, onPointerEnters, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerEnter, ref onPointerEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 18887d476d48533498efd14224a2f651
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncPointerExitTrigger : AsyncTriggerBase, IPointerExitHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerExit;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerExits;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerExit, onPointerExits);
|
||||
}
|
||||
|
||||
|
||||
void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerExit, onPointerExits, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerExit, ref onPointerExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9e3ed09876a11a84794795809ebee243
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncPointerUpTrigger : AsyncTriggerBase, IPointerUpHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerUp;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerUps;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerUp, onPointerUps);
|
||||
}
|
||||
|
||||
|
||||
void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerUp, onPointerUps, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerUp, ref onPointerUps, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7a0493ea32f81314cbbaf2b635ba3167
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,55 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncRectTransformTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> onRectTransformDimensionsChange;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onRectTransformDimensionsChanges;
|
||||
AsyncTriggerPromise<AsyncUnit> onRectTransformRemoved;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onRectTransformRemoveds;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onRectTransformDimensionsChange, onRectTransformDimensionsChanges, onRectTransformRemoved, onRectTransformRemoveds);
|
||||
}
|
||||
|
||||
|
||||
void OnRectTransformDimensionsChange()
|
||||
{
|
||||
TrySetResult(onRectTransformDimensionsChange, onRectTransformDimensionsChanges, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnRectTransformDimensionsChangeAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onRectTransformDimensionsChange, ref onRectTransformDimensionsChanges, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnRectTransformRemoved()
|
||||
{
|
||||
TrySetResult(onRectTransformRemoved, onRectTransformRemoveds, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnRectTransformRemovedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onRectTransformRemoved, ref onRectTransformRemoveds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dfe3470221c66c84397c0783c62b24e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncScrollTrigger : AsyncTriggerBase, IScrollHandler
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onScroll;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onScrolls;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onScroll, onScrolls);
|
||||
}
|
||||
|
||||
|
||||
void IScrollHandler.OnScroll(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onScroll, onScrolls, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<PointerEventData> OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onScroll, ref onScrolls, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c751e9d3deb97d4d8691a8a583c2afd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncSelectTrigger : AsyncTriggerBase, ISelectHandler
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onSelect;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onSelects;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onSelect, onSelects);
|
||||
}
|
||||
|
||||
|
||||
void ISelectHandler.OnSelect(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onSelect, onSelects, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onSelect, ref onSelects, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fcc2347251a4fc5498a03f0c17382920
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,16 +1,30 @@
|
|||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
public static partial class AsyncTriggerExtensions
|
||||
{
|
||||
public static AsyncStartTrigger GetAsyncStartTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncStartTrigger>(gameObject);
|
||||
}
|
||||
|
||||
public static AsyncStartTrigger GetAsyncStartTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncStartTrigger();
|
||||
}
|
||||
}
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncStartTrigger : MonoBehaviour
|
||||
{
|
||||
bool awakeCalled = false;
|
||||
bool called = false;
|
||||
UniTaskCompletionSource promise;
|
||||
TriggerEvent<AsyncUnit> triggerEvent;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
|
@ -20,22 +34,30 @@ namespace UniRx.Async.Triggers
|
|||
void Start()
|
||||
{
|
||||
called = true;
|
||||
promise?.TrySetResult();
|
||||
triggerEvent?.TrySetResult(AsyncUnit.Default);
|
||||
triggerEvent = null;
|
||||
}
|
||||
|
||||
public UniTask StartAsync()
|
||||
{
|
||||
if (called) return UniTask.CompletedTask;
|
||||
|
||||
if (!awakeCalled)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
}
|
||||
return new UniTask(promise ?? (promise = new UniTaskCompletionSource()));
|
||||
|
||||
if (triggerEvent == null)
|
||||
{
|
||||
triggerEvent = new TriggerEvent<AsyncUnit>();
|
||||
}
|
||||
|
||||
return ((IAsyncOneShotTrigger)new AsyncTriggerHandler<AsyncUnit>(triggerEvent, true)).OneShotAsync();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
promise?.TrySetCanceled();
|
||||
triggerEvent?.TrySetCanceled(CancellationToken.None);
|
||||
}
|
||||
|
||||
class AwakeMonitor : IPlayerLoopItem
|
||||
|
@ -49,7 +71,7 @@ namespace UniRx.Async.Triggers
|
|||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (trigger.awakeCalled) return false;
|
||||
if (trigger.called) return false;
|
||||
if (trigger == null)
|
||||
{
|
||||
trigger.OnDestroy();
|
||||
|
@ -59,6 +81,7 @@ namespace UniRx.Async.Triggers
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncSubmitTrigger : AsyncTriggerBase, ISubmitHandler
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onSubmit;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onSubmits;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onSubmit, onSubmits);
|
||||
}
|
||||
|
||||
|
||||
void ISubmitHandler.OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onSubmit, onSubmits, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onSubmit, ref onSubmits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 97e85abc2d7ec0c44adfbe5ee971aad3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncTransformChangedTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> onBeforeTransformParentChanged;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onBeforeTransformParentChangeds;
|
||||
AsyncTriggerPromise<AsyncUnit> onTransformParentChanged;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onTransformParentChangeds;
|
||||
AsyncTriggerPromise<AsyncUnit> onTransformChildrenChanged;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onTransformChildrenChangeds;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onBeforeTransformParentChanged, onBeforeTransformParentChangeds, onTransformParentChanged, onTransformParentChangeds, onTransformChildrenChanged, onTransformChildrenChangeds);
|
||||
}
|
||||
|
||||
|
||||
void OnBeforeTransformParentChanged()
|
||||
{
|
||||
TrySetResult(onBeforeTransformParentChanged, onBeforeTransformParentChangeds, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnBeforeTransformParentChangedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onBeforeTransformParentChanged, ref onBeforeTransformParentChangeds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTransformParentChanged()
|
||||
{
|
||||
TrySetResult(onTransformParentChanged, onTransformParentChangeds, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnTransformParentChangedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTransformParentChanged, ref onTransformParentChangeds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTransformChildrenChanged()
|
||||
{
|
||||
TrySetResult(onTransformChildrenChanged, onTransformChildrenChangeds, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnTransformChildrenChangedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTransformChildrenChanged, ref onTransformChildrenChangeds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 053f983cd760f5e4394be8fd657243c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncTrigger2DTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<Collider2D> onTriggerEnter2D;
|
||||
AsyncTriggerPromiseDictionary<Collider2D> onTriggerEnter2Ds;
|
||||
AsyncTriggerPromise<Collider2D> onTriggerExit2D;
|
||||
AsyncTriggerPromiseDictionary<Collider2D> onTriggerExit2Ds;
|
||||
AsyncTriggerPromise<Collider2D> onTriggerStay2D;
|
||||
AsyncTriggerPromiseDictionary<Collider2D> onTriggerStay2Ds;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onTriggerEnter2D, onTriggerEnter2Ds, onTriggerExit2D, onTriggerExit2Ds, onTriggerStay2D, onTriggerStay2Ds);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
TrySetResult(onTriggerEnter2D, onTriggerEnter2Ds, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collider2D> OnTriggerEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerEnter2D, ref onTriggerEnter2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
TrySetResult(onTriggerExit2D, onTriggerExit2Ds, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collider2D> OnTriggerExit2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerExit2D, ref onTriggerExit2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerStay2D(Collider2D other)
|
||||
{
|
||||
TrySetResult(onTriggerStay2D, onTriggerStay2Ds, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collider2D> OnTriggerStay2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerStay2D, ref onTriggerStay2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 102f8eba36bc2a54e878e67aca9686e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -9,202 +9,47 @@ using UnityEngine;
|
|||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
public interface ICancelablePromise
|
||||
{
|
||||
CancellationToken RegisteredCancellationToken { get; }
|
||||
bool TrySetCanceled();
|
||||
}
|
||||
|
||||
|
||||
public interface ICancellationTokenKeyDictionary
|
||||
{
|
||||
void Remove(CancellationToken token);
|
||||
}
|
||||
|
||||
public class AsyncTriggerPromiseDictionary<TPromiseType> :
|
||||
Dictionary<CancellationToken, AutoResetUniTaskCompletionSource<TPromiseType>>,
|
||||
ICancellationTokenKeyDictionary,
|
||||
IEnumerable<ICancelablePromise>
|
||||
{
|
||||
public AsyncTriggerPromiseDictionary()
|
||||
: base(CancellationTokenEqualityComparer.Default)
|
||||
{
|
||||
}
|
||||
|
||||
IEnumerator<ICancelablePromise> IEnumerable<ICancelablePromise>.GetEnumerator()
|
||||
{
|
||||
// TODO:
|
||||
throw new NotImplementedException();
|
||||
//return Values.GetEnumerator();
|
||||
}
|
||||
|
||||
void ICancellationTokenKeyDictionary.Remove(CancellationToken token)
|
||||
{
|
||||
this.Remove(token);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class AsyncTriggerBase : MonoBehaviour
|
||||
{
|
||||
static readonly Action<object> Callback = CancelCallback;
|
||||
|
||||
bool calledAwake = false;
|
||||
bool destroyCalled = false;
|
||||
CancellationTokenRegistration[] registeredCancellations;
|
||||
int registeredCancellationsCount;
|
||||
|
||||
protected abstract IEnumerable<ICancelablePromise> GetPromises();
|
||||
|
||||
static protected IEnumerable<ICancelablePromise> Concat(ICancelablePromise p1, IEnumerable<ICancelablePromise> p1s)
|
||||
{
|
||||
if (p1 != null) yield return p1;
|
||||
if (p1s != null) foreach (var item in p1s) yield return item;
|
||||
}
|
||||
|
||||
static protected IEnumerable<ICancelablePromise> Concat(
|
||||
ICancelablePromise p1, IEnumerable<ICancelablePromise> p1s,
|
||||
ICancelablePromise p2, IEnumerable<ICancelablePromise> p2s)
|
||||
{
|
||||
if (p1 != null) yield return p1;
|
||||
if (p1s != null) foreach (var item in p1s) yield return item;
|
||||
if (p2 != null) yield return p2;
|
||||
if (p2s != null) foreach (var item in p2s) yield return item;
|
||||
}
|
||||
|
||||
static protected IEnumerable<ICancelablePromise> Concat(
|
||||
ICancelablePromise p1, IEnumerable<ICancelablePromise> p1s,
|
||||
ICancelablePromise p2, IEnumerable<ICancelablePromise> p2s,
|
||||
ICancelablePromise p3, IEnumerable<ICancelablePromise> p3s)
|
||||
{
|
||||
if (p1 != null) yield return p1;
|
||||
if (p1s != null) foreach (var item in p1s) yield return item;
|
||||
if (p2 != null) yield return p2;
|
||||
if (p2s != null) foreach (var item in p2s) yield return item;
|
||||
if (p3 != null) yield return p3;
|
||||
if (p3s != null) foreach (var item in p3s) yield return item;
|
||||
}
|
||||
|
||||
static protected IEnumerable<ICancelablePromise> Concat(
|
||||
ICancelablePromise p1, IEnumerable<ICancelablePromise> p1s,
|
||||
ICancelablePromise p2, IEnumerable<ICancelablePromise> p2s,
|
||||
ICancelablePromise p3, IEnumerable<ICancelablePromise> p3s,
|
||||
ICancelablePromise p4, IEnumerable<ICancelablePromise> p4s)
|
||||
{
|
||||
if (p1 != null) yield return p1;
|
||||
if (p1s != null) foreach (var item in p1s) yield return item;
|
||||
if (p2 != null) yield return p2;
|
||||
if (p2s != null) foreach (var item in p2s) yield return item;
|
||||
if (p3 != null) yield return p3;
|
||||
if (p3s != null) foreach (var item in p3s) yield return item;
|
||||
if (p4 != null) yield return p4;
|
||||
if (p4s != null) foreach (var item in p4s) yield return item;
|
||||
}
|
||||
|
||||
// otherwise...
|
||||
static protected IEnumerable<ICancelablePromise> Concat(params object[] promises)
|
||||
{
|
||||
foreach (var item in promises)
|
||||
{
|
||||
if (item is ICancelablePromise p)
|
||||
{
|
||||
yield return p;
|
||||
}
|
||||
else if (item is IEnumerable<ICancelablePromise> ps)
|
||||
{
|
||||
foreach (var p2 in ps)
|
||||
{
|
||||
yield return p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected UniTask<T> GetOrAddPromise<T>(ref AsyncTriggerPromise<T> promise, ref AsyncTriggerPromiseDictionary<T> promises, CancellationToken cancellationToken)
|
||||
{
|
||||
if (destroyCalled) return UniTask.FromCanceled<T>();
|
||||
|
||||
if (!cancellationToken.CanBeCanceled)
|
||||
{
|
||||
if (promise == null)
|
||||
{
|
||||
promise = new AsyncTriggerPromise<T>();
|
||||
if (!calledAwake)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
}
|
||||
}
|
||||
return promise.Task;
|
||||
}
|
||||
|
||||
if (promises == null) promises = new AsyncTriggerPromiseDictionary<T>();
|
||||
|
||||
if (promises.TryGetValue(cancellationToken, out var cancellablePromise))
|
||||
{
|
||||
return cancellablePromise.Task;
|
||||
}
|
||||
|
||||
cancellablePromise = new AsyncTriggerPromise<T>();
|
||||
promises.Add(cancellationToken, cancellablePromise);
|
||||
if (!calledAwake)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
}
|
||||
|
||||
var registrationToken = cancellationToken.RegisterWithoutCaptureExecutionContext(Callback, Tuple.Create((ICancellationTokenKeyDictionary)promises, (ICancelablePromise)cancellablePromise));
|
||||
if (registeredCancellations == null)
|
||||
{
|
||||
registeredCancellations = ArrayPool<CancellationTokenRegistration>.Shared.Rent(4);
|
||||
}
|
||||
ArrayPoolUtil.EnsureCapacity(ref registeredCancellations, registeredCancellationsCount + 1, ArrayPool<CancellationTokenRegistration>.Shared);
|
||||
registeredCancellations[registeredCancellationsCount++] = registrationToken;
|
||||
|
||||
return cancellablePromise.Task;
|
||||
}
|
||||
|
||||
static void CancelCallback(object state)
|
||||
{
|
||||
var tuple = (Tuple<ICancellationTokenKeyDictionary, ICancelablePromise>)state;
|
||||
var dict = tuple.Item1;
|
||||
var promise = tuple.Item2;
|
||||
|
||||
promise.TrySetCanceled();
|
||||
dict.Remove(promise.RegisteredCancellationToken);
|
||||
}
|
||||
|
||||
protected void TrySetResult<T>(ReusablePromise<T> promise, AsyncTriggerPromiseDictionary<T> promises, T value)
|
||||
{
|
||||
if (promise != null)
|
||||
{
|
||||
promise.TrySetResult(value);
|
||||
}
|
||||
if (promises != null)
|
||||
{
|
||||
PromiseHelper.TrySetResultAll(promises.Values, value);
|
||||
}
|
||||
}
|
||||
bool calledAwake;
|
||||
bool calledDestroy;
|
||||
ICancelPromise triggerSlot;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
calledAwake = true;
|
||||
}
|
||||
|
||||
protected TriggerEvent<T> SetTriggerEvent<T>(ref TriggerEvent<T> field)
|
||||
{
|
||||
if (field == null)
|
||||
{
|
||||
field = new TriggerEvent<T>();
|
||||
if (triggerSlot == null)
|
||||
{
|
||||
triggerSlot = field;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("triggerSlot is already filled.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!calledAwake)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
}
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (destroyCalled) return;
|
||||
destroyCalled = true;
|
||||
foreach (var item in GetPromises())
|
||||
{
|
||||
item.TrySetCanceled();
|
||||
}
|
||||
if (registeredCancellations != null)
|
||||
{
|
||||
for (int i = 0; i < registeredCancellationsCount; i++)
|
||||
{
|
||||
registeredCancellations[i].Dispose();
|
||||
registeredCancellations[i] = default(CancellationTokenRegistration);
|
||||
}
|
||||
ArrayPool<CancellationTokenRegistration>.Shared.Return(registeredCancellations);
|
||||
}
|
||||
if (calledDestroy) return;
|
||||
calledDestroy = true;
|
||||
|
||||
triggerSlot?.TrySetCanceled();
|
||||
triggerSlot = null;
|
||||
}
|
||||
|
||||
class AwakeMonitor : IPlayerLoopItem
|
||||
|
@ -228,6 +73,313 @@ namespace UniRx.Async.Triggers
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IAsyncOneShotTrigger
|
||||
{
|
||||
UniTask OneShotAsync();
|
||||
}
|
||||
|
||||
public partial class AsyncTriggerHandler<T> : IAsyncOneShotTrigger
|
||||
{
|
||||
UniTask IAsyncOneShotTrigger.OneShotAsync()
|
||||
{
|
||||
core.Reset();
|
||||
return new UniTask((IUniTaskSource)this, core.Version);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class AsyncTriggerHandler<T> : IUniTaskSource<T>, IResolvePromise<T>, ICancelPromise, IDisposable
|
||||
{
|
||||
static Action<object> cancellationCallback = CancellationCallback;
|
||||
|
||||
readonly TriggerEvent<T> trigger;
|
||||
|
||||
CancellationToken cancellationToken;
|
||||
CancellationTokenRegistration registration;
|
||||
bool isDisposed;
|
||||
bool callOnce;
|
||||
|
||||
UniTaskCompletionSourceCore<T> core;
|
||||
|
||||
internal CancellationToken CancellationToken => cancellationToken;
|
||||
|
||||
public AsyncTriggerHandler(TriggerEvent<T> trigger, bool callOnce)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
isDisposed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.trigger = trigger;
|
||||
this.cancellationToken = default;
|
||||
this.registration = default;
|
||||
this.callOnce = callOnce;
|
||||
|
||||
trigger.Add(this);
|
||||
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
}
|
||||
|
||||
public AsyncTriggerHandler(TriggerEvent<T> trigger, CancellationToken cancellationToken, bool callOnce)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
isDisposed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.trigger = trigger;
|
||||
this.cancellationToken = cancellationToken;
|
||||
this.callOnce = callOnce;
|
||||
|
||||
trigger.Add(this);
|
||||
|
||||
if (cancellationToken.CanBeCanceled)
|
||||
{
|
||||
registration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, this);
|
||||
}
|
||||
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
}
|
||||
|
||||
static void CancellationCallback(object state)
|
||||
{
|
||||
var self = (AsyncTriggerHandler<T>)state;
|
||||
self.Dispose();
|
||||
|
||||
self.core.TrySetCanceled(self.cancellationToken);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!isDisposed)
|
||||
{
|
||||
isDisposed = true;
|
||||
TaskTracker.RemoveTracking(this);
|
||||
registration.Dispose();
|
||||
trigger.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
T IUniTaskSource<T>.GetResult(short token)
|
||||
{
|
||||
try
|
||||
{
|
||||
return core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (callOnce)
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IResolvePromise<T>.TrySetResult(T result)
|
||||
{
|
||||
return core.TrySetResult(result);
|
||||
}
|
||||
|
||||
bool ICancelPromise.TrySetCanceled(CancellationToken cancellationToken)
|
||||
{
|
||||
return core.TrySetCanceled(cancellationToken);
|
||||
}
|
||||
|
||||
void IUniTaskSource.GetResult(short token)
|
||||
{
|
||||
((IUniTaskSource<T>)this).GetResult(token);
|
||||
}
|
||||
|
||||
UniTaskStatus IUniTaskSource.GetStatus(short token)
|
||||
{
|
||||
return core.GetStatus(token);
|
||||
}
|
||||
|
||||
UniTaskStatus IUniTaskSource.UnsafeGetStatus()
|
||||
{
|
||||
return core.UnsafeGetStatus();
|
||||
}
|
||||
|
||||
void IUniTaskSource.OnCompleted(Action<object> continuation, object state, short token)
|
||||
{
|
||||
core.OnCompleted(continuation, state, token);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TriggerEvent<T> : IResolvePromise<T>, ICancelPromise
|
||||
{
|
||||
// optimize: many cases, handler is single.
|
||||
AsyncTriggerHandler<T> singleHandler;
|
||||
|
||||
List<AsyncTriggerHandler<T>> handlers;
|
||||
|
||||
public bool TrySetResult(T value)
|
||||
{
|
||||
List<Exception> exceptions = null;
|
||||
|
||||
if (singleHandler != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
((IResolvePromise<T>)singleHandler).TrySetResult(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (handlers == null)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
else
|
||||
{
|
||||
exceptions = new List<Exception>();
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (handlers != null)
|
||||
{
|
||||
// make snapshot
|
||||
var rentArray = ArrayPoolUtil.CopyToRentArray(handlers);
|
||||
var clearArray = true;
|
||||
try
|
||||
{
|
||||
var array = rentArray.Array;
|
||||
var len = rentArray.Length;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
((IResolvePromise<T>)array[i]).TrySetResult(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (exceptions == null)
|
||||
{
|
||||
exceptions = new List<Exception>();
|
||||
}
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
array[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
rentArray.DisposeManually(clearArray);
|
||||
}
|
||||
}
|
||||
|
||||
if (exceptions != null)
|
||||
{
|
||||
throw new AggregateException(exceptions);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TrySetCanceled(CancellationToken cancellationToken)
|
||||
{
|
||||
List<Exception> exceptions = null;
|
||||
|
||||
if (singleHandler != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
((ICancelPromise)singleHandler).TrySetCanceled(cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (handlers == null)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
else
|
||||
{
|
||||
exceptions = new List<Exception>();
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (handlers != null)
|
||||
{
|
||||
// make snapshot
|
||||
var rentArray = ArrayPoolUtil.CopyToRentArray(handlers);
|
||||
var clearArray = true;
|
||||
try
|
||||
{
|
||||
var array = rentArray.Array;
|
||||
var len = rentArray.Length;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
((ICancelPromise)array[i]).TrySetCanceled(cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (exceptions == null)
|
||||
{
|
||||
exceptions = new List<Exception>();
|
||||
}
|
||||
exceptions.Add(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
array[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
rentArray.DisposeManually(clearArray);
|
||||
}
|
||||
}
|
||||
|
||||
if (exceptions != null)
|
||||
{
|
||||
throw new AggregateException(exceptions);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Add(AsyncTriggerHandler<T> handler)
|
||||
{
|
||||
if (singleHandler == null)
|
||||
{
|
||||
singleHandler = handler;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (handlers != null)
|
||||
{
|
||||
handlers = new List<AsyncTriggerHandler<T>>();
|
||||
handlers.Add(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(AsyncTriggerHandler<T> handler)
|
||||
{
|
||||
if (singleHandler == handler)
|
||||
{
|
||||
singleHandler = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (handlers != null)
|
||||
{
|
||||
handlers.Remove(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -25,7 +25,7 @@ namespace UniRx.Async
|
|||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
public static class AsyncTriggerExtensions
|
||||
public static partial class AsyncTriggerExtensions
|
||||
{
|
||||
// Util.
|
||||
|
||||
|
@ -74,444 +74,6 @@ namespace UniRx.Async.Triggers
|
|||
{
|
||||
return component.GetAsyncAwakeTrigger().AwakeAsync();
|
||||
}
|
||||
|
||||
// Get Triggers.
|
||||
|
||||
/// <summary>Get for OnAnimatorIKAsync | OnAnimatorMoveAsync.</summary>
|
||||
public static AsyncAnimatorTrigger GetAsyncAnimatorTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncAnimatorTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnAnimatorIKAsync | OnAnimatorMoveAsync.</summary>
|
||||
public static AsyncAnimatorTrigger GetAsyncAnimatorTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncAnimatorTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for AwakeAsync.</summary>
|
||||
public static AsyncAwakeTrigger GetAsyncAwakeTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncAwakeTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for AwakeAsync.</summary>
|
||||
public static AsyncAwakeTrigger GetAsyncAwakeTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncAwakeTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnBeginDragAsync.</summary>
|
||||
public static AsyncBeginDragTrigger GetAsyncBeginDragTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncBeginDragTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnBeginDragAsync.</summary>
|
||||
public static AsyncBeginDragTrigger GetAsyncBeginDragTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncBeginDragTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnCancelAsync.</summary>
|
||||
public static AsyncCancelTrigger GetAsyncCancelTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncCancelTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnCancelAsync.</summary>
|
||||
public static AsyncCancelTrigger GetAsyncCancelTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncCancelTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnCanvasGroupChangedAsync.</summary>
|
||||
public static AsyncCanvasGroupChangedTrigger GetAsyncCanvasGroupChangedTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncCanvasGroupChangedTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnCanvasGroupChangedAsync.</summary>
|
||||
public static AsyncCanvasGroupChangedTrigger GetAsyncCanvasGroupChangedTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncCanvasGroupChangedTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnCollisionEnter2DAsync | OnCollisionExit2DAsync | OnCollisionStay2DAsync.</summary>
|
||||
public static AsyncCollision2DTrigger GetAsyncCollision2DTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncCollision2DTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnCollisionEnter2DAsync | OnCollisionExit2DAsync | OnCollisionStay2DAsync.</summary>
|
||||
public static AsyncCollision2DTrigger GetAsyncCollision2DTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncCollision2DTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnCollisionEnterAsync | OnCollisionExitAsync | OnCollisionStayAsync.</summary>
|
||||
public static AsyncCollisionTrigger GetAsyncCollisionTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncCollisionTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnCollisionEnterAsync | OnCollisionExitAsync | OnCollisionStayAsync.</summary>
|
||||
public static AsyncCollisionTrigger GetAsyncCollisionTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncCollisionTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnDeselectAsync.</summary>
|
||||
public static AsyncDeselectTrigger GetAsyncDeselectTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncDeselectTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnDeselectAsync.</summary>
|
||||
public static AsyncDeselectTrigger GetAsyncDeselectTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncDeselectTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnDestroyAsync.</summary>
|
||||
public static AsyncDestroyTrigger GetAsyncDestroyTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncDestroyTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnDestroyAsync.</summary>
|
||||
public static AsyncDestroyTrigger GetAsyncDestroyTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncDestroyTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnDragAsync.</summary>
|
||||
public static AsyncDragTrigger GetAsyncDragTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncDragTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnDragAsync.</summary>
|
||||
public static AsyncDragTrigger GetAsyncDragTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncDragTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnDropAsync.</summary>
|
||||
public static AsyncDropTrigger GetAsyncDropTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncDropTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnDropAsync.</summary>
|
||||
public static AsyncDropTrigger GetAsyncDropTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncDropTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnEnableAsync | OnDisableAsync.</summary>
|
||||
public static AsyncEnableDisableTrigger GetAsyncEnableDisableTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncEnableDisableTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnEnableAsync | OnDisableAsync.</summary>
|
||||
public static AsyncEnableDisableTrigger GetAsyncEnableDisableTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncEnableDisableTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnEndDragAsync.</summary>
|
||||
public static AsyncEndDragTrigger GetAsyncEndDragTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncEndDragTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnEndDragAsync.</summary>
|
||||
public static AsyncEndDragTrigger GetAsyncEndDragTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncEndDragTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for FixedUpdateAsync.</summary>
|
||||
public static AsyncFixedUpdateTrigger GetAsyncFixedUpdateTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncFixedUpdateTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for FixedUpdateAsync.</summary>
|
||||
public static AsyncFixedUpdateTrigger GetAsyncFixedUpdateTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncFixedUpdateTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnInitializePotentialDragAsync.</summary>
|
||||
public static AsyncInitializePotentialDragTrigger GetAsyncInitializePotentialDragTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncInitializePotentialDragTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnInitializePotentialDragAsync.</summary>
|
||||
public static AsyncInitializePotentialDragTrigger GetAsyncInitializePotentialDragTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncInitializePotentialDragTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnJointBreakAsync.</summary>
|
||||
public static AsyncJointTrigger GetAsyncJointTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncJointTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnJointBreakAsync.</summary>
|
||||
public static AsyncJointTrigger GetAsyncJointTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncJointTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for LateUpdateAsync.</summary>
|
||||
public static AsyncLateUpdateTrigger GetAsyncLateUpdateTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncLateUpdateTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for LateUpdateAsync.</summary>
|
||||
public static AsyncLateUpdateTrigger GetAsyncLateUpdateTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncLateUpdateTrigger();
|
||||
}
|
||||
|
||||
#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO)
|
||||
|
||||
/// <summary>Get for OnMouseDownAsync | OnMouseDragAsync | OnMouseEnterAsync | OnMouseExitAsync | OnMouseOverAsync | OnMouseUpAsync | OnMouseUpAsButtonAsync.</summary>
|
||||
public static AsyncMouseTrigger GetAsyncMouseTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncMouseTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnMouseDownAsync | OnMouseDragAsync | OnMouseEnterAsync | OnMouseExitAsync | OnMouseOverAsync | OnMouseUpAsync | OnMouseUpAsButtonAsync.</summary>
|
||||
public static AsyncMouseTrigger GetAsyncMouseTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncMouseTrigger();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>Get for OnMoveAsync.</summary>
|
||||
public static AsyncMoveTrigger GetAsyncMoveTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncMoveTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnMoveAsync.</summary>
|
||||
public static AsyncMoveTrigger GetAsyncMoveTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncMoveTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnParticleCollisionAsync | OnParticleTriggerAsync.</summary>
|
||||
public static AsyncParticleTrigger GetAsyncParticleTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncParticleTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnParticleCollisionAsync | OnParticleTriggerAsync.</summary>
|
||||
public static AsyncParticleTrigger GetAsyncParticleTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncParticleTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerClickAsync.</summary>
|
||||
public static AsyncPointerClickTrigger GetAsyncPointerClickTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncPointerClickTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerClickAsync.</summary>
|
||||
public static AsyncPointerClickTrigger GetAsyncPointerClickTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncPointerClickTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerDownAsync.</summary>
|
||||
public static AsyncPointerDownTrigger GetAsyncPointerDownTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncPointerDownTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerDownAsync.</summary>
|
||||
public static AsyncPointerDownTrigger GetAsyncPointerDownTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncPointerDownTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerEnterAsync.</summary>
|
||||
public static AsyncPointerEnterTrigger GetAsyncPointerEnterTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncPointerEnterTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerEnterAsync.</summary>
|
||||
public static AsyncPointerEnterTrigger GetAsyncPointerEnterTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncPointerEnterTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerExitAsync.</summary>
|
||||
public static AsyncPointerExitTrigger GetAsyncPointerExitTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncPointerExitTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerExitAsync.</summary>
|
||||
public static AsyncPointerExitTrigger GetAsyncPointerExitTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncPointerExitTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerUpAsync.</summary>
|
||||
public static AsyncPointerUpTrigger GetAsyncPointerUpTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncPointerUpTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnPointerUpAsync.</summary>
|
||||
public static AsyncPointerUpTrigger GetAsyncPointerUpTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncPointerUpTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnRectTransformDimensionsChange | OnRectTransformDimensionsChangeAsync | OnRectTransformRemoved | OnRectTransformRemovedAsync.</summary>
|
||||
public static AsyncRectTransformTrigger GetAsyncRectTransformTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncRectTransformTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnRectTransformDimensionsChange | OnRectTransformDimensionsChangeAsync | OnRectTransformRemoved | OnRectTransformRemovedAsync.</summary>
|
||||
public static AsyncRectTransformTrigger GetAsyncRectTransformTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncRectTransformTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnScrollAsync.</summary>
|
||||
public static AsyncScrollTrigger GetAsyncScrollTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncScrollTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnScrollAsync.</summary>
|
||||
public static AsyncScrollTrigger GetAsyncScrollTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncScrollTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnSelectAsync.</summary>
|
||||
public static AsyncSelectTrigger GetAsyncSelectTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncSelectTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnSelectAsync.</summary>
|
||||
public static AsyncSelectTrigger GetAsyncSelectTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncSelectTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for StartAsync.</summary>
|
||||
public static AsyncStartTrigger GetAsyncStartTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncStartTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for StartAsync.</summary>
|
||||
public static AsyncStartTrigger GetAsyncStartTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncStartTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnSubmitAsync.</summary>
|
||||
public static AsyncSubmitTrigger GetAsyncSubmitTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncSubmitTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnSubmitAsync.</summary>
|
||||
public static AsyncSubmitTrigger GetAsyncSubmitTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncSubmitTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnBeforeTransformParentChangedAsync | OnTransformParentChangedAsync | OnTransformChildrenChangedAsync.</summary>
|
||||
public static AsyncTransformChangedTrigger GetAsyncTransformChangedTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncTransformChangedTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnBeforeTransformParentChangedAsync | OnTransformParentChangedAsync | OnTransformChildrenChangedAsync.</summary>
|
||||
public static AsyncTransformChangedTrigger GetAsyncTransformChangedTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncTransformChangedTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnTriggerEnter2DAsync | OnTriggerExit2DAsync | OnTriggerStay2DAsync.</summary>
|
||||
public static AsyncTrigger2DTrigger GetAsyncTrigger2DTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncTrigger2DTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnTriggerEnter2DAsync | OnTriggerExit2DAsync | OnTriggerStay2DAsync.</summary>
|
||||
public static AsyncTrigger2DTrigger GetAsyncTrigger2DTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncTrigger2DTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnTriggerEnterAsync | OnTriggerExitAsync | OnTriggerStayAsync.</summary>
|
||||
public static AsyncTriggerTrigger GetAsyncTriggerTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncTriggerTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnTriggerEnterAsync | OnTriggerExitAsync | OnTriggerStayAsync.</summary>
|
||||
public static AsyncTriggerTrigger GetAsyncTriggerTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncTriggerTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnUpdateSelectedAsync.</summary>
|
||||
public static AsyncUpdateSelectedTrigger GetAsyncUpdateSelectedTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncUpdateSelectedTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnUpdateSelectedAsync.</summary>
|
||||
public static AsyncUpdateSelectedTrigger GetAsyncUpdateSelectedTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncUpdateSelectedTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for UpdateAsync.</summary>
|
||||
public static AsyncUpdateTrigger GetAsyncUpdateTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncUpdateTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for UpdateAsync.</summary>
|
||||
public static AsyncUpdateTrigger GetAsyncUpdateTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncUpdateTrigger();
|
||||
}
|
||||
|
||||
/// <summary>Get for OnBecameInvisibleAsync | OnBecameVisibleAsync.</summary>
|
||||
public static AsyncVisibleTrigger GetAsyncVisibleTrigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<AsyncVisibleTrigger>(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>Get for OnBecameInvisibleAsync | OnBecameVisibleAsync.</summary>
|
||||
public static AsyncVisibleTrigger GetAsyncVisibleTrigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsyncVisibleTrigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncTriggerTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<Collider> onTriggerEnter;
|
||||
AsyncTriggerPromiseDictionary<Collider> onTriggerEnters;
|
||||
AsyncTriggerPromise<Collider> onTriggerExit;
|
||||
AsyncTriggerPromiseDictionary<Collider> onTriggerExits;
|
||||
AsyncTriggerPromise<Collider> onTriggerStay;
|
||||
AsyncTriggerPromiseDictionary<Collider> onTriggerStays;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onTriggerEnter, onTriggerEnters, onTriggerExit, onTriggerExits, onTriggerStay, onTriggerStays);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
TrySetResult(onTriggerEnter, onTriggerEnters, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collider> OnTriggerEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerEnter, ref onTriggerEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
TrySetResult(onTriggerExit, onTriggerExits, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collider> OnTriggerExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerExit, ref onTriggerExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerStay(Collider other)
|
||||
{
|
||||
TrySetResult(onTriggerStay, onTriggerStays, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<Collider> OnTriggerStayAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerStay, ref onTriggerStays, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 46bbbbaa910762c4786906e10b6b7b8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncUpdateSelectedTrigger : AsyncTriggerBase, IUpdateSelectedHandler
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onUpdateSelected;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onUpdateSelecteds;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onUpdateSelected, onUpdateSelecteds);
|
||||
}
|
||||
|
||||
|
||||
void IUpdateSelectedHandler.OnUpdateSelected(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onUpdateSelected, onUpdateSelecteds, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask<BaseEventData> OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onUpdateSelected, ref onUpdateSelecteds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ba5b0a4234e164e41b85f10b709d72e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,200 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using UniRx.Async.Internal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncUpdateTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> update;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> updates;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(update, updates);
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
TrySetResult(update, updates, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask UpdateAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref update, ref updates, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO:remove 2.
|
||||
public abstract class AsyncTriggerBase2 : MonoBehaviour
|
||||
{
|
||||
static readonly Action<object> Callback = CancelCallback;
|
||||
|
||||
bool calledAwake = false;
|
||||
bool destroyCalled = false;
|
||||
CancellationTokenRegistration[] registeredCancellations;
|
||||
int registeredCancellationsCount;
|
||||
|
||||
protected abstract IEnumerable<ICancelablePromise> GetPromises();
|
||||
|
||||
void Awake()
|
||||
{
|
||||
calledAwake = true;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (destroyCalled) return;
|
||||
destroyCalled = true;
|
||||
foreach (var item in GetPromises())
|
||||
{
|
||||
item.TrySetCanceled();
|
||||
}
|
||||
if (registeredCancellations != null)
|
||||
{
|
||||
for (int i = 0; i < registeredCancellationsCount; i++)
|
||||
{
|
||||
registeredCancellations[i].Dispose();
|
||||
registeredCancellations[i] = default(CancellationTokenRegistration);
|
||||
}
|
||||
ArrayPool<CancellationTokenRegistration>.Shared.Return(registeredCancellations);
|
||||
}
|
||||
}
|
||||
|
||||
protected void TrySetResult<T>(MinimumQueue<UniTaskCompletionSource<AsyncUnit>> promise, AsyncTriggerPromiseDictionary<T> promises, T result)
|
||||
{
|
||||
if (promise != null)
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
|
||||
if (promises != null)
|
||||
{
|
||||
PromiseHelper.TrySetResultAll(promises.Values, result);
|
||||
}
|
||||
}
|
||||
|
||||
public UniTask<T> CreatePromise<T>(ref MinimumQueue<AutoResetUniTaskCompletionSource<T>> promise, ref AsyncTriggerPromiseDictionary<T> promises, CancellationToken cancellationToken)
|
||||
{
|
||||
if (destroyCalled) return UniTask.FromCanceled<T>();
|
||||
|
||||
if (!calledAwake)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
}
|
||||
|
||||
if (!cancellationToken.CanBeCanceled)
|
||||
{
|
||||
if (promise == null)
|
||||
{
|
||||
promise = new MinimumQueue<AutoResetUniTaskCompletionSource<T>>(4); // kakko kari.(ArrayPool?)
|
||||
}
|
||||
|
||||
var tcs = AutoResetUniTaskCompletionSource<T>.Create();
|
||||
promise.Enqueue(tcs);
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
|
||||
CancellationTokenRegistration registrationToken = default;
|
||||
// TODO:atode.
|
||||
// var registrationToken = cancellationToken.RegisterWithoutCaptureExecutionContext(Callback, Tuple.Create((ICancellationTokenKeyDictionary)promises, (ICancelablePromise)cancellablePromise));
|
||||
if (registeredCancellations == null)
|
||||
{
|
||||
registeredCancellations = ArrayPool<CancellationTokenRegistration>.Shared.Rent(4);
|
||||
}
|
||||
|
||||
ArrayPoolUtil.EnsureCapacity(ref registeredCancellations, registeredCancellationsCount + 1, ArrayPool<CancellationTokenRegistration>.Shared);
|
||||
registeredCancellations[registeredCancellationsCount++] = registrationToken;
|
||||
|
||||
// TODO:<3A>ªuse at registration
|
||||
{
|
||||
if (promises == null)
|
||||
{
|
||||
promises = new AsyncTriggerPromiseDictionary<T>();
|
||||
}
|
||||
|
||||
var tcs = AutoResetUniTaskCompletionSource<T>.Create();
|
||||
promises.Add(cancellationToken, tcs);
|
||||
return tcs.Task;
|
||||
}
|
||||
}
|
||||
|
||||
static void CancelCallback(object state)
|
||||
{
|
||||
// TODO:nantokasuru.
|
||||
|
||||
//var tuple = (Tuple<ICancellationTokenKeyDictionary, ICancelablePromise>)state;
|
||||
//var dict = tuple.Item1;
|
||||
//var promise = tuple.Item2;
|
||||
|
||||
//promise.TrySetCanceled();
|
||||
//dict.Remove(promise.RegisteredCancellationToken);
|
||||
}
|
||||
|
||||
class AwakeMonitor : IPlayerLoopItem
|
||||
{
|
||||
readonly AsyncTriggerBase2 trigger;
|
||||
|
||||
public AwakeMonitor(AsyncTriggerBase2 trigger)
|
||||
{
|
||||
this.trigger = trigger;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (trigger.calledAwake) return false;
|
||||
if (trigger == null)
|
||||
{
|
||||
trigger.OnDestroy();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO:remove 2.
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncUpdateTrigger2 : AsyncTriggerBase2
|
||||
{
|
||||
MinimumQueue<UniTaskCompletionSource<AsyncUnit>> promise;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> promises;
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
// TODO:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// TrySetResult
|
||||
}
|
||||
|
||||
public UniTask UpdateAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return CreatePromise<AsyncUnit>(ref promise, ref promises, cancellationToken).AsUniTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c6053bbe25af0d6439712f7c5fc4afc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,55 +0,0 @@
|
|||
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncVisibleTrigger : AsyncTriggerBase
|
||||
{
|
||||
AsyncTriggerPromise<AsyncUnit> onBecameInvisible;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onBecameInvisibles;
|
||||
AsyncTriggerPromise<AsyncUnit> onBecameVisible;
|
||||
AsyncTriggerPromiseDictionary<AsyncUnit> onBecameVisibles;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onBecameInvisible, onBecameInvisibles, onBecameVisible, onBecameVisibles);
|
||||
}
|
||||
|
||||
|
||||
void OnBecameInvisible()
|
||||
{
|
||||
TrySetResult(onBecameInvisible, onBecameInvisibles, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnBecameInvisibleAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onBecameInvisible, ref onBecameInvisibles, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnBecameVisible()
|
||||
{
|
||||
TrySetResult(onBecameVisible, onBecameVisibles, AsyncUnit.Default);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnBecameVisibleAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onBecameVisible, ref onBecameVisibles, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57ebfef2a87c49c46ad6454db136f3ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,186 @@
|
|||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".cs" #>
|
||||
<#
|
||||
var empty = new (string, string)[0];
|
||||
|
||||
var triggers = new (string triggerName, string methodName, string returnType, string handlerInterface, (string argType, string argName)[] arguments)[]
|
||||
{
|
||||
("AnimatorIK", "OnAnimatorIK", "int", null, new []{ ("int", "layerIndex") }),
|
||||
("AnimatorMove", "OnAnimatorMove", "AsyncUnit", null, empty),
|
||||
("OnCanvasGroupChanged", "OnCanvasGroupChanged", "AsyncUnit", null, empty ),
|
||||
("CollisionEnter2D", "OnCollisionEnter2D", "Collision2D", null, new []{ ("Collision2D", "coll") }),
|
||||
("CollisionExit2D", "OnCollisionExit2D", "Collision2D", null, new []{ ("Collision2D", "coll") }),
|
||||
("CollisionStay2D", "OnCollisionStay2D", "Collision2D", null, new []{ ("Collision2D", "coll") }),
|
||||
("CollisionEnter", "OnCollisionEnter", "Collision", null, new []{ ("Collision", "coll") }),
|
||||
("CollisionExit", "OnCollisionExit", "Collision", null, new []{ ("Collision", "coll") }),
|
||||
("CollisionStay", "OnCollisionStay", "Collision", null, new []{ ("Collision", "coll") }),
|
||||
("Enable", "OnEnable", "AsyncUnit", null, empty),
|
||||
("Disable", "OnDisable", "AsyncUnit", null, empty),
|
||||
("JointBreak", "OnJointBreak", "float", null, new []{ ("float", "breakForce") }),
|
||||
("JointBreak2D", "OnJointBreak2D", "Joint2D", null, new []{ ("Joint2D", "brokenJoint") }),
|
||||
("Update", "Update", "AsyncUnit", null, empty),
|
||||
("FixedUpdate", "FixedUpdate", "AsyncUnit", null, empty),
|
||||
("LateUpdate", "LateUpdate", "AsyncUnit", null, empty),
|
||||
("MouseDown", "OnMouseDown", "AsyncUnit", null, empty),
|
||||
("MouseDrag", "OnMouseDrag", "AsyncUnit", null, empty),
|
||||
("MouseEnter", "OnMouseEnter", "AsyncUnit", null, empty),
|
||||
("MouseExit", "OnMouseExit", "AsyncUnit", null, empty),
|
||||
("MouseOver", "OnMouseOver", "AsyncUnit", null, empty),
|
||||
("MouseUp", "OnMouseUp", "AsyncUnit", null, empty),
|
||||
("MouseUpAsButton", "OnMouseUpAsButton", "AsyncUnit", null, empty),
|
||||
("ParticleCollision", "OnParticleCollision", "GameObject", null, new []{ ("GameObject", "other") }),
|
||||
("RectTransformDimensionsChange", "OnRectTransformDimensionsChange", "AsyncUnit", null, empty),
|
||||
("RectTransformRemoved", "OnRectTransformRemoved", "AsyncUnit", null, empty),
|
||||
("BeforeTransformParentChanged", "OnBeforeTransformParentChanged", "AsyncUnit", null, empty),
|
||||
("TransformParentChanged", "OnTransformParentChanged", "AsyncUnit", null, empty),
|
||||
("TransformChildrenChanged", "OnTransformChildrenChanged", "AsyncUnit", null, empty),
|
||||
("TriggerEnter2D", "OnTriggerEnter2D", "Collider2D", null, new []{ ("Collider2D", "other") }),
|
||||
("TriggerExit2D", "OnTriggerExit2D", "Collider2D", null, new []{ ("Collider2D", "other") }),
|
||||
("TriggerStay2D", "OnTriggerStay2D", "Collider2D", null, new []{ ("Collider2D", "other") }),
|
||||
("TriggerEnter", "OnTriggerEnter", "Collider", null, new []{ ("Collider", "other") }),
|
||||
("TriggerExit", "OnTriggerExit", "Collider", null, new []{ ("Collider", "other") }),
|
||||
("TriggerStay", "OnTriggerStay", "Collider", null, new []{ ("Collider", "other") }),
|
||||
("BecameInvisible", "OnBecameInvisible", "AsyncUnit", null, empty),
|
||||
("BecameVisible", "OnBecameVisible", "AsyncUnit", null, empty),
|
||||
|
||||
// new in v2
|
||||
("ApplicationFocus", "OnApplicationFocus", "bool", null, new []{("bool", "hasFocus") }),
|
||||
("ApplicationPause", "OnApplicationPause", "bool", null, new []{("bool", "pauseStatus") }),
|
||||
("ApplicationQuit", "OnApplicationQuit", "AsyncUnit", null, empty),
|
||||
("AudioFilterRead", "OnAudioFilterRead", "(float[] data, int channels)", null, new[]{("float[]", "data"), ("int", "channels")}),
|
||||
("ControllerColliderHit", "OnControllerColliderHit", "ControllerColliderHit", null, new[]{("ControllerColliderHit", "hit")}),
|
||||
("DrawGizmos", "OnDrawGizmos", "AsyncUnit", null, empty),
|
||||
("DrawGizmosSelected", "OnDrawGizmosSelected", "AsyncUnit", null, empty),
|
||||
("GUI", "OnGUI", "AsyncUnit", null, empty),
|
||||
("ParticleSystemStopped", "OnParticleSystemStopped", "AsyncUnit", null, empty),
|
||||
("ParticleTrigger", "OnParticleTrigger", "AsyncUnit", null, empty),
|
||||
("PostRender", "OnPostRender", "AsyncUnit", null, empty),
|
||||
("PreCull", "OnPreCull", "AsyncUnit", null, empty),
|
||||
("PreRender", "OnPreRender", "AsyncUnit", null, empty),
|
||||
("RenderImage", "OnRenderImage", "(RenderTexture source, RenderTexture destination)", null, new[]{("RenderTexture", "source"), ("RenderTexture", "destination")}),
|
||||
("RenderObject", "OnRenderObject", "AsyncUnit", null, empty),
|
||||
("ServerInitialized", "OnServerInitialized", "AsyncUnit", null, empty),
|
||||
("Validate", "OnValidate", "AsyncUnit", null, empty),
|
||||
("WillRenderObject", "OnWillRenderObject", "AsyncUnit", null, empty),
|
||||
("Reset", "Reset", "AsyncUnit", null, empty),
|
||||
|
||||
// uGUI
|
||||
("BeginDrag", "OnBeginDrag", "PointerEventData", "IBeginDragHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("Cancel", "OnCancel", "BaseEventData", "ICancelHandler", new []{ ("BaseEventData", "eventData") }),
|
||||
("Deselect", "OnDeselect", "BaseEventData", "IDeselectHandler", new []{ ("BaseEventData", "eventData") }),
|
||||
("Drag", "OnDrag", "PointerEventData", "IDragHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("Drop", "OnDrop", "PointerEventData", "IDropHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("EndDrag", "OnEndDrag", "PointerEventData", "IEndDragHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("InitializePotentialDrag", "OnInitializePotentialDrag", "PointerEventData", "IInitializePotentialDragHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("Move", "OnMove", "AxisEventData", "IMoveHandler", new []{ ("AxisEventData", "eventData") }),
|
||||
("PointerClick", "OnPointerClick", "PointerEventData", "IPointerClickHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("PointerDown", "OnPointerDown", "PointerEventData", "IPointerDownHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("PointerEnter", "OnPointerEnter", "PointerEventData", "IPointerEnterHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("PointerExit", "OnPointerExit", "PointerEventData", "IPointerExitHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("PointerUp", "OnPointerUp", "PointerEventData", "IPointerUpHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("Scroll", "OnScroll", "PointerEventData", "IScrollHandler", new []{ ("PointerEventData", "eventData") }),
|
||||
("Select", "OnSelect", "BaseEventData", "ISelectHandler", new []{ ("BaseEventData", "eventData") }),
|
||||
("Submit", "OnSubmit", "BaseEventData", "ISubmitHandler", new []{ ("BaseEventData", "eventData") }),
|
||||
("UpdateSelected", "OnUpdateSelected", "BaseEventData", "IUpdateSelectedHandler", new []{ ("BaseEventData", "eventData") }),
|
||||
|
||||
// 2019.3
|
||||
("ParticleUpdateJobScheduled", "OnParticleUpdateJobScheduled", "UnityEngine.ParticleSystemJobs.ParticleSystemJobData", null, new[]{("UnityEngine.ParticleSystemJobs.ParticleSystemJobData", "particles")}),
|
||||
|
||||
// Oneshot
|
||||
// Awake, Start, Destroy
|
||||
};
|
||||
|
||||
triggers = triggers.OrderBy(x => x.handlerInterface != null).ThenBy(x => x.handlerInterface != null ? x.handlerInterface : x.methodName).ToArray();
|
||||
|
||||
Func<string, string> ToInterfaceName = x => $"IAsync{x}Handler";
|
||||
Func<string, string> ToUniTaskName = x => x == "AsyncUnit" ? "UniTask" : $"UniTask<{x}>";
|
||||
Func<string, string> ToCastUniTasSourceType = x => x == "AsyncUnit" ? "IUniTaskSource" : $"IUniTaskSource<{x}>";
|
||||
Func<string, string> TriggerFieldName = x => char.ToLowerInvariant(x[0]) + x.Substring(1, x.Length - 1) + "TriggerEvent";
|
||||
Func<string, string> OnInvokeSuffix = x => x == "AsyncUnit" ? ".AsUniTask()" : $"";
|
||||
Func<(string argType, string argName)[], string> BuildMethodArgument = x => string.Join(", ", x.Select(y => y.argType + " " + y.argName));
|
||||
Func<(string argType, string argName)[], string> BuildResultParameter = x => x.Length == 0 ? "AsyncUnit.Default" : "(" + string.Join(", ", x.Select(y => y.argName)) + ")";
|
||||
|
||||
Func<string, bool> Is2019_3 = x => x == "ParticleUpdateJobScheduled";
|
||||
#>
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
<# foreach(var t in triggers) { #>
|
||||
#region <#= t.triggerName #>
|
||||
<# if(Is2019_3(t.triggerName)) { #>
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
<# } #>
|
||||
|
||||
public interface <#= ToInterfaceName(t.methodName) #>
|
||||
{
|
||||
<#= ToUniTaskName(t.returnType) #> <#= t.methodName #>Async();
|
||||
}
|
||||
|
||||
public partial class AsyncTriggerHandler<T> : <#= ToInterfaceName(t.methodName) #>
|
||||
{
|
||||
<#= ToUniTaskName(t.returnType) #> <#= ToInterfaceName(t.methodName) #>.<#= t.methodName #>Async()
|
||||
{
|
||||
core.Reset();
|
||||
return new <#= ToUniTaskName(t.returnType) #>((<#= ToCastUniTasSourceType(t.returnType) #>)(object)this, core.Version);
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class AsyncTriggerExtensions
|
||||
{
|
||||
public static Async<#= t.triggerName #>Trigger GetAsync<#= t.triggerName #>Trigger(this GameObject gameObject)
|
||||
{
|
||||
return GetOrAddComponent<Async<#= t.triggerName #>Trigger>(gameObject);
|
||||
}
|
||||
|
||||
public static Async<#= t.triggerName #>Trigger GetAsync<#= t.triggerName #>Trigger(this Component component)
|
||||
{
|
||||
return component.gameObject.GetAsync<#= t.triggerName #>Trigger();
|
||||
}
|
||||
}
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public sealed class Async<#= t.triggerName #>Trigger : AsyncTriggerBase<#= (t.handlerInterface == null) ? "" : $", {t.handlerInterface}" #>
|
||||
{
|
||||
TriggerEvent<<#= t.returnType #>> <#= TriggerFieldName(t.methodName) #>;
|
||||
|
||||
void <#= (t.handlerInterface == null) ? "" : $"{t.handlerInterface}." #><#= t.methodName #>(<#= BuildMethodArgument(t.arguments) #>)
|
||||
{
|
||||
<#= TriggerFieldName(t.methodName) #>?.TrySetResult(<#= BuildResultParameter(t.arguments) #>);
|
||||
}
|
||||
|
||||
public <#= ToInterfaceName(t.methodName) #> Get<#= t.methodName #>AsyncHandler()
|
||||
{
|
||||
return new AsyncTriggerHandler<<#= t.returnType #>>(SetTriggerEvent(ref <#= TriggerFieldName(t.methodName) #>), false);
|
||||
}
|
||||
|
||||
public <#= ToInterfaceName(t.methodName) #> Get<#= t.methodName #>AsyncHandler(CancellationToken cancellationToken)
|
||||
{
|
||||
return new AsyncTriggerHandler<<#= t.returnType #>>(SetTriggerEvent(ref <#= TriggerFieldName(t.methodName) #>), cancellationToken, false);
|
||||
}
|
||||
|
||||
public <#= ToUniTaskName(t.returnType) #> <#= t.methodName #>Async()
|
||||
{
|
||||
return ((<#= ToInterfaceName(t.methodName) #>)new AsyncTriggerHandler<<#= t.returnType #>>(SetTriggerEvent(ref <#= TriggerFieldName(t.methodName) #>), true)).<#= t.methodName #>Async();
|
||||
}
|
||||
|
||||
public <#= ToUniTaskName(t.returnType) #> <#= t.methodName #>Async(CancellationToken cancellationToken)
|
||||
{
|
||||
return ((<#= ToInterfaceName(t.methodName) #>)new AsyncTriggerHandler<<#= t.returnType #>>(SetTriggerEvent(ref <#= TriggerFieldName(t.methodName) #>), cancellationToken, true)).<#= t.methodName #>Async();
|
||||
}
|
||||
}
|
||||
<# if(Is2019_3(t.triggerName)) { #>
|
||||
#endif
|
||||
<# } #>
|
||||
#endregion
|
||||
|
||||
<# } #>
|
||||
}
|
|
@ -79,7 +79,7 @@ namespace UniRx.Async
|
|||
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -91,7 +91,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
@ -168,7 +168,7 @@ namespace UniRx.Async
|
|||
result.delayFrameCount = delayFrameCount;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -180,7 +180,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
@ -266,7 +266,7 @@ namespace UniRx.Async
|
|||
result.delayFrameTimeSpan = (float)delayFrameTimeSpan.TotalSeconds;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -278,7 +278,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
@ -364,7 +364,7 @@ namespace UniRx.Async
|
|||
result.delayFrameTimeSpan = (float)delayFrameTimeSpan.TotalSeconds;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -376,7 +376,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace UniRx.Async
|
|||
result.predicate = predicate;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
@ -158,7 +158,7 @@ namespace UniRx.Async
|
|||
result.predicate = predicate;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -170,7 +170,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
@ -267,7 +267,7 @@ namespace UniRx.Async
|
|||
result.equalityComparer = equalityComparer ?? UnityEqualityComparer.GetDefault<U>();
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -279,7 +279,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
@ -387,7 +387,7 @@ namespace UniRx.Async
|
|||
result.equalityComparer = equalityComparer ?? UnityEqualityComparer.GetDefault<U>();
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -399,7 +399,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -271,7 +271,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -471,7 +471,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -707,7 +707,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -979,7 +979,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -1034,7 +1034,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -1287,7 +1287,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -1343,7 +1343,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -1631,7 +1631,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7, T8) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -1688,7 +1688,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -2011,7 +2011,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7, T8, T9) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -2069,7 +2069,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -2427,7 +2427,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -2486,7 +2486,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -2879,7 +2879,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -2939,7 +2939,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -3367,7 +3367,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -3428,7 +3428,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -3891,7 +3891,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -3953,7 +3953,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13, UniTask<T14> task14)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -4451,7 +4451,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -4514,7 +4514,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13, UniTask<T14> task14, UniTask<T15> task15)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -5047,7 +5047,7 @@ namespace UniRx.Async
|
|||
|
||||
public (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace UniRx.Async
|
|||
|
||||
public static UniTask<T[]> WhenAll<T>(IEnumerable<UniTask<T>> tasks)
|
||||
{
|
||||
using (var span = ArrayPoolUtil.Materialize(tasks))
|
||||
using (var span = ArrayPoolUtil.CopyToRentArray(tasks))
|
||||
{
|
||||
var promise = new WhenAllPromise<T>(span.Array, span.Length); // consumed array in constructor.
|
||||
return new UniTask<T[]>(promise, 0);
|
||||
|
@ -31,7 +31,7 @@ namespace UniRx.Async
|
|||
|
||||
public static UniTask WhenAll(IEnumerable<UniTask> tasks)
|
||||
{
|
||||
using (var span = ArrayPoolUtil.Materialize(tasks))
|
||||
using (var span = ArrayPoolUtil.CopyToRentArray(tasks))
|
||||
{
|
||||
var promise = new WhenAllPromise(span.Array, span.Length); // consumed array in constructor.
|
||||
return new UniTask(promise, 0);
|
||||
|
@ -46,7 +46,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask<T>[] tasks, int tasksLength)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completeCount = 0;
|
||||
this.result = new T[tasksLength];
|
||||
|
@ -101,7 +101,7 @@ namespace UniRx.Async
|
|||
|
||||
public T[] GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAllPromise(UniTask[] tasks, int tasksLength)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.tasksLength = tasksLength;
|
||||
this.completeCount = 0;
|
||||
|
@ -195,7 +195,7 @@ namespace UniRx.Async
|
|||
|
||||
public void GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -464,7 +464,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -700,7 +700,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -973,7 +973,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -1016,7 +1016,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -1283,7 +1283,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -1326,7 +1326,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -1630,7 +1630,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -1673,7 +1673,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -2014,7 +2014,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -2057,7 +2057,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -2435,7 +2435,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -2478,7 +2478,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -2893,7 +2893,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -2936,7 +2936,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -3388,7 +3388,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -3431,7 +3431,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -3920,7 +3920,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -3963,7 +3963,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13, UniTask<T14> task14)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -4489,7 +4489,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -4532,7 +4532,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T1> task1, UniTask<T2> task2, UniTask<T3> task3, UniTask<T4> task4, UniTask<T5> task5, UniTask<T6> task6, UniTask<T7> task7, UniTask<T8> task8, UniTask<T9> task9, UniTask<T10> task10, UniTask<T11> task11, UniTask<T12> task12, UniTask<T13> task13, UniTask<T14> task14, UniTask<T15> task15)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
this.completedCount = 0;
|
||||
{
|
||||
|
@ -5095,7 +5095,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7, T8 result8, T9 result9, T10 result10, T11 result11, T12 result12, T13 result13, T14 result14, T15 result15) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace UniRx.Async
|
|||
|
||||
public static UniTask<(int winArgumentIndex, T result)> WhenAny<T>(IEnumerable<UniTask<T>> tasks)
|
||||
{
|
||||
using (var span = ArrayPoolUtil.Materialize(tasks))
|
||||
using (var span = ArrayPoolUtil.CopyToRentArray(tasks))
|
||||
{
|
||||
return new UniTask<(int, T)>(new WhenAnyPromise<T>(span.Array, span.Length), 0);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace UniRx.Async
|
|||
/// <summary>Return value is winArgumentIndex</summary>
|
||||
public static UniTask<int> WhenAny(IEnumerable<UniTask> tasks)
|
||||
{
|
||||
using (var span = ArrayPoolUtil.Materialize(tasks))
|
||||
using (var span = ArrayPoolUtil.CopyToRentArray(tasks))
|
||||
{
|
||||
return new UniTask<int>(new WhenAnyPromise(span.Array, span.Length), 0);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyLRPromise(UniTask<T> leftTask, UniTask rightTask)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
{
|
||||
UniTask<T>.Awaiter awaiter;
|
||||
|
@ -149,7 +149,7 @@ namespace UniRx.Async
|
|||
|
||||
public (bool, T) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask<T>[] tasks, int tasksLength)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
for (int i = 0; i < tasksLength; i++)
|
||||
{
|
||||
|
@ -242,7 +242,7 @@ namespace UniRx.Async
|
|||
|
||||
public (int, T) GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ namespace UniRx.Async
|
|||
|
||||
public WhenAnyPromise(UniTask[] tasks, int tasksLength)
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
|
||||
for (int i = 0; i < tasksLength; i++)
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ namespace UniRx.Async
|
|||
|
||||
public int GetResult(short token)
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
GC.SuppressFinalize(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ namespace UniRx.Async
|
|||
|
||||
public UniTaskCompletionSource()
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 2);
|
||||
TaskTracker.TrackActiveTask(this, 2);
|
||||
}
|
||||
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
|
@ -281,7 +281,7 @@ namespace UniRx.Async
|
|||
if (!handled)
|
||||
{
|
||||
handled = true;
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ namespace UniRx.Async
|
|||
{
|
||||
// Reset, re-active tracker
|
||||
handled = false;
|
||||
TaskTracker2.TrackActiveTask(this, 2);
|
||||
TaskTracker.TrackActiveTask(this, 2);
|
||||
core.Reset();
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ namespace UniRx.Async
|
|||
public static AutoResetUniTaskCompletionSource Create()
|
||||
{
|
||||
var value = pool.TryRent() ?? new AutoResetUniTaskCompletionSource();
|
||||
TaskTracker2.TrackActiveTask(value, 2);
|
||||
TaskTracker.TrackActiveTask(value, 2);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
@ -459,7 +459,7 @@ namespace UniRx.Async
|
|||
|
||||
public UniTaskCompletionSource()
|
||||
{
|
||||
TaskTracker2.TrackActiveTask(this, 2);
|
||||
TaskTracker.TrackActiveTask(this, 2);
|
||||
}
|
||||
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
|
@ -468,7 +468,7 @@ namespace UniRx.Async
|
|||
if (!handled)
|
||||
{
|
||||
handled = true;
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ namespace UniRx.Async
|
|||
{
|
||||
handled = false;
|
||||
core.Reset();
|
||||
TaskTracker2.TrackActiveTask(this, 2);
|
||||
TaskTracker.TrackActiveTask(this, 2);
|
||||
}
|
||||
|
||||
public bool TrySetResult(T result)
|
||||
|
@ -548,7 +548,7 @@ namespace UniRx.Async
|
|||
public static AutoResetUniTaskCompletionSource<T> Create()
|
||||
{
|
||||
var result = pool.TryRent() ?? new AutoResetUniTaskCompletionSource<T>();
|
||||
TaskTracker2.TrackActiveTask(result, 2);
|
||||
TaskTracker.TrackActiveTask(result, 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
return core.GetResult(token);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -3,136 +3,117 @@
|
|||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using UniRx.Async.Internal;
|
||||
using Unity.Jobs;
|
||||
|
||||
namespace UniRx.Async
|
||||
{
|
||||
public static partial class UnityAsyncExtensions
|
||||
{
|
||||
public static IAwaiter GetAwaiter(this JobHandle jobHandle)
|
||||
public static UniTask.Awaiter GetAwaiter(this JobHandle jobHandle)
|
||||
{
|
||||
var awaiter = new JobHandleAwaiter(jobHandle, CancellationToken.None);
|
||||
if (!awaiter.IsCompleted)
|
||||
var handler = JobHandlePromise.Create(jobHandle, CancellationToken.None, out var token);
|
||||
if (handler.GetStatus(token).IsCompleted() && handler is JobHandlePromise loopItem)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.EarlyUpdate, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PreUpdate, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PreLateUpdate, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PostLateUpdate, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.EarlyUpdate, loopItem);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PreUpdate, loopItem);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, loopItem);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PreLateUpdate, loopItem);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PostLateUpdate, loopItem);
|
||||
}
|
||||
return awaiter;
|
||||
|
||||
return new UniTask(handler, token).GetAwaiter();
|
||||
}
|
||||
|
||||
public static UniTask ToUniTask(this JobHandle jobHandle, CancellationToken cancellation = default(CancellationToken))
|
||||
{
|
||||
var awaiter = new JobHandleAwaiter(jobHandle, cancellation);
|
||||
if (!awaiter.IsCompleted)
|
||||
var handler = JobHandlePromise.Create(jobHandle, cancellation, out var token);
|
||||
if (handler.GetStatus(token).IsCompleted() && handler is JobHandlePromise loopItem)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.EarlyUpdate, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PreUpdate, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PreLateUpdate, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PostLateUpdate, awaiter);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.EarlyUpdate, loopItem);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PreUpdate, loopItem);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, loopItem);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PreLateUpdate, loopItem);
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.PostLateUpdate, loopItem);
|
||||
}
|
||||
return new UniTask(awaiter);
|
||||
|
||||
return new UniTask(handler, token);
|
||||
}
|
||||
|
||||
public static UniTask ConfigureAwait(this JobHandle jobHandle, PlayerLoopTiming waitTiming, CancellationToken cancellation = default(CancellationToken))
|
||||
{
|
||||
var awaiter = new JobHandleAwaiter(jobHandle, cancellation);
|
||||
if (!awaiter.IsCompleted)
|
||||
var handler = JobHandlePromise.Create(jobHandle, cancellation, out var token);
|
||||
if (handler.GetStatus(token).IsCompleted() && handler is JobHandlePromise loopItem)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(waitTiming, awaiter);
|
||||
}
|
||||
return new UniTask(awaiter);
|
||||
PlayerLoopHelper.AddAction(waitTiming, loopItem);
|
||||
}
|
||||
|
||||
class JobHandleAwaiter : IAwaiter, IPlayerLoopItem
|
||||
return new UniTask(handler, token);
|
||||
}
|
||||
|
||||
sealed class JobHandlePromise : IUniTaskSource, IPlayerLoopItem
|
||||
{
|
||||
JobHandle jobHandle;
|
||||
CancellationToken cancellationToken;
|
||||
UniTaskStatus status;
|
||||
Action continuation;
|
||||
|
||||
public JobHandleAwaiter(JobHandle jobHandle, CancellationToken cancellationToken, int skipFrame = 2)
|
||||
UniTaskCompletionSourceCore<AsyncUnit> core;
|
||||
|
||||
public static IUniTaskSource Create(JobHandle jobHandle, CancellationToken cancellationToken, out short token)
|
||||
{
|
||||
this.status = cancellationToken.IsCancellationRequested ? UniTaskStatus.Canceled
|
||||
: jobHandle.IsCompleted ? UniTaskStatus.Succeeded
|
||||
: UniTaskStatus.Pending;
|
||||
|
||||
if (this.status.IsCompleted()) return;
|
||||
|
||||
this.jobHandle = jobHandle;
|
||||
this.cancellationToken = cancellationToken;
|
||||
this.status = UniTaskStatus.Pending;
|
||||
this.continuation = null;
|
||||
|
||||
TaskTracker.TrackActiveTask(this, skipFrame);
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return AutoResetUniTaskCompletionSource.CreateFromCanceled(cancellationToken, out token);
|
||||
}
|
||||
|
||||
public bool IsCompleted => status.IsCompleted();
|
||||
// not use pool.
|
||||
var result = new JobHandlePromise();
|
||||
|
||||
public UniTaskStatus Status => status;
|
||||
result.jobHandle = jobHandle;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
public void GetResult()
|
||||
{
|
||||
if (status == UniTaskStatus.Succeeded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (status == UniTaskStatus.Canceled)
|
||||
{
|
||||
Error.ThrowOperationCanceledException();
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
token = result.core.Version;
|
||||
return result;
|
||||
}
|
||||
|
||||
Error.ThrowNotYetCompleted();
|
||||
public void GetResult(short token)
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.GetResult(token);
|
||||
}
|
||||
|
||||
public UniTaskStatus GetStatus(short token)
|
||||
{
|
||||
return core.GetStatus(token);
|
||||
}
|
||||
|
||||
public UniTaskStatus UnsafeGetStatus()
|
||||
{
|
||||
return core.UnsafeGetStatus();
|
||||
}
|
||||
|
||||
public void OnCompleted(Action<object> continuation, object state, short token)
|
||||
{
|
||||
core.OnCompleted(continuation, state, token);
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
// Call jobHandle.Complete after finished.
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.EarlyUpdate, new JobHandleAwaiter(jobHandle, CancellationToken.None, 1));
|
||||
InvokeContinuation(UniTaskStatus.Canceled);
|
||||
core.TrySetCanceled(cancellationToken);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (jobHandle.IsCompleted)
|
||||
{
|
||||
jobHandle.Complete();
|
||||
InvokeContinuation(UniTaskStatus.Succeeded);
|
||||
core.TrySetResult(AsyncUnit.Default);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InvokeContinuation(UniTaskStatus status)
|
||||
{
|
||||
this.status = status;
|
||||
var cont = this.continuation;
|
||||
|
||||
// cleanup
|
||||
TaskTracker.RemoveTracking(this);
|
||||
this.continuation = null;
|
||||
this.cancellationToken = CancellationToken.None;
|
||||
this.jobHandle = default(JobHandle);
|
||||
|
||||
if (cont != null) cont.Invoke();
|
||||
}
|
||||
|
||||
public void OnCompleted(Action continuation)
|
||||
{
|
||||
UnsafeOnCompleted(continuation);
|
||||
}
|
||||
|
||||
public void UnsafeOnCompleted(Action continuation)
|
||||
{
|
||||
Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation);
|
||||
this.continuation = continuation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace UniRx.Async
|
|||
result.progress = progress;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
|
||||
core.GetResult(token);
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ namespace UniRx.Async
|
|||
result.progress = progress;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -289,7 +289,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ namespace UniRx.Async
|
|||
result.progress = progress;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -466,7 +466,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ namespace UniRx.Async
|
|||
result.progress = progress;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -643,7 +643,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ namespace UniRx.Async
|
|||
result.progress = progress;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -821,7 +821,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
|
||||
return core.GetResult(token);
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace UniRx.Async
|
|||
result.progress = progress;
|
||||
result.cancellationToken = cancellationToken;
|
||||
|
||||
TaskTracker2.TrackActiveTask(result, 3);
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
|
||||
|
@ -149,7 +149,7 @@ namespace UniRx.Async
|
|||
{
|
||||
try
|
||||
{
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
|
||||
<# if (!IsVoid(t)) { #>
|
||||
return core.GetResult(token);
|
||||
|
|
|
@ -211,7 +211,7 @@ namespace UniRx.Async
|
|||
registration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, this);
|
||||
}
|
||||
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
}
|
||||
|
||||
public UniTask OnInvokeAsync()
|
||||
|
@ -238,7 +238,7 @@ namespace UniRx.Async
|
|||
if (!isDisposed)
|
||||
{
|
||||
isDisposed = true;
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
registration.Dispose();
|
||||
if (unityEvent != null)
|
||||
{
|
||||
|
@ -317,7 +317,7 @@ namespace UniRx.Async
|
|||
registration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, this);
|
||||
}
|
||||
|
||||
TaskTracker2.TrackActiveTask(this, 3);
|
||||
TaskTracker.TrackActiveTask(this, 3);
|
||||
}
|
||||
|
||||
public UniTask<T> OnInvokeAsync()
|
||||
|
@ -344,7 +344,7 @@ namespace UniRx.Async
|
|||
if (!isDisposed)
|
||||
{
|
||||
isDisposed = true;
|
||||
TaskTracker2.RemoveTracking(this);
|
||||
TaskTracker.RemoveTracking(this);
|
||||
registration.Dispose();
|
||||
if (unityEvent != null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue