From 642cbe6bcd9778ec71e3f1b187361eeb9cb9940f Mon Sep 17 00:00:00 2001 From: neuecc Date: Thu, 30 May 2019 19:41:23 +0900 Subject: [PATCH] ok all --- Assets/Scenes/SandboxMain.cs | 33 +- Assets/Scenes/SandboxMain.unity | 570 ++++++++++++++++++ .../AsyncMethodBuilderAttribute.cs | 2 +- .../UniRx.Async/EnumeratorAsyncExtensions.cs | 106 +++- .../Triggers/AsyncAnimatorTrigger.cs | 2 +- .../Triggers/AsyncBeginDragTrigger.cs | 2 +- .../Triggers/AsyncCancelTrigger.cs | 2 +- .../Triggers/AsyncCollision2DTrigger.cs | 6 +- .../Triggers/AsyncCollisionTrigger.cs | 6 +- .../Triggers/AsyncDeselectTrigger.cs | 2 +- .../UniRx.Async/Triggers/AsyncDragTrigger.cs | 2 +- .../UniRx.Async/Triggers/AsyncDropTrigger.cs | 2 +- .../Triggers/AsyncEndDragTrigger.cs | 2 +- .../UniRx.Async/Triggers/AsyncEventTrigger.cs | 34 +- .../AsyncInitializePotentialDragTrigger.cs | 2 +- .../UniRx.Async/Triggers/AsyncJointTrigger.cs | 4 +- .../UniRx.Async/Triggers/AsyncMoveTrigger.cs | 2 +- .../Triggers/AsyncParticleTrigger.cs | 2 +- .../Triggers/AsyncPointerClickTrigger.cs | 2 +- .../Triggers/AsyncPointerDownTrigger.cs | 2 +- .../Triggers/AsyncPointerEnterTrigger.cs | 2 +- .../Triggers/AsyncPointerExitTrigger.cs | 2 +- .../Triggers/AsyncPointerUpTrigger.cs | 2 +- .../Triggers/AsyncScrollTrigger.cs | 2 +- .../Triggers/AsyncSelectTrigger.cs | 2 +- .../Triggers/AsyncSubmitTrigger.cs | 2 +- .../Triggers/AsyncTrigger2DTrigger.cs | 6 +- .../Triggers/AsyncTriggerTrigger.cs | 6 +- .../Triggers/AsyncUpdateSelectedTrigger.cs | 2 +- Assets/UniRx.Async/UnityAsyncExtensions.cs | 20 +- ProjectSettings/Physics2DSettings.asset | Bin 4448 -> 2028 bytes 31 files changed, 765 insertions(+), 66 deletions(-) diff --git a/Assets/Scenes/SandboxMain.cs b/Assets/Scenes/SandboxMain.cs index 158da1d2..201a91bf 100644 --- a/Assets/Scenes/SandboxMain.cs +++ b/Assets/Scenes/SandboxMain.cs @@ -1,20 +1,33 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Threading; using UniRx.Async; using UnityEngine; +using UnityEngine.Networking; +using UnityEngine.UI; public class SandboxMain : MonoBehaviour { - // Start is called before the first frame update - void Start() - { - RunAsync().Forget(); - } + public Button okButton; + public Button cancelButton; + CancellationTokenSource cts; - async UniTaskVoid RunAsync() + async void Start() { - var id = await UniTask.Run(() => System.Threading.Thread.CurrentThread.ManagedThreadId, configureAwait: false); - UnityEngine.Debug.Log("ReturnId:" + id); - UnityEngine.Debug.Log("CurrentId:" + System.Threading.Thread.CurrentThread.ManagedThreadId); + await UniTask.CompletedTask; // ok + + // var subject = new Subject(); + //subject.OnCompleted(); + IObservable subject = default; + try + { + await subject.ToUniTask(); // exception + } + catch (Exception exception) + { + Debug.Log(exception); + } } } + diff --git a/Assets/Scenes/SandboxMain.unity b/Assets/Scenes/SandboxMain.unity index c1335141..59e79064 100644 --- a/Assets/Scenes/SandboxMain.unity +++ b/Assets/Scenes/SandboxMain.unity @@ -120,6 +120,127 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &16537670 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 16537671} + - component: {fileID: 16537674} + - component: {fileID: 16537673} + - component: {fileID: 16537672} + m_Layer: 0 + m_Name: StartButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &16537671 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 16537670} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1584557232} + m_Father: {fileID: 1556045508} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -7, y: 226} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &16537672 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 16537670} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 16537673} + m_OnClick: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &16537673 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 16537670} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &16537674 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 16537670} + m_CullTransparentMesh: 0 --- !u!1 &519420028 GameObject: m_ObjectHideFlags: 0 @@ -159,6 +280,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f0bc6c75abb2e0b47a25aa49bfd488ed, type: 3} m_Name: m_EditorClassIdentifier: + okButton: {fileID: 16537672} + cancelButton: {fileID: 628393011} --- !u!20 &519420031 Camera: m_ObjectHideFlags: 0 @@ -216,3 +339,450 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &628393009 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 628393010} + - component: {fileID: 628393013} + - component: {fileID: 628393012} + - component: {fileID: 628393011} + m_Layer: 0 + m_Name: CancelButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &628393010 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 628393009} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 865871445} + m_Father: {fileID: 1556045508} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -4.9, y: 179} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &628393011 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 628393009} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 628393012} + m_OnClick: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &628393012 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 628393009} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &628393013 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 628393009} + m_CullTransparentMesh: 0 +--- !u!1 &865871444 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 865871445} + - component: {fileID: 865871447} + - component: {fileID: 865871446} + m_Layer: 0 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &865871445 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 865871444} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 628393010} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &865871446 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 865871444} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Cancel +--- !u!222 &865871447 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 865871444} + m_CullTransparentMesh: 0 +--- !u!1 &872009839 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 872009842} + - component: {fileID: 872009841} + - component: {fileID: 872009840} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &872009840 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 872009839} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &872009841 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 872009839} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &872009842 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 872009839} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1556045504 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1556045508} + - component: {fileID: 1556045507} + - component: {fileID: 1556045506} + - component: {fileID: 1556045505} + m_Layer: 0 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1556045505 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1556045504} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1556045506 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1556045504} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &1556045507 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1556045504} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1556045508 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1556045504} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 16537671} + - {fileID: 628393010} + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &1584557231 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1584557232} + - component: {fileID: 1584557234} + - component: {fileID: 1584557233} + m_Layer: 0 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1584557232 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1584557231} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 16537671} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1584557233 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1584557231} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Start + +' +--- !u!222 &1584557234 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1584557231} + m_CullTransparentMesh: 0 diff --git a/Assets/UniRx.Async/CompilerServices/AsyncMethodBuilderAttribute.cs b/Assets/UniRx.Async/CompilerServices/AsyncMethodBuilderAttribute.cs index b9658c95..06528cfa 100644 --- a/Assets/UniRx.Async/CompilerServices/AsyncMethodBuilderAttribute.cs +++ b/Assets/UniRx.Async/CompilerServices/AsyncMethodBuilderAttribute.cs @@ -4,7 +4,7 @@ namespace System.Runtime.CompilerServices { - public sealed class AsyncMethodBuilderAttribute : Attribute + internal sealed class AsyncMethodBuilderAttribute : Attribute { public Type BuilderType { get; } diff --git a/Assets/UniRx.Async/EnumeratorAsyncExtensions.cs b/Assets/UniRx.Async/EnumeratorAsyncExtensions.cs index 5f3411e5..2d3114a8 100644 --- a/Assets/UniRx.Async/EnumeratorAsyncExtensions.cs +++ b/Assets/UniRx.Async/EnumeratorAsyncExtensions.cs @@ -3,9 +3,11 @@ using System; using System.Collections; +using System.Reflection; using System.Runtime.ExceptionServices; using System.Threading; using UniRx.Async.Internal; +using UnityEngine; namespace UniRx.Async { @@ -57,7 +59,7 @@ public EnumeratorAwaiter(IEnumerator innerEnumerator, CancellationToken cancella return; } - this.innerEnumerator = innerEnumerator; + this.innerEnumerator = ConsumeEnumerator(innerEnumerator); this.status = AwaiterStatus.Pending; this.cancellationToken = cancellationToken; this.continuation = null; @@ -142,6 +144,108 @@ public void UnsafeOnCompleted(Action continuation) Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); this.continuation = continuation; } + + // Unwrap YieldInstructions + + static IEnumerator ConsumeEnumerator(IEnumerator enumerator) + { + while (enumerator.MoveNext()) + { + var current = enumerator.Current; + if (current == null) + { + yield return null; + } + else if (current is CustomYieldInstruction) + { + // WWW, WaitForSecondsRealtime + var e2 = UnwrapWaitCustomYieldInstruction((CustomYieldInstruction)current); + while (e2.MoveNext()) + { + yield return null; + } + } + else if (current is YieldInstruction) + { + IEnumerator innerCoroutine = null; + switch (current) + { + case AsyncOperation ao: + innerCoroutine = UnwrapWaitAsyncOperation(ao); + break; + case WaitForSeconds wfs: + innerCoroutine = UnwrapWaitForSeconds(wfs); + break; + } + if (innerCoroutine != null) + { + while (innerCoroutine.MoveNext()) + { + yield return null; + } + } + else + { + yield return null; + } + } + else if (current is IEnumerator e3) + { + while (e3.MoveNext()) + { + yield return null; + } + } + else + { + // WaitForEndOfFrame, WaitForFixedUpdate, others. + yield return null; + } + } + } + + // WWW and others as CustomYieldInstruction. + static IEnumerator UnwrapWaitCustomYieldInstruction(CustomYieldInstruction yieldInstruction) + { + while (yieldInstruction.keepWaiting) + { + yield return null; + } + } + + static readonly FieldInfo waitForSeconds_Seconds = typeof(WaitForSeconds).GetField("m_Seconds", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic); + + static IEnumerator UnwrapWaitForSeconds(WaitForSeconds waitForSeconds) + { + var second = (float)waitForSeconds_Seconds.GetValue(waitForSeconds); + var startTime = DateTimeOffset.UtcNow; + while (true) + { + yield return null; + + var elapsed = (DateTimeOffset.UtcNow - startTime).TotalSeconds; + if (elapsed >= second) + { + break; + } + }; + } + + static IEnumerator UnwrapEnumerator(IEnumerator enumerator) + { + while (enumerator.MoveNext()) + { + yield return null; + } + } + + static IEnumerator UnwrapWaitAsyncOperation(AsyncOperation asyncOperation) + { + while (!asyncOperation.isDone) + { + yield return null; + } + } } } } diff --git a/Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs index 00b66cb3..2a294d71 100644 --- a/Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs @@ -29,7 +29,7 @@ void OnAnimatorIK(int layerIndex) } - public UniTask OnAnimatorIKAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnAnimatorIKAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onAnimatorIK, ref onAnimatorIKs, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs index bef10376..e17664be 100644 --- a/Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs @@ -28,7 +28,7 @@ void OnBeginDrag(PointerEventData eventData) } - public UniTask OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onBeginDrag, ref onBeginDrags, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs index f484e598..f397ddef 100644 --- a/Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs @@ -28,7 +28,7 @@ void OnCancel(BaseEventData eventData) } - public UniTask OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onCancel, ref onCancels, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs index c3f0c9cb..0f0b7479 100644 --- a/Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs @@ -32,7 +32,7 @@ void OnCollisionEnter2D(Collision2D coll) } - public UniTask OnCollisionEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnCollisionEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onCollisionEnter2D, ref onCollisionEnter2Ds, cancellationToken); } @@ -44,7 +44,7 @@ void OnCollisionExit2D(Collision2D coll) } - public UniTask OnCollisionExit2DAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnCollisionExit2DAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onCollisionExit2D, ref onCollisionExit2Ds, cancellationToken); } @@ -56,7 +56,7 @@ void OnCollisionStay2D(Collision2D coll) } - public UniTask OnCollisionStay2DAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnCollisionStay2DAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onCollisionStay2D, ref onCollisionStay2Ds, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs index 3534c698..71306df9 100644 --- a/Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs @@ -32,7 +32,7 @@ void OnCollisionEnter(Collision collision) } - public UniTask OnCollisionEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnCollisionEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onCollisionEnter, ref onCollisionEnters, cancellationToken); } @@ -44,7 +44,7 @@ void OnCollisionExit(Collision collisionInfo) } - public UniTask OnCollisionExitAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnCollisionExitAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onCollisionExit, ref onCollisionExits, cancellationToken); } @@ -56,7 +56,7 @@ void OnCollisionStay(Collision collisionInfo) } - public UniTask OnCollisionStayAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnCollisionStayAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onCollisionStay, ref onCollisionStays, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs index 18ac7d0d..e1e7ce43 100644 --- a/Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs @@ -28,7 +28,7 @@ void OnDeselect(BaseEventData eventData) } - public UniTask OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onDeselect, ref onDeselects, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs index 46ad8d98..b1e4d566 100644 --- a/Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs @@ -28,7 +28,7 @@ void OnDrag(PointerEventData eventData) } - public UniTask OnDragAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnDragAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onDrag, ref onDrags, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs index 8993952f..7042c4d3 100644 --- a/Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs @@ -28,7 +28,7 @@ void OnDrop(PointerEventData eventData) } - public UniTask OnDropAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnDropAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onDrop, ref onDrops, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs index cbaa8235..2b4ce34f 100644 --- a/Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs @@ -28,7 +28,7 @@ void OnEndDrag(PointerEventData eventData) } - public UniTask OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onEndDrag, ref onEndDrags, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs index 218fedc9..17568d22 100644 --- a/Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs @@ -59,7 +59,7 @@ void OnDeselect(BaseEventData eventData) } - public UniTask OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onDeselect, ref onDeselects, cancellationToken); } @@ -71,7 +71,7 @@ void OnMove(AxisEventData eventData) } - public UniTask OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onMove, ref onMoves, cancellationToken); } @@ -83,7 +83,7 @@ void OnPointerDown(PointerEventData eventData) } - public UniTask OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerDown, ref onPointerDowns, cancellationToken); } @@ -95,7 +95,7 @@ void OnPointerEnter(PointerEventData eventData) } - public UniTask OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerEnter, ref onPointerEnters, cancellationToken); } @@ -107,7 +107,7 @@ void OnPointerExit(PointerEventData eventData) } - public UniTask OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerExit, ref onPointerExits, cancellationToken); } @@ -119,7 +119,7 @@ void OnPointerUp(PointerEventData eventData) } - public UniTask OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerUp, ref onPointerUps, cancellationToken); } @@ -131,7 +131,7 @@ void OnSelect(BaseEventData eventData) } - public UniTask OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onSelect, ref onSelects, cancellationToken); } @@ -143,7 +143,7 @@ void OnPointerClick(PointerEventData eventData) } - public UniTask OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerClick, ref onPointerClicks, cancellationToken); } @@ -155,7 +155,7 @@ void OnSubmit(BaseEventData eventData) } - public UniTask OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onSubmit, ref onSubmits, cancellationToken); } @@ -167,7 +167,7 @@ void OnDrag(PointerEventData eventData) } - public UniTask OnDragAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnDragAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onDrag, ref onDrags, cancellationToken); } @@ -179,7 +179,7 @@ void OnBeginDrag(PointerEventData eventData) } - public UniTask OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onBeginDrag, ref onBeginDrags, cancellationToken); } @@ -191,7 +191,7 @@ void OnEndDrag(PointerEventData eventData) } - public UniTask OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onEndDrag, ref onEndDrags, cancellationToken); } @@ -203,7 +203,7 @@ void OnDrop(PointerEventData eventData) } - public UniTask OnDropAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnDropAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onDrop, ref onDrops, cancellationToken); } @@ -215,7 +215,7 @@ void OnUpdateSelected(BaseEventData eventData) } - public UniTask OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onUpdateSelected, ref onUpdateSelecteds, cancellationToken); } @@ -227,7 +227,7 @@ void OnInitializePotentialDrag(PointerEventData eventData) } - public UniTask OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onInitializePotentialDrag, ref onInitializePotentialDrags, cancellationToken); } @@ -239,7 +239,7 @@ void OnCancel(BaseEventData eventData) } - public UniTask OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onCancel, ref onCancels, cancellationToken); } @@ -251,7 +251,7 @@ void OnScroll(PointerEventData eventData) } - public UniTask OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onScroll, ref onScrolls, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncInitializePotentialDragTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncInitializePotentialDragTrigger.cs index 59e04b4b..4334b4e4 100644 --- a/Assets/UniRx.Async/Triggers/AsyncInitializePotentialDragTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncInitializePotentialDragTrigger.cs @@ -28,7 +28,7 @@ void OnInitializePotentialDrag(PointerEventData eventData) } - public UniTask OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onInitializePotentialDrag, ref onInitializePotentialDrags, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs index 9321182f..bf334076 100644 --- a/Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs @@ -30,7 +30,7 @@ void OnJointBreak(float breakForce) } - public UniTask OnJointBreakAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnJointBreakAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onJointBreak, ref onJointBreaks, cancellationToken); } @@ -42,7 +42,7 @@ void OnJointBreak2D(Joint2D brokenJoint) } - public UniTask OnJointBreak2DAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnJointBreak2DAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onJointBreak2D, ref onJointBreak2Ds, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs index cab098c9..6066c8dc 100644 --- a/Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs @@ -28,7 +28,7 @@ void OnMove(AxisEventData eventData) } - public UniTask OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onMove, ref onMoves, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs index 4e22b36a..284461ac 100644 --- a/Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs @@ -28,7 +28,7 @@ void OnParticleCollision(GameObject other) } - public UniTask OnParticleCollisionAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnParticleCollisionAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onParticleCollision, ref onParticleCollisions, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs index 64b902d3..5a9167a1 100644 --- a/Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs @@ -28,7 +28,7 @@ void OnPointerClick(PointerEventData eventData) } - public UniTask OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerClick, ref onPointerClicks, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs index 2e32bfcd..12cb568e 100644 --- a/Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs @@ -28,7 +28,7 @@ void OnPointerDown(PointerEventData eventData) } - public UniTask OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerDown, ref onPointerDowns, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs index 36ed2e33..2532079e 100644 --- a/Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs @@ -28,7 +28,7 @@ void OnPointerEnter(PointerEventData eventData) } - public UniTask OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerEnter, ref onPointerEnters, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs index 3cf25753..29063d42 100644 --- a/Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs @@ -28,7 +28,7 @@ void OnPointerExit(PointerEventData eventData) } - public UniTask OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerExit, ref onPointerExits, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs index 4f56fa94..1eb0b926 100644 --- a/Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs @@ -28,7 +28,7 @@ void OnPointerUp(PointerEventData eventData) } - public UniTask OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onPointerUp, ref onPointerUps, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs index 7a28c646..363a25ad 100644 --- a/Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs @@ -28,7 +28,7 @@ void OnScroll(PointerEventData eventData) } - public UniTask OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onScroll, ref onScrolls, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs index 093ec79f..1a98f9df 100644 --- a/Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs @@ -28,7 +28,7 @@ void OnSelect(BaseEventData eventData) } - public UniTask OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onSelect, ref onSelects, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs index 0dd4206a..ff9b17d5 100644 --- a/Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs @@ -28,7 +28,7 @@ void OnSubmit(BaseEventData eventData) } - public UniTask OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onSubmit, ref onSubmits, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs index dc334159..fb3cfe58 100644 --- a/Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs @@ -32,7 +32,7 @@ void OnTriggerEnter2D(Collider2D other) } - public UniTask OnTriggerEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnTriggerEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onTriggerEnter2D, ref onTriggerEnter2Ds, cancellationToken); } @@ -44,7 +44,7 @@ void OnTriggerExit2D(Collider2D other) } - public UniTask OnTriggerExit2DAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnTriggerExit2DAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onTriggerExit2D, ref onTriggerExit2Ds, cancellationToken); } @@ -56,7 +56,7 @@ void OnTriggerStay2D(Collider2D other) } - public UniTask OnTriggerStay2DAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnTriggerStay2DAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onTriggerStay2D, ref onTriggerStay2Ds, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs index 22f3c947..8ee5d625 100644 --- a/Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs @@ -32,7 +32,7 @@ void OnTriggerEnter(Collider other) } - public UniTask OnTriggerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnTriggerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onTriggerEnter, ref onTriggerEnters, cancellationToken); } @@ -44,7 +44,7 @@ void OnTriggerExit(Collider other) } - public UniTask OnTriggerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnTriggerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onTriggerExit, ref onTriggerExits, cancellationToken); } @@ -56,7 +56,7 @@ void OnTriggerStay(Collider other) } - public UniTask OnTriggerStayAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnTriggerStayAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onTriggerStay, ref onTriggerStays, cancellationToken); } diff --git a/Assets/UniRx.Async/Triggers/AsyncUpdateSelectedTrigger.cs b/Assets/UniRx.Async/Triggers/AsyncUpdateSelectedTrigger.cs index 5f7536e3..fcb81f69 100644 --- a/Assets/UniRx.Async/Triggers/AsyncUpdateSelectedTrigger.cs +++ b/Assets/UniRx.Async/Triggers/AsyncUpdateSelectedTrigger.cs @@ -28,7 +28,7 @@ void OnUpdateSelected(BaseEventData eventData) } - public UniTask OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken)) + public UniTask OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken)) { return GetOrAddPromise(ref onUpdateSelected, ref onUpdateSelecteds, cancellationToken); } diff --git a/Assets/UniRx.Async/UnityAsyncExtensions.cs b/Assets/UniRx.Async/UnityAsyncExtensions.cs index 0005ca73..7d7f0a8d 100644 --- a/Assets/UniRx.Async/UnityAsyncExtensions.cs +++ b/Assets/UniRx.Async/UnityAsyncExtensions.cs @@ -168,13 +168,16 @@ public void GetResult() } } - asyncOperation = null; // remove reference. - if (continuationAction != null) { asyncOperation.completed -= continuationAction; + asyncOperation = null; // remove reference. continuationAction = null; } + else + { + asyncOperation = null; // remove reference. + } } public void OnCompleted(Action continuation) @@ -316,13 +319,17 @@ public UnityEngine.Object GetResult() } this.result = asyncOperation.asset; - asyncOperation = null; // remove reference. if (continuationAction != null) { asyncOperation.completed -= continuationAction; + asyncOperation = null; // remove reference. continuationAction = null; } + else + { + asyncOperation = null; // remove reference. + } return this.result; } @@ -576,13 +583,18 @@ public UnityWebRequest GetResult() } this.result = asyncOperation.webRequest; - asyncOperation = null; // remove reference. if (continuationAction != null) { asyncOperation.completed -= continuationAction; + asyncOperation = null; // remove reference. continuationAction = null; } + else + { + asyncOperation = null; // remove reference. + } + return this.result; } diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset index 71e598122cc35abfe2ba430bdda9b917083f46c4..6c5cf8a004ac48f27cb36f7cdea139eb4d3e812f 100644 GIT binary patch literal 2028 zcmd^A%WmQ@6y5U`?xM2-L;{q@E`VsMO6fFArCA}981U4wk?oYy(fs>dKN3SH@?CL*hctsofI8jXfQg8}*$)Sh-n zMH3ZHVxl$WTQ#g9l&u!)UnJ3YG$m7p;SsgqSrJJwqaP%FAyQGnhp1!Ow-UcWlp*^4 z4$L}&{~Cj4Klo$O3EAMB={eTc9#|X7$ZP^sM|dGjBw#-S0@mOc;`OcRlTg$=RFSqt z3Y+Cl615X79iqSjbNv25Il*!)q=Xu5nyqG7fDzy3>@(_Of#FhOu9!_B-Vm z3I;9ViS^rZ1^NQcaaW-4^;mEX;TD^XBHDQNw)bMa*t-rx{EHJceh|tPnZwMehW6qV zbOBBZ0GunTG~vlH7Sf2O0JGJM!wmPr^$?~<)Dw{qwdkbjYzV6mGgj3Wj9jQ=W@l zeMy^Ao<2e@MCq@y{jpC$^-D>&TLOZ#Ln$MkikgAwcp3}#W>`vBMO{``C7B`((d)?w z!!)2u@zJWRqQWZeUQiANoLpTZK{$G$Q&m6b#o2adt0>nZrWtIUTSO<}?>SroqVA~n zt$~IAgv1&)YR0`9WC@QkV{4qess)ER;&`(P&h>dtM}^IFx6=Eo~7vI^b7RgOG3| z;TI0VP5&nBb?eBiSaVQ*gna_A(`^mv&)Vgj4}RSBqTVC~G&D5K!_p5sK z>ecIy5n|1V5NnSMA=V3VD}IE??cTGme{cV8J172{pP#oZ=x!&NpI<$9`PkOiu9k<- zU5*aCa%}q$v~$-8fv+r22$5jQyzC^Yj?%*C+)9yrY>9+pX_8eJ@}IzOgW?9%6%zDG zNnt^A7PdE`&G{>-6n#=sXucV3^3$zYHb$jai5`Irn#3@l^)?p5m(wd`@xhFxkCGCB6SC8`XNd&TdPB$1Lr^WPM|TarXd3e8vG!l3<)k|a`6Xue)?UMJX&loXopRQw)E z5-BM(A5xsx(Q@-$#qTxnQ;PQ)`1^|AXW(Bbe!qeLsQ4BGzpD6F1K)rf2jlmEf#(!| zu!mbRKSsfEL}HudUBUcg{v20)dl$);=556vGVnJQf7rl3Q2Y@C|6K7M2L7$$JHeOU zzv%z3iuW7%pNj7?@O20-Y&_4fnv-jS313}jlEpJ&0V zYW`lREpbLswo^W)_@f41SNt&pKdSiSJ=_xX?-)4!!*g!g^|gO|&is>q`wU$B_mqKa z|MvIr)IVSOcc6zaj^EP;uH(mhJ@akkIavM=@u;#?E>$f5?_2Qw>KIz6CF)KQvT8+a4YS4%sJE3cPxxs@NHRw#( zZ7!IyOo?NFk?KsNBSP(B#4cP6emL0}Utzml(3@#|@?vyh+ zQJI>y8?lDe)q|SnIMW!Kx+8n_z{8&W1}!Lmdh{wprNED2a&%%Ma$=!^ITVbKPRo$w z7_x3xv?FH(fpueq!fxVBsDX{hjbg`dbZSA!lftBmkGM_;>6Q^zC#pIjECC&HX4JA> zT`BN9w@FiUC!_Zer|izgZJgG^nuIj&`t6_{ z_29DWH;-T?CyIMqcy79hzok%$#v9ZX14vORCy zZk&ileFWMbmnk~t$P~cwMYsqShG4i{4sn;cKM{mev{CeC>`qjh43Goz$ff0MUng`{ zr^5~dS#_~EFhIZ3Ln($~Fr(wEtrutP6G$sB2t_DbVqDmALb`M@;>D9vnn|?_$H7Tm zH5b!EhwToJTWuQmnb4h;cQ$!{%iiRUXFHjj-~Y}3egwX}vgu;hOa6hyyBzw!F&{KX4}e767T`Sb88p${lYe(s}PXtST{UQLpNeIR^T|C{A+@lq#i