mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-24 00:30:11 +00:00
import from UniRx and some modified.
This commit is contained in:
54
Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs
Normal file
54
Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs
Normal file
@@ -0,0 +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.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 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
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae912c37ac7f4cd42b25f22452435103
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/UniRx.Async/Triggers/AsyncAwakeTrigger.cs
Normal file
55
Assets/UniRx.Async/Triggers/AsyncAwakeTrigger.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
#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 UnityEngine;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncAwakeTrigger : MonoBehaviour
|
||||
{
|
||||
bool called = false;
|
||||
UniTaskCompletionSource promise;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
called = true;
|
||||
promise?.TrySetResult();
|
||||
}
|
||||
|
||||
public UniTask AwakeAsync()
|
||||
{
|
||||
if (called) return UniTask.CompletedTask;
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
return new UniTask(promise ?? (promise = new UniTaskCompletionSource()));
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
promise?.TrySetCanceled();
|
||||
}
|
||||
|
||||
class AwakeMonitor : IPlayerLoopItem
|
||||
{
|
||||
readonly AsyncAwakeTrigger trigger;
|
||||
|
||||
public AwakeMonitor(AsyncAwakeTrigger trigger)
|
||||
{
|
||||
this.trigger = trigger;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (trigger.called) return false;
|
||||
if (trigger == null)
|
||||
{
|
||||
trigger.OnDestroy();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/UniRx.Async/Triggers/AsyncAwakeTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncAwakeTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef2840a2586894741a0ae211b8fd669b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onBeginDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onBeginDrags;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onBeginDrag, onBeginDrags);
|
||||
}
|
||||
|
||||
|
||||
void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onBeginDrag, onBeginDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onBeginDrag, ref onBeginDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 171fd2191eb22af4fbd92b51815ca757
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onCancel;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onCancels;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onCancel, onCancels);
|
||||
}
|
||||
|
||||
|
||||
void OnCancel(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onCancel, onCancels, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCancel, ref onCancels, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 291886b6e5f2d044a85b2a4dedcaca97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eddba832648f83046a320ffcacfc771d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs
Normal file
69
Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
#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 OnCollisionEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionEnter2D, ref onCollisionEnter2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionExit2D(Collision2D coll)
|
||||
{
|
||||
TrySetResult(onCollisionExit2D, onCollisionExit2Ds, coll);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnCollisionExit2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionExit2D, ref onCollisionExit2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionStay2D(Collision2D coll)
|
||||
{
|
||||
TrySetResult(onCollisionStay2D, onCollisionStay2Ds, coll);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnCollisionStay2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionStay2D, ref onCollisionStay2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbeb63f69bedec44f8003730887f914b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs
Normal file
69
Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
#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 OnCollisionEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionEnter, ref onCollisionEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionExit(Collision collisionInfo)
|
||||
{
|
||||
TrySetResult(onCollisionExit, onCollisionExits, collisionInfo);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnCollisionExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionExit, ref onCollisionExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionStay(Collision collisionInfo)
|
||||
{
|
||||
TrySetResult(onCollisionStay, onCollisionStays, collisionInfo);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnCollisionStayAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCollisionStay, ref onCollisionStays, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72db4a683be8f6a428823502599014a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onDeselect;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onDeselects;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onDeselect, onDeselects);
|
||||
}
|
||||
|
||||
|
||||
void OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onDeselect, onDeselects, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDeselect, ref onDeselects, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30faa9be5bd883e488bdc52f4825c4da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Assets/UniRx.Async/Triggers/AsyncDestroyTrigger.cs
Normal file
93
Assets/UniRx.Async/Triggers/AsyncDestroyTrigger.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
#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 UniRx.Async.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncDestroyTrigger : MonoBehaviour
|
||||
{
|
||||
bool called = false;
|
||||
UniTaskCompletionSource promise;
|
||||
CancellationTokenSource cancellationTokenSource; // main cancellation
|
||||
object canellationTokenSourceOrQueue; // external from AddCancellationTriggerOnDestory
|
||||
|
||||
public CancellationToken CancellationToken
|
||||
{
|
||||
get
|
||||
{
|
||||
if (cancellationTokenSource == null)
|
||||
{
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
}
|
||||
return cancellationTokenSource.Token;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
void OnDestroy()
|
||||
{
|
||||
called = true;
|
||||
promise?.TrySetResult();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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()));
|
||||
}
|
||||
|
||||
/// <summary>Add Cancellation Triggers on destroy</summary>
|
||||
public void AddCancellationTriggerOnDestory(CancellationTokenSource cts)
|
||||
{
|
||||
if (called)
|
||||
{
|
||||
cts.Cancel();
|
||||
cts.Dispose();
|
||||
}
|
||||
|
||||
if (canellationTokenSourceOrQueue == null)
|
||||
{
|
||||
canellationTokenSourceOrQueue = cts;
|
||||
}
|
||||
else if (canellationTokenSourceOrQueue is CancellationTokenSource c)
|
||||
{
|
||||
var q = new MinimumQueue<CancellationTokenSource>(4);
|
||||
q.Enqueue(c);
|
||||
q.Enqueue(cts);
|
||||
canellationTokenSourceOrQueue = q;
|
||||
}
|
||||
else
|
||||
{
|
||||
((MinimumQueue<CancellationTokenSource>)canellationTokenSourceOrQueue).Enqueue(cts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/UniRx.Async/Triggers/AsyncDestroyTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncDestroyTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4afdcb1cbadf954ba8b1cf465429e17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onDrags;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onDrag, onDrags);
|
||||
}
|
||||
|
||||
|
||||
void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onDrag, onDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDrag, ref onDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52242547ba60ea74f8a2e3bbab5fcdfa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onDrop;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onDrops;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onDrop, onDrops);
|
||||
}
|
||||
|
||||
|
||||
void OnDrop(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onDrop, onDrops, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnDropAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDrop, ref onDrops, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42d65fd5e4be25f41a927eca25b0acf7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/UniRx.Async/Triggers/AsyncEnableDisableTrigger.cs
Normal file
55
Assets/UniRx.Async/Triggers/AsyncEnableDisableTrigger.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0bf9142b63b4cb43b693f0b83b3dbe7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onEndDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onEndDrags;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onEndDrag, onEndDrags);
|
||||
}
|
||||
|
||||
|
||||
void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onEndDrag, onEndDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onEndDrag, ref onEndDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8298d43de348acc4aa4e7dbf30472dbf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
264
Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs
Normal file
264
Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs
Normal file
@@ -0,0 +1,264 @@
|
||||
|
||||
#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 OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDeselect, ref onDeselects, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnMove(AxisEventData eventData)
|
||||
{
|
||||
TrySetResult(onMove, onMoves, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMove, ref onMoves, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerDown, onPointerDowns, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerDown, ref onPointerDowns, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerEnter, onPointerEnters, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerEnter, ref onPointerEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerExit, onPointerExits, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerExit, ref onPointerExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerUp, onPointerUps, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerUp, ref onPointerUps, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onSelect, onSelects, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onSelect, ref onSelects, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerClick, onPointerClicks, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerClick, ref onPointerClicks, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onSubmit, onSubmits, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onSubmit, ref onSubmits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onDrag, onDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDrag, ref onDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onBeginDrag, onBeginDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onBeginDrag, ref onBeginDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onEndDrag, onEndDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onEndDrag, ref onEndDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnDrop(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onDrop, onDrops, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnDropAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onDrop, ref onDrops, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnUpdateSelected(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onUpdateSelected, onUpdateSelecteds, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onUpdateSelected, ref onUpdateSelecteds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnInitializePotentialDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onInitializePotentialDrag, onInitializePotentialDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onInitializePotentialDrag, ref onInitializePotentialDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnCancel(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onCancel, onCancels, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onCancel, ref onCancels, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onScroll, onScrolls, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onScroll, ref onScrolls, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89997820797ad6d43b17971a8bd0d8fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncFixedUpdateTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncFixedUpdateTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncFixedUpdateTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncFixedUpdateTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c74b906c4294aaa4e900f6e7f8b36df6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onInitializePotentialDrag;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onInitializePotentialDrags;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onInitializePotentialDrag, onInitializePotentialDrags);
|
||||
}
|
||||
|
||||
|
||||
void OnInitializePotentialDrag(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onInitializePotentialDrag, onInitializePotentialDrags, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onInitializePotentialDrag, ref onInitializePotentialDrags, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae0733adc239a324f8b934ffb119abd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs
Normal file
55
Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
#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 OnJointBreakAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onJointBreak, ref onJointBreaks, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnJointBreak2D(Joint2D brokenJoint)
|
||||
{
|
||||
TrySetResult(onJointBreak2D, onJointBreak2Ds, brokenJoint);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnJointBreak2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onJointBreak2D, ref onJointBreak2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04dc74e7b2368094f9153921804a1fb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncLateUpdateTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncLateUpdateTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncLateUpdateTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncLateUpdateTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4fb2b4c09cb4ec4a82b934f2038eb36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
129
Assets/UniRx.Async/Triggers/AsyncMouseTrigger.cs
Normal file
129
Assets/UniRx.Async/Triggers/AsyncMouseTrigger.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
|
||||
#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
|
||||
11
Assets/UniRx.Async/Triggers/AsyncMouseTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncMouseTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57ad5120e9c4d424484c963791467272
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<AxisEventData> onMove;
|
||||
AsyncTriggerPromiseDictionary<AxisEventData> onMoves;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onMove, onMoves);
|
||||
}
|
||||
|
||||
|
||||
void OnMove(AxisEventData eventData)
|
||||
{
|
||||
TrySetResult(onMove, onMoves, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onMove, ref onMoves, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1699926e875c24d4aa34bc8817f96f0e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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 OnParticleCollisionAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onParticleCollision, ref onParticleCollisions, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27d3f2efd47fb1d4fb2e9130f97ea8aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerClick;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerClicks;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerClick, onPointerClicks);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerClick, onPointerClicks, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerClick, ref onPointerClicks, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f8865abf2db3d248b3730cdb18bb8b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerDown;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerDowns;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerDown, onPointerDowns);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerDown, onPointerDowns, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerDown, ref onPointerDowns, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c5132395605eaa498a7efedee5acdd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerEnter;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerEnters;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerEnter, onPointerEnters);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerEnter, onPointerEnters, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerEnter, ref onPointerEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18887d476d48533498efd14224a2f651
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerExit;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerExits;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerExit, onPointerExits);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerExit, onPointerExits, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerExit, ref onPointerExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e3ed09876a11a84794795809ebee243
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onPointerUp;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onPointerUps;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onPointerUp, onPointerUps);
|
||||
}
|
||||
|
||||
|
||||
void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onPointerUp, onPointerUps, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onPointerUp, ref onPointerUps, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a0493ea32f81314cbbaf2b635ba3167
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/UniRx.Async/Triggers/AsyncRectTransformTrigger.cs
Normal file
55
Assets/UniRx.Async/Triggers/AsyncRectTransformTrigger.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfe3470221c66c84397c0783c62b24e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<PointerEventData> onScroll;
|
||||
AsyncTriggerPromiseDictionary<PointerEventData> onScrolls;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onScroll, onScrolls);
|
||||
}
|
||||
|
||||
|
||||
void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
TrySetResult(onScroll, onScrolls, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onScroll, ref onScrolls, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c751e9d3deb97d4d8691a8a583c2afd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onSelect;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onSelects;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onSelect, onSelects);
|
||||
}
|
||||
|
||||
|
||||
void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onSelect, onSelects, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onSelect, ref onSelects, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcc2347251a4fc5498a03f0c17382920
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/UniRx.Async/Triggers/AsyncStartTrigger.cs
Normal file
64
Assets/UniRx.Async/Triggers/AsyncStartTrigger.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
#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 UnityEngine;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class AsyncStartTrigger : MonoBehaviour
|
||||
{
|
||||
bool awakeCalled = false;
|
||||
bool called = false;
|
||||
UniTaskCompletionSource promise;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
awakeCalled = true;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
called = true;
|
||||
promise?.TrySetResult();
|
||||
}
|
||||
|
||||
public UniTask StartAsync()
|
||||
{
|
||||
if (called) return UniTask.CompletedTask;
|
||||
if (!awakeCalled)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this));
|
||||
}
|
||||
return new UniTask(promise ?? (promise = new UniTaskCompletionSource()));
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
promise?.TrySetCanceled();
|
||||
}
|
||||
|
||||
class AwakeMonitor : IPlayerLoopItem
|
||||
{
|
||||
readonly AsyncStartTrigger trigger;
|
||||
|
||||
public AwakeMonitor(AsyncStartTrigger trigger)
|
||||
{
|
||||
this.trigger = trigger;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (trigger.awakeCalled) return false;
|
||||
if (trigger == null)
|
||||
{
|
||||
trigger.OnDestroy();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/UniRx.Async/Triggers/AsyncStartTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncStartTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4fd0f75e54ec3d4fbcb7fc65b11646b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onSubmit;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onSubmits;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onSubmit, onSubmits);
|
||||
}
|
||||
|
||||
|
||||
void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onSubmit, onSubmits, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onSubmit, ref onSubmits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97e85abc2d7ec0c44adfbe5ee971aad3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
Assets/UniRx.Async/Triggers/AsyncTransformChangedTrigger.cs
Normal file
69
Assets/UniRx.Async/Triggers/AsyncTransformChangedTrigger.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 053f983cd760f5e4394be8fd657243c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs
Normal file
69
Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
#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 OnTriggerEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerEnter2D, ref onTriggerEnter2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
TrySetResult(onTriggerExit2D, onTriggerExit2Ds, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnTriggerExit2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerExit2D, ref onTriggerExit2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerStay2D(Collider2D other)
|
||||
{
|
||||
TrySetResult(onTriggerStay2D, onTriggerStay2Ds, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnTriggerStay2DAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerStay2D, ref onTriggerStay2Ds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 102f8eba36bc2a54e878e67aca9686e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
271
Assets/UniRx.Async/Triggers/AsyncTriggerBase.cs
Normal file
271
Assets/UniRx.Async/Triggers/AsyncTriggerBase.cs
Normal file
@@ -0,0 +1,271 @@
|
||||
#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.Threading;
|
||||
using UniRx.Async.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Async.Triggers
|
||||
{
|
||||
public interface ICancelablePromise
|
||||
{
|
||||
CancellationToken RegisteredCancellationToken { get; }
|
||||
bool TrySetCanceled();
|
||||
}
|
||||
|
||||
public class AsyncTriggerPromise<T> : ReusablePromise<T>, IPromise<T>, ICancelablePromise
|
||||
{
|
||||
public CancellationToken RegisteredCancellationToken { get; private set; }
|
||||
|
||||
public AsyncTriggerPromise()
|
||||
: this(CancellationToken.None)
|
||||
{
|
||||
}
|
||||
|
||||
public AsyncTriggerPromise(CancellationToken cancellationToken)
|
||||
{
|
||||
this.RegisteredCancellationToken = cancellationToken;
|
||||
TaskTracker.TrackActiveTask(this);
|
||||
}
|
||||
|
||||
public override T GetResult()
|
||||
{
|
||||
if (Status == AwaiterStatus.Pending) return RawResult;
|
||||
return base.GetResult();
|
||||
}
|
||||
|
||||
public override bool TrySetResult(T result)
|
||||
{
|
||||
if (Status == AwaiterStatus.Pending)
|
||||
{
|
||||
// keep status as Pending.
|
||||
this.ForceSetResult(result);
|
||||
TryInvokeContinuation();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool TrySetCanceled()
|
||||
{
|
||||
if (Status == AwaiterStatus.Canceled) return false;
|
||||
TaskTracker.RemoveTracking(this);
|
||||
return base.TrySetCanceled();
|
||||
}
|
||||
}
|
||||
|
||||
public interface ICancellationTokenKeyDictionary
|
||||
{
|
||||
void Remove(CancellationToken token);
|
||||
}
|
||||
|
||||
public class AsyncTriggerPromiseDictionary<TPromiseType> :
|
||||
Dictionary<CancellationToken, AsyncTriggerPromise<TPromiseType>>,
|
||||
ICancellationTokenKeyDictionary,
|
||||
IEnumerable<ICancelablePromise>
|
||||
{
|
||||
public AsyncTriggerPromiseDictionary()
|
||||
: base(CancellationTokenEqualityComparer.Default)
|
||||
{
|
||||
}
|
||||
|
||||
IEnumerator<ICancelablePromise> IEnumerable<ICancelablePromise>.GetEnumerator()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
class AwakeMonitor : IPlayerLoopItem
|
||||
{
|
||||
readonly AsyncTriggerBase trigger;
|
||||
|
||||
public AwakeMonitor(AsyncTriggerBase trigger)
|
||||
{
|
||||
this.trigger = trigger;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (trigger.calledAwake) return false;
|
||||
if (trigger == null)
|
||||
{
|
||||
trigger.OnDestroy();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/UniRx.Async/Triggers/AsyncTriggerBase.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncTriggerBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c0c2bcee832c6641b25949c412f020f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
511
Assets/UniRx.Async/Triggers/AsyncTriggerExtensions.cs
Normal file
511
Assets/UniRx.Async/Triggers/AsyncTriggerExtensions.cs
Normal file
@@ -0,0 +1,511 @@
|
||||
#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 class AsyncTriggerExtensions
|
||||
{
|
||||
// Util.
|
||||
|
||||
static T GetOrAddComponent<T>(GameObject gameObject)
|
||||
where T : Component
|
||||
{
|
||||
var component = gameObject.GetComponent<T>();
|
||||
if (component == null)
|
||||
{
|
||||
component = gameObject.AddComponent<T>();
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
// Special for single operation.
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
public static UniTask OnDestroyAsync(this GameObject gameObject)
|
||||
{
|
||||
return gameObject.GetAsyncDestroyTrigger().OnDestroyAsync();
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
public static UniTask OnDestroyAsync(this Component component)
|
||||
{
|
||||
return component.GetAsyncDestroyTrigger().OnDestroyAsync();
|
||||
}
|
||||
|
||||
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
|
||||
public static CancellationToken GetCancellationTokenOnDestroy(this GameObject gameObject)
|
||||
{
|
||||
return gameObject.GetAsyncDestroyTrigger().CancellationToken;
|
||||
}
|
||||
|
||||
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
|
||||
public static CancellationToken GetCancellationTokenOnDestroy(this Component component)
|
||||
{
|
||||
return component.GetAsyncDestroyTrigger().CancellationToken;
|
||||
}
|
||||
|
||||
public static UniTask StartAsync(this GameObject gameObject)
|
||||
{
|
||||
return gameObject.GetAsyncStartTrigger().StartAsync();
|
||||
}
|
||||
|
||||
public static UniTask StartAsync(this Component component)
|
||||
{
|
||||
return component.GetAsyncStartTrigger().StartAsync();
|
||||
}
|
||||
|
||||
public static UniTask AwakeAsync(this GameObject gameObject)
|
||||
{
|
||||
return gameObject.GetAsyncAwakeTrigger().AwakeAsync();
|
||||
}
|
||||
|
||||
public static UniTask AwakeAsync(this Component component)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/UniRx.Async/Triggers/AsyncTriggerExtensions.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncTriggerExtensions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59b61dbea1562a84fb7a38ae0a0a0f88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs
Normal file
69
Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
#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 OnTriggerEnterAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerEnter, ref onTriggerEnters, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
TrySetResult(onTriggerExit, onTriggerExits, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnTriggerExitAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerExit, ref onTriggerExits, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
void OnTriggerStay(Collider other)
|
||||
{
|
||||
TrySetResult(onTriggerStay, onTriggerStays, other);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnTriggerStayAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onTriggerStay, ref onTriggerStays, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46bbbbaa910762c4786906e10b6b7b8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncUpdateSelectedTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncUpdateSelectedTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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
|
||||
{
|
||||
AsyncTriggerPromise<BaseEventData> onUpdateSelected;
|
||||
AsyncTriggerPromiseDictionary<BaseEventData> onUpdateSelecteds;
|
||||
|
||||
|
||||
protected override IEnumerable<ICancelablePromise> GetPromises()
|
||||
{
|
||||
return Concat(onUpdateSelected, onUpdateSelecteds);
|
||||
}
|
||||
|
||||
|
||||
void OnUpdateSelected(BaseEventData eventData)
|
||||
{
|
||||
TrySetResult(onUpdateSelected, onUpdateSelecteds, eventData);
|
||||
}
|
||||
|
||||
|
||||
public UniTask OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return GetOrAddPromise(ref onUpdateSelected, ref onUpdateSelecteds, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba5b0a4234e164e41b85f10b709d72e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/UniRx.Async/Triggers/AsyncUpdateTrigger.cs
Normal file
41
Assets/UniRx.Async/Triggers/AsyncUpdateTrigger.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#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 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncUpdateTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncUpdateTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6053bbe25af0d6439712f7c5fc4afc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/UniRx.Async/Triggers/AsyncVisibleTrigger.cs
Normal file
55
Assets/UniRx.Async/Triggers/AsyncVisibleTrigger.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
#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
|
||||
|
||||
11
Assets/UniRx.Async/Triggers/AsyncVisibleTrigger.cs.meta
Normal file
11
Assets/UniRx.Async/Triggers/AsyncVisibleTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57ebfef2a87c49c46ad6454db136f3ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user