#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(GameObject gameObject) where T : Component { var component = gameObject.GetComponent(); if (component == null) { component = gameObject.AddComponent(); } return component; } // Special for single operation. /// This function is called when the MonoBehaviour will be destroyed. public static UniTask OnDestroyAsync(this GameObject gameObject) { return gameObject.GetAsyncDestroyTrigger().OnDestroyAsync(); } /// This function is called when the MonoBehaviour will be destroyed. public static UniTask OnDestroyAsync(this Component component) { return component.GetAsyncDestroyTrigger().OnDestroyAsync(); } /// This CancellationToken is canceled when the MonoBehaviour will be destroyed. public static CancellationToken GetCancellationTokenOnDestroy(this GameObject gameObject) { return gameObject.GetAsyncDestroyTrigger().CancellationToken; } /// This CancellationToken is canceled when the MonoBehaviour will be destroyed. 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. /// Get for OnAnimatorIKAsync | OnAnimatorMoveAsync. public static AsyncAnimatorTrigger GetAsyncAnimatorTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnAnimatorIKAsync | OnAnimatorMoveAsync. public static AsyncAnimatorTrigger GetAsyncAnimatorTrigger(this Component component) { return component.gameObject.GetAsyncAnimatorTrigger(); } /// Get for AwakeAsync. public static AsyncAwakeTrigger GetAsyncAwakeTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for AwakeAsync. public static AsyncAwakeTrigger GetAsyncAwakeTrigger(this Component component) { return component.gameObject.GetAsyncAwakeTrigger(); } /// Get for OnBeginDragAsync. public static AsyncBeginDragTrigger GetAsyncBeginDragTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnBeginDragAsync. public static AsyncBeginDragTrigger GetAsyncBeginDragTrigger(this Component component) { return component.gameObject.GetAsyncBeginDragTrigger(); } /// Get for OnCancelAsync. public static AsyncCancelTrigger GetAsyncCancelTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnCancelAsync. public static AsyncCancelTrigger GetAsyncCancelTrigger(this Component component) { return component.gameObject.GetAsyncCancelTrigger(); } /// Get for OnCanvasGroupChangedAsync. public static AsyncCanvasGroupChangedTrigger GetAsyncCanvasGroupChangedTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnCanvasGroupChangedAsync. public static AsyncCanvasGroupChangedTrigger GetAsyncCanvasGroupChangedTrigger(this Component component) { return component.gameObject.GetAsyncCanvasGroupChangedTrigger(); } /// Get for OnCollisionEnter2DAsync | OnCollisionExit2DAsync | OnCollisionStay2DAsync. public static AsyncCollision2DTrigger GetAsyncCollision2DTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnCollisionEnter2DAsync | OnCollisionExit2DAsync | OnCollisionStay2DAsync. public static AsyncCollision2DTrigger GetAsyncCollision2DTrigger(this Component component) { return component.gameObject.GetAsyncCollision2DTrigger(); } /// Get for OnCollisionEnterAsync | OnCollisionExitAsync | OnCollisionStayAsync. public static AsyncCollisionTrigger GetAsyncCollisionTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnCollisionEnterAsync | OnCollisionExitAsync | OnCollisionStayAsync. public static AsyncCollisionTrigger GetAsyncCollisionTrigger(this Component component) { return component.gameObject.GetAsyncCollisionTrigger(); } /// Get for OnDeselectAsync. public static AsyncDeselectTrigger GetAsyncDeselectTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnDeselectAsync. public static AsyncDeselectTrigger GetAsyncDeselectTrigger(this Component component) { return component.gameObject.GetAsyncDeselectTrigger(); } /// Get for OnDestroyAsync. public static AsyncDestroyTrigger GetAsyncDestroyTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnDestroyAsync. public static AsyncDestroyTrigger GetAsyncDestroyTrigger(this Component component) { return component.gameObject.GetAsyncDestroyTrigger(); } /// Get for OnDragAsync. public static AsyncDragTrigger GetAsyncDragTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnDragAsync. public static AsyncDragTrigger GetAsyncDragTrigger(this Component component) { return component.gameObject.GetAsyncDragTrigger(); } /// Get for OnDropAsync. public static AsyncDropTrigger GetAsyncDropTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnDropAsync. public static AsyncDropTrigger GetAsyncDropTrigger(this Component component) { return component.gameObject.GetAsyncDropTrigger(); } /// Get for OnEnableAsync | OnDisableAsync. public static AsyncEnableDisableTrigger GetAsyncEnableDisableTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnEnableAsync | OnDisableAsync. public static AsyncEnableDisableTrigger GetAsyncEnableDisableTrigger(this Component component) { return component.gameObject.GetAsyncEnableDisableTrigger(); } /// Get for OnEndDragAsync. public static AsyncEndDragTrigger GetAsyncEndDragTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnEndDragAsync. public static AsyncEndDragTrigger GetAsyncEndDragTrigger(this Component component) { return component.gameObject.GetAsyncEndDragTrigger(); } /// Get for FixedUpdateAsync. public static AsyncFixedUpdateTrigger GetAsyncFixedUpdateTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for FixedUpdateAsync. public static AsyncFixedUpdateTrigger GetAsyncFixedUpdateTrigger(this Component component) { return component.gameObject.GetAsyncFixedUpdateTrigger(); } /// Get for OnInitializePotentialDragAsync. public static AsyncInitializePotentialDragTrigger GetAsyncInitializePotentialDragTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnInitializePotentialDragAsync. public static AsyncInitializePotentialDragTrigger GetAsyncInitializePotentialDragTrigger(this Component component) { return component.gameObject.GetAsyncInitializePotentialDragTrigger(); } /// Get for OnJointBreakAsync. public static AsyncJointTrigger GetAsyncJointTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnJointBreakAsync. public static AsyncJointTrigger GetAsyncJointTrigger(this Component component) { return component.gameObject.GetAsyncJointTrigger(); } /// Get for LateUpdateAsync. public static AsyncLateUpdateTrigger GetAsyncLateUpdateTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for LateUpdateAsync. public static AsyncLateUpdateTrigger GetAsyncLateUpdateTrigger(this Component component) { return component.gameObject.GetAsyncLateUpdateTrigger(); } #if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO) /// Get for OnMouseDownAsync | OnMouseDragAsync | OnMouseEnterAsync | OnMouseExitAsync | OnMouseOverAsync | OnMouseUpAsync | OnMouseUpAsButtonAsync. public static AsyncMouseTrigger GetAsyncMouseTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnMouseDownAsync | OnMouseDragAsync | OnMouseEnterAsync | OnMouseExitAsync | OnMouseOverAsync | OnMouseUpAsync | OnMouseUpAsButtonAsync. public static AsyncMouseTrigger GetAsyncMouseTrigger(this Component component) { return component.gameObject.GetAsyncMouseTrigger(); } #endif /// Get for OnMoveAsync. public static AsyncMoveTrigger GetAsyncMoveTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnMoveAsync. public static AsyncMoveTrigger GetAsyncMoveTrigger(this Component component) { return component.gameObject.GetAsyncMoveTrigger(); } /// Get for OnParticleCollisionAsync | OnParticleTriggerAsync. public static AsyncParticleTrigger GetAsyncParticleTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnParticleCollisionAsync | OnParticleTriggerAsync. public static AsyncParticleTrigger GetAsyncParticleTrigger(this Component component) { return component.gameObject.GetAsyncParticleTrigger(); } /// Get for OnPointerClickAsync. public static AsyncPointerClickTrigger GetAsyncPointerClickTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnPointerClickAsync. public static AsyncPointerClickTrigger GetAsyncPointerClickTrigger(this Component component) { return component.gameObject.GetAsyncPointerClickTrigger(); } /// Get for OnPointerDownAsync. public static AsyncPointerDownTrigger GetAsyncPointerDownTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnPointerDownAsync. public static AsyncPointerDownTrigger GetAsyncPointerDownTrigger(this Component component) { return component.gameObject.GetAsyncPointerDownTrigger(); } /// Get for OnPointerEnterAsync. public static AsyncPointerEnterTrigger GetAsyncPointerEnterTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnPointerEnterAsync. public static AsyncPointerEnterTrigger GetAsyncPointerEnterTrigger(this Component component) { return component.gameObject.GetAsyncPointerEnterTrigger(); } /// Get for OnPointerExitAsync. public static AsyncPointerExitTrigger GetAsyncPointerExitTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnPointerExitAsync. public static AsyncPointerExitTrigger GetAsyncPointerExitTrigger(this Component component) { return component.gameObject.GetAsyncPointerExitTrigger(); } /// Get for OnPointerUpAsync. public static AsyncPointerUpTrigger GetAsyncPointerUpTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnPointerUpAsync. public static AsyncPointerUpTrigger GetAsyncPointerUpTrigger(this Component component) { return component.gameObject.GetAsyncPointerUpTrigger(); } /// Get for OnRectTransformDimensionsChange | OnRectTransformDimensionsChangeAsync | OnRectTransformRemoved | OnRectTransformRemovedAsync. public static AsyncRectTransformTrigger GetAsyncRectTransformTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnRectTransformDimensionsChange | OnRectTransformDimensionsChangeAsync | OnRectTransformRemoved | OnRectTransformRemovedAsync. public static AsyncRectTransformTrigger GetAsyncRectTransformTrigger(this Component component) { return component.gameObject.GetAsyncRectTransformTrigger(); } /// Get for OnScrollAsync. public static AsyncScrollTrigger GetAsyncScrollTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnScrollAsync. public static AsyncScrollTrigger GetAsyncScrollTrigger(this Component component) { return component.gameObject.GetAsyncScrollTrigger(); } /// Get for OnSelectAsync. public static AsyncSelectTrigger GetAsyncSelectTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnSelectAsync. public static AsyncSelectTrigger GetAsyncSelectTrigger(this Component component) { return component.gameObject.GetAsyncSelectTrigger(); } /// Get for StartAsync. public static AsyncStartTrigger GetAsyncStartTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for StartAsync. public static AsyncStartTrigger GetAsyncStartTrigger(this Component component) { return component.gameObject.GetAsyncStartTrigger(); } /// Get for OnSubmitAsync. public static AsyncSubmitTrigger GetAsyncSubmitTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnSubmitAsync. public static AsyncSubmitTrigger GetAsyncSubmitTrigger(this Component component) { return component.gameObject.GetAsyncSubmitTrigger(); } /// Get for OnBeforeTransformParentChangedAsync | OnTransformParentChangedAsync | OnTransformChildrenChangedAsync. public static AsyncTransformChangedTrigger GetAsyncTransformChangedTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnBeforeTransformParentChangedAsync | OnTransformParentChangedAsync | OnTransformChildrenChangedAsync. public static AsyncTransformChangedTrigger GetAsyncTransformChangedTrigger(this Component component) { return component.gameObject.GetAsyncTransformChangedTrigger(); } /// Get for OnTriggerEnter2DAsync | OnTriggerExit2DAsync | OnTriggerStay2DAsync. public static AsyncTrigger2DTrigger GetAsyncTrigger2DTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnTriggerEnter2DAsync | OnTriggerExit2DAsync | OnTriggerStay2DAsync. public static AsyncTrigger2DTrigger GetAsyncTrigger2DTrigger(this Component component) { return component.gameObject.GetAsyncTrigger2DTrigger(); } /// Get for OnTriggerEnterAsync | OnTriggerExitAsync | OnTriggerStayAsync. public static AsyncTriggerTrigger GetAsyncTriggerTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnTriggerEnterAsync | OnTriggerExitAsync | OnTriggerStayAsync. public static AsyncTriggerTrigger GetAsyncTriggerTrigger(this Component component) { return component.gameObject.GetAsyncTriggerTrigger(); } /// Get for OnUpdateSelectedAsync. public static AsyncUpdateSelectedTrigger GetAsyncUpdateSelectedTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnUpdateSelectedAsync. public static AsyncUpdateSelectedTrigger GetAsyncUpdateSelectedTrigger(this Component component) { return component.gameObject.GetAsyncUpdateSelectedTrigger(); } /// Get for UpdateAsync. public static AsyncUpdateTrigger GetAsyncUpdateTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for UpdateAsync. public static AsyncUpdateTrigger GetAsyncUpdateTrigger(this Component component) { return component.gameObject.GetAsyncUpdateTrigger(); } /// Get for OnBecameInvisibleAsync | OnBecameVisibleAsync. public static AsyncVisibleTrigger GetAsyncVisibleTrigger(this GameObject gameObject) { return GetOrAddComponent(gameObject); } /// Get for OnBecameInvisibleAsync | OnBecameVisibleAsync. public static AsyncVisibleTrigger GetAsyncVisibleTrigger(this Component component) { return component.gameObject.GetAsyncVisibleTrigger(); } } } #endif