From 5aaeb13c5d98486f71303b6f73d999031f3e1d1c Mon Sep 17 00:00:00 2001 From: Yoshifumi Kawai Date: Mon, 20 May 2019 00:14:47 +0900 Subject: [PATCH] import from UniRx and some modified. --- .gitignore | 156 +- Assets/RuntimeUnitTestToolkit.meta | 8 + Assets/RuntimeUnitTestToolkit/Editor.meta | 8 + .../Editor/HierarchyTreeBuilder.cs | 133 ++ .../Editor/HierarchyTreeBuilder.cs.meta | 11 + .../Editor/UnitTestBuilder.MenuItems.cs | 341 +++ .../Editor/UnitTestBuilder.MenuItems.cs.meta | 11 + .../Editor/UnitTestBuilder.cs | 515 +++++ .../Editor/UnitTestBuilder.cs.meta | 12 + .../RuntimeUnitTestToolkit.asmdef | 16 + .../RuntimeUnitTestToolkit.asmdef.meta | 7 + .../RuntimeUnitTestToolkit/UnitTestRunner.cs | 450 ++++ .../UnitTestRunner.cs.meta | 12 + Assets/RuntimeUnitTestToolkit/package.json | 11 + .../RuntimeUnitTestToolkit/package.json.meta | 7 + Assets/Scenes.meta | 8 + Assets/Scenes/SandboxMain.cs | 20 + Assets/Scenes/SandboxMain.cs.meta | 11 + Assets/Scenes/SandboxMain.unity | 218 ++ Assets/Scenes/SandboxMain.unity.meta | 7 + Assets/Tests.meta | 8 + Assets/Tests/AsyncTest.cs | 384 ++++ Assets/Tests/AsyncTest.cs.meta | 11 + Assets/Tests/RunTest.cs | 96 + Assets/Tests/RunTest.cs.meta | 11 + Assets/Tests/Shims.cs | 144 ++ Assets/Tests/Shims.cs.meta | 11 + Assets/Tests/UniRx.Async.Tests.asmdef | 20 + Assets/Tests/UniRx.Async.Tests.asmdef.meta | 7 + Assets/Tests/WhenAnyTest.cs | 44 + Assets/Tests/WhenAnyTest.cs.meta | 11 + Assets/UniRx.Async.meta | 8 + Assets/UniRx.Async/AsyncUnit.cs | 28 + Assets/UniRx.Async/AsyncUnit.cs.meta | 11 + .../CancellationTokenEqualityComparer.cs | 25 + .../CancellationTokenEqualityComparer.cs.meta | 11 + .../CancellationTokenExtensions.cs | 76 + .../CancellationTokenExtensions.cs.meta | 11 + .../CancellationTokenSourceExtensions.cs | 48 + .../CancellationTokenSourceExtensions.cs.meta | 11 + Assets/UniRx.Async/CompilerServices.meta | 8 + .../AsyncMethodBuilderAttribute.cs | 18 + .../AsyncMethodBuilderAttribute.cs.meta | 11 + .../AsyncUniTaskMethodBuilder.cs | 274 +++ .../AsyncUniTaskMethodBuilder.cs.meta | 11 + .../AsyncUniTaskVoidMethodBuilder.cs | 90 + .../AsyncUniTaskVoidMethodBuilder.cs.meta | 11 + .../CompilerServices/MoveNextRunner.cs | 23 + .../CompilerServices/MoveNextRunner.cs.meta | 11 + Assets/UniRx.Async/DiagnosticsExtensions.cs | 270 +++ .../UniRx.Async/DiagnosticsExtensions.cs.meta | 11 + Assets/UniRx.Async/Editor.meta | 8 + .../UniRx.Async/Editor/SplitterGUILayout.cs | 64 + .../Editor/SplitterGUILayout.cs.meta | 11 + .../Editor/UniRx.Async.Editor.asmdef | 16 + .../Editor/UniRx.Async.Editor.asmdef.meta | 7 + .../Editor/UniTaskTrackerTreeView.cs | 180 ++ .../Editor/UniTaskTrackerTreeView.cs.meta | 11 + .../Editor/UniTaskTrackerWindow.cs | 211 ++ .../Editor/UniTaskTrackerWindow.cs.meta | 11 + .../UniRx.Async/EnumerableAsyncExtensions.cs | 36 + .../EnumerableAsyncExtensions.cs.meta | 11 + .../UniRx.Async/EnumeratorAsyncExtensions.cs | 149 ++ .../EnumeratorAsyncExtensions.cs.meta | 11 + Assets/UniRx.Async/ExceptionExtensions.cs | 16 + .../UniRx.Async/ExceptionExtensions.cs.meta | 11 + Assets/UniRx.Async/IAwaiter.cs | 64 + Assets/UniRx.Async/IAwaiter.cs.meta | 11 + Assets/UniRx.Async/Internal.meta | 8 + Assets/UniRx.Async/Internal/ArrayPool.cs | 152 ++ Assets/UniRx.Async/Internal/ArrayPool.cs.meta | 12 + Assets/UniRx.Async/Internal/ArrayPoolUtil.cs | 112 + .../Internal/ArrayPoolUtil.cs.meta | 12 + Assets/UniRx.Async/Internal/ArrayUtil.cs | 75 + Assets/UniRx.Async/Internal/ArrayUtil.cs.meta | 12 + .../Internal/CancellationTokenHelper.cs | 32 + .../Internal/CancellationTokenHelper.cs.meta | 11 + .../UniRx.Async/Internal/ContinuationQueue.cs | 115 + .../Internal/ContinuationQueue.cs.meta | 11 + Assets/UniRx.Async/Internal/Error.cs | 63 + Assets/UniRx.Async/Internal/Error.cs.meta | 12 + Assets/UniRx.Async/Internal/Hack.cs | 23 + Assets/UniRx.Async/Internal/Hack.cs.meta | 11 + Assets/UniRx.Async/Internal/LazyPromise.cs | 130 ++ .../UniRx.Async/Internal/LazyPromise.cs.meta | 11 + Assets/UniRx.Async/Internal/MinimumQueue.cs | 122 ++ .../UniRx.Async/Internal/MinimumQueue.cs.meta | 11 + .../UniRx.Async/Internal/PlayerLoopRunner.cs | 153 ++ .../Internal/PlayerLoopRunner.cs.meta | 11 + Assets/UniRx.Async/Internal/PromiseHelper.cs | 34 + .../Internal/PromiseHelper.cs.meta | 11 + .../UniRx.Async/Internal/ReusablePromise.cs | 395 ++++ .../Internal/ReusablePromise.cs.meta | 11 + .../Internal/RuntimeHelpersAbstraction.cs | 60 + .../RuntimeHelpersAbstraction.cs.meta | 12 + Assets/UniRx.Async/Internal/TaskTracker.cs | 152 ++ .../UniRx.Async/Internal/TaskTracker.cs.meta | 11 + .../Internal/UnityEqualityComparer.cs | 271 +++ .../Internal/UnityEqualityComparer.cs.meta | 11 + Assets/UniRx.Async/Internal/WeakDictionary.cs | 336 +++ .../Internal/WeakDictionary.cs.meta | 11 + Assets/UniRx.Async/PlayerLoopHelper.cs | 136 ++ Assets/UniRx.Async/PlayerLoopHelper.cs.meta | 11 + Assets/UniRx.Async/Progress.cs | 88 + Assets/UniRx.Async/Progress.cs.meta | 11 + Assets/UniRx.Async/Triggers.meta | 8 + .../Triggers/AsyncAnimatorTrigger.cs | 54 + .../Triggers/AsyncAnimatorTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncAwakeTrigger.cs | 55 + .../Triggers/AsyncAwakeTrigger.cs.meta | 11 + .../Triggers/AsyncBeginDragTrigger.cs | 41 + .../Triggers/AsyncBeginDragTrigger.cs.meta | 11 + .../Triggers/AsyncCancelTrigger.cs | 41 + .../Triggers/AsyncCancelTrigger.cs.meta | 11 + .../AsyncCanvasGroupChangedTrigger.cs | 41 + .../AsyncCanvasGroupChangedTrigger.cs.meta | 11 + .../Triggers/AsyncCollision2DTrigger.cs | 69 + .../Triggers/AsyncCollision2DTrigger.cs.meta | 11 + .../Triggers/AsyncCollisionTrigger.cs | 69 + .../Triggers/AsyncCollisionTrigger.cs.meta | 11 + .../Triggers/AsyncDeselectTrigger.cs | 41 + .../Triggers/AsyncDeselectTrigger.cs.meta | 11 + .../Triggers/AsyncDestroyTrigger.cs | 93 + .../Triggers/AsyncDestroyTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncDragTrigger.cs | 41 + .../Triggers/AsyncDragTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncDropTrigger.cs | 41 + .../Triggers/AsyncDropTrigger.cs.meta | 11 + .../Triggers/AsyncEnableDisableTrigger.cs | 55 + .../AsyncEnableDisableTrigger.cs.meta | 11 + .../Triggers/AsyncEndDragTrigger.cs | 41 + .../Triggers/AsyncEndDragTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncEventTrigger.cs | 264 +++ .../Triggers/AsyncEventTrigger.cs.meta | 11 + .../Triggers/AsyncFixedUpdateTrigger.cs | 41 + .../Triggers/AsyncFixedUpdateTrigger.cs.meta | 11 + .../AsyncInitializePotentialDragTrigger.cs | 41 + ...syncInitializePotentialDragTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncJointTrigger.cs | 55 + .../Triggers/AsyncJointTrigger.cs.meta | 11 + .../Triggers/AsyncLateUpdateTrigger.cs | 41 + .../Triggers/AsyncLateUpdateTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncMouseTrigger.cs | 129 ++ .../Triggers/AsyncMouseTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncMoveTrigger.cs | 41 + .../Triggers/AsyncMoveTrigger.cs.meta | 11 + .../Triggers/AsyncParticleTrigger.cs | 41 + .../Triggers/AsyncParticleTrigger.cs.meta | 11 + .../Triggers/AsyncPointerClickTrigger.cs | 41 + .../Triggers/AsyncPointerClickTrigger.cs.meta | 11 + .../Triggers/AsyncPointerDownTrigger.cs | 41 + .../Triggers/AsyncPointerDownTrigger.cs.meta | 11 + .../Triggers/AsyncPointerEnterTrigger.cs | 41 + .../Triggers/AsyncPointerEnterTrigger.cs.meta | 11 + .../Triggers/AsyncPointerExitTrigger.cs | 41 + .../Triggers/AsyncPointerExitTrigger.cs.meta | 11 + .../Triggers/AsyncPointerUpTrigger.cs | 41 + .../Triggers/AsyncPointerUpTrigger.cs.meta | 11 + .../Triggers/AsyncRectTransformTrigger.cs | 55 + .../AsyncRectTransformTrigger.cs.meta | 11 + .../Triggers/AsyncScrollTrigger.cs | 41 + .../Triggers/AsyncScrollTrigger.cs.meta | 11 + .../Triggers/AsyncSelectTrigger.cs | 41 + .../Triggers/AsyncSelectTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncStartTrigger.cs | 64 + .../Triggers/AsyncStartTrigger.cs.meta | 11 + .../Triggers/AsyncSubmitTrigger.cs | 41 + .../Triggers/AsyncSubmitTrigger.cs.meta | 11 + .../Triggers/AsyncTransformChangedTrigger.cs | 69 + .../AsyncTransformChangedTrigger.cs.meta | 11 + .../Triggers/AsyncTrigger2DTrigger.cs | 69 + .../Triggers/AsyncTrigger2DTrigger.cs.meta | 11 + .../UniRx.Async/Triggers/AsyncTriggerBase.cs | 271 +++ .../Triggers/AsyncTriggerBase.cs.meta | 11 + .../Triggers/AsyncTriggerExtensions.cs | 511 +++++ .../Triggers/AsyncTriggerExtensions.cs.meta | 11 + .../Triggers/AsyncTriggerTrigger.cs | 69 + .../Triggers/AsyncTriggerTrigger.cs.meta | 11 + .../Triggers/AsyncUpdateSelectedTrigger.cs | 41 + .../AsyncUpdateSelectedTrigger.cs.meta | 11 + .../Triggers/AsyncUpdateTrigger.cs | 41 + .../Triggers/AsyncUpdateTrigger.cs.meta | 11 + .../Triggers/AsyncVisibleTrigger.cs | 55 + .../Triggers/AsyncVisibleTrigger.cs.meta | 11 + Assets/UniRx.Async/UniRx.Async.asmdef | 8 + Assets/UniRx.Async/UniRx.Async.asmdef.meta | 7 + Assets/UniRx.Async/UniTask.Bridge.cs | 20 + Assets/UniRx.Async/UniTask.Bridge.cs.meta | 11 + Assets/UniRx.Async/UniTask.Delay.cs | 246 +++ Assets/UniRx.Async/UniTask.Delay.cs.meta | 11 + Assets/UniRx.Async/UniTask.Factory.cs | 121 ++ Assets/UniRx.Async/UniTask.Factory.cs.meta | 11 + Assets/UniRx.Async/UniTask.Run.cs | 99 + Assets/UniRx.Async/UniTask.Run.cs.meta | 11 + Assets/UniRx.Async/UniTask.Threading.cs | 176 ++ Assets/UniRx.Async/UniTask.Threading.cs.meta | 11 + Assets/UniRx.Async/UniTask.WaitUntil.cs | 235 +++ Assets/UniRx.Async/UniTask.WaitUntil.cs.meta | 11 + .../UniRx.Async/UniTask.WhenAll.Generated.cs | 1863 +++++++++++++++++ .../UniTask.WhenAll.Generated.cs.meta | 11 + Assets/UniRx.Async/UniTask.WhenAll.cs | 298 +++ Assets/UniRx.Async/UniTask.WhenAll.cs.meta | 11 + .../UniRx.Async/UniTask.WhenAny.Generated.cs | 1527 ++++++++++++++ .../UniTask.WhenAny.Generated.cs.meta | 11 + Assets/UniRx.Async/UniTask.WhenAny.cs | 374 ++++ Assets/UniRx.Async/UniTask.WhenAny.cs.meta | 11 + Assets/UniRx.Async/UniTask.cs | 479 +++++ Assets/UniRx.Async/UniTask.cs.meta | 11 + Assets/UniRx.Async/UniTaskCompletionSource.cs | 413 ++++ .../UniTaskCompletionSource.cs.meta | 11 + .../UniTaskExtensions.Shorthand.cs | 53 + .../UniTaskExtensions.Shorthand.cs.meta | 11 + Assets/UniRx.Async/UniTaskExtensions.cs | 486 +++++ Assets/UniRx.Async/UniTaskExtensions.cs.meta | 11 + .../UniTaskObservableExtensions.cs | 745 +++++++ .../UniTaskObservableExtensions.cs.meta | 11 + Assets/UniRx.Async/UniTaskScheduler.cs | 94 + Assets/UniRx.Async/UniTaskScheduler.cs.meta | 11 + Assets/UniRx.Async/UniTaskVoid.cs | 48 + Assets/UniRx.Async/UniTaskVoid.cs.meta | 11 + .../UniRx.Async/UnityAsyncExtensions.Jobs.cs | 140 ++ .../UnityAsyncExtensions.Jobs.cs.meta | 11 + Assets/UniRx.Async/UnityAsyncExtensions.cs | 702 +++++++ .../UniRx.Async/UnityAsyncExtensions.cs.meta | 11 + .../UniRx.Async/UnityAsyncExtensions.uGUI.cs | 434 ++++ .../UnityAsyncExtensions.uGUI.cs.meta | 11 + LICENSE.md => LICENSE | 3 +- ProjectSettings/AudioManager.asset | 17 + ProjectSettings/ClusterInputManager.asset | 6 + ProjectSettings/DynamicsManager.asset | 30 + ProjectSettings/EditorBuildSettings.asset | 11 + ProjectSettings/EditorSettings.asset | 21 + ProjectSettings/GraphicsSettings.asset | 60 + ProjectSettings/InputManager.asset | 295 +++ ProjectSettings/NavMeshAreas.asset | 91 + ProjectSettings/NetworkManager.asset | 8 + ProjectSettings/Physics2DSettings.asset | Bin 0 -> 4448 bytes ProjectSettings/PresetManager.asset | 6 + ProjectSettings/ProjectSettings.asset | 620 ++++++ ProjectSettings/ProjectVersion.txt | 2 + ProjectSettings/QualitySettings.asset | 191 ++ ProjectSettings/TagManager.asset | 43 + ProjectSettings/TimeManager.asset | 9 + ProjectSettings/UnityConnectSettings.asset | 34 + ProjectSettings/VFXManager.asset | 7 + ProjectSettings/XRSettings.asset | 10 + 246 files changed, 20742 insertions(+), 19 deletions(-) create mode 100644 Assets/RuntimeUnitTestToolkit.meta create mode 100644 Assets/RuntimeUnitTestToolkit/Editor.meta create mode 100644 Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs create mode 100644 Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta create mode 100644 Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs create mode 100644 Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta create mode 100644 Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs create mode 100644 Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs.meta create mode 100644 Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef create mode 100644 Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta create mode 100644 Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs create mode 100644 Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs.meta create mode 100644 Assets/RuntimeUnitTestToolkit/package.json create mode 100644 Assets/RuntimeUnitTestToolkit/package.json.meta create mode 100644 Assets/Scenes.meta create mode 100644 Assets/Scenes/SandboxMain.cs create mode 100644 Assets/Scenes/SandboxMain.cs.meta create mode 100644 Assets/Scenes/SandboxMain.unity create mode 100644 Assets/Scenes/SandboxMain.unity.meta create mode 100644 Assets/Tests.meta create mode 100644 Assets/Tests/AsyncTest.cs create mode 100644 Assets/Tests/AsyncTest.cs.meta create mode 100644 Assets/Tests/RunTest.cs create mode 100644 Assets/Tests/RunTest.cs.meta create mode 100644 Assets/Tests/Shims.cs create mode 100644 Assets/Tests/Shims.cs.meta create mode 100644 Assets/Tests/UniRx.Async.Tests.asmdef create mode 100644 Assets/Tests/UniRx.Async.Tests.asmdef.meta create mode 100644 Assets/Tests/WhenAnyTest.cs create mode 100644 Assets/Tests/WhenAnyTest.cs.meta create mode 100644 Assets/UniRx.Async.meta create mode 100644 Assets/UniRx.Async/AsyncUnit.cs create mode 100644 Assets/UniRx.Async/AsyncUnit.cs.meta create mode 100644 Assets/UniRx.Async/CancellationTokenEqualityComparer.cs create mode 100644 Assets/UniRx.Async/CancellationTokenEqualityComparer.cs.meta create mode 100644 Assets/UniRx.Async/CancellationTokenExtensions.cs create mode 100644 Assets/UniRx.Async/CancellationTokenExtensions.cs.meta create mode 100644 Assets/UniRx.Async/CancellationTokenSourceExtensions.cs create mode 100644 Assets/UniRx.Async/CancellationTokenSourceExtensions.cs.meta create mode 100644 Assets/UniRx.Async/CompilerServices.meta create mode 100644 Assets/UniRx.Async/CompilerServices/AsyncMethodBuilderAttribute.cs create mode 100644 Assets/UniRx.Async/CompilerServices/AsyncMethodBuilderAttribute.cs.meta create mode 100644 Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs create mode 100644 Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs.meta create mode 100644 Assets/UniRx.Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs create mode 100644 Assets/UniRx.Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs.meta create mode 100644 Assets/UniRx.Async/CompilerServices/MoveNextRunner.cs create mode 100644 Assets/UniRx.Async/CompilerServices/MoveNextRunner.cs.meta create mode 100644 Assets/UniRx.Async/DiagnosticsExtensions.cs create mode 100644 Assets/UniRx.Async/DiagnosticsExtensions.cs.meta create mode 100644 Assets/UniRx.Async/Editor.meta create mode 100644 Assets/UniRx.Async/Editor/SplitterGUILayout.cs create mode 100644 Assets/UniRx.Async/Editor/SplitterGUILayout.cs.meta create mode 100644 Assets/UniRx.Async/Editor/UniRx.Async.Editor.asmdef create mode 100644 Assets/UniRx.Async/Editor/UniRx.Async.Editor.asmdef.meta create mode 100644 Assets/UniRx.Async/Editor/UniTaskTrackerTreeView.cs create mode 100644 Assets/UniRx.Async/Editor/UniTaskTrackerTreeView.cs.meta create mode 100644 Assets/UniRx.Async/Editor/UniTaskTrackerWindow.cs create mode 100644 Assets/UniRx.Async/Editor/UniTaskTrackerWindow.cs.meta create mode 100644 Assets/UniRx.Async/EnumerableAsyncExtensions.cs create mode 100644 Assets/UniRx.Async/EnumerableAsyncExtensions.cs.meta create mode 100644 Assets/UniRx.Async/EnumeratorAsyncExtensions.cs create mode 100644 Assets/UniRx.Async/EnumeratorAsyncExtensions.cs.meta create mode 100644 Assets/UniRx.Async/ExceptionExtensions.cs create mode 100644 Assets/UniRx.Async/ExceptionExtensions.cs.meta create mode 100644 Assets/UniRx.Async/IAwaiter.cs create mode 100644 Assets/UniRx.Async/IAwaiter.cs.meta create mode 100644 Assets/UniRx.Async/Internal.meta create mode 100644 Assets/UniRx.Async/Internal/ArrayPool.cs create mode 100644 Assets/UniRx.Async/Internal/ArrayPool.cs.meta create mode 100644 Assets/UniRx.Async/Internal/ArrayPoolUtil.cs create mode 100644 Assets/UniRx.Async/Internal/ArrayPoolUtil.cs.meta create mode 100644 Assets/UniRx.Async/Internal/ArrayUtil.cs create mode 100644 Assets/UniRx.Async/Internal/ArrayUtil.cs.meta create mode 100644 Assets/UniRx.Async/Internal/CancellationTokenHelper.cs create mode 100644 Assets/UniRx.Async/Internal/CancellationTokenHelper.cs.meta create mode 100644 Assets/UniRx.Async/Internal/ContinuationQueue.cs create mode 100644 Assets/UniRx.Async/Internal/ContinuationQueue.cs.meta create mode 100644 Assets/UniRx.Async/Internal/Error.cs create mode 100644 Assets/UniRx.Async/Internal/Error.cs.meta create mode 100644 Assets/UniRx.Async/Internal/Hack.cs create mode 100644 Assets/UniRx.Async/Internal/Hack.cs.meta create mode 100644 Assets/UniRx.Async/Internal/LazyPromise.cs create mode 100644 Assets/UniRx.Async/Internal/LazyPromise.cs.meta create mode 100644 Assets/UniRx.Async/Internal/MinimumQueue.cs create mode 100644 Assets/UniRx.Async/Internal/MinimumQueue.cs.meta create mode 100644 Assets/UniRx.Async/Internal/PlayerLoopRunner.cs create mode 100644 Assets/UniRx.Async/Internal/PlayerLoopRunner.cs.meta create mode 100644 Assets/UniRx.Async/Internal/PromiseHelper.cs create mode 100644 Assets/UniRx.Async/Internal/PromiseHelper.cs.meta create mode 100644 Assets/UniRx.Async/Internal/ReusablePromise.cs create mode 100644 Assets/UniRx.Async/Internal/ReusablePromise.cs.meta create mode 100644 Assets/UniRx.Async/Internal/RuntimeHelpersAbstraction.cs create mode 100644 Assets/UniRx.Async/Internal/RuntimeHelpersAbstraction.cs.meta create mode 100644 Assets/UniRx.Async/Internal/TaskTracker.cs create mode 100644 Assets/UniRx.Async/Internal/TaskTracker.cs.meta create mode 100644 Assets/UniRx.Async/Internal/UnityEqualityComparer.cs create mode 100644 Assets/UniRx.Async/Internal/UnityEqualityComparer.cs.meta create mode 100644 Assets/UniRx.Async/Internal/WeakDictionary.cs create mode 100644 Assets/UniRx.Async/Internal/WeakDictionary.cs.meta create mode 100644 Assets/UniRx.Async/PlayerLoopHelper.cs create mode 100644 Assets/UniRx.Async/PlayerLoopHelper.cs.meta create mode 100644 Assets/UniRx.Async/Progress.cs create mode 100644 Assets/UniRx.Async/Progress.cs.meta create mode 100644 Assets/UniRx.Async/Triggers.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncAnimatorTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncAwakeTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncAwakeTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncBeginDragTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncCancelTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncCanvasGroupChangedTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncCanvasGroupChangedTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncCollision2DTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncCollisionTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncDeselectTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncDestroyTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncDestroyTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncDragTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncDropTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncEnableDisableTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncEnableDisableTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncEndDragTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncEventTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncFixedUpdateTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncFixedUpdateTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncInitializePotentialDragTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncInitializePotentialDragTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncJointTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncLateUpdateTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncLateUpdateTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncMouseTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncMouseTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncMoveTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncParticleTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerClickTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerDownTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerEnterTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerExitTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncPointerUpTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncRectTransformTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncRectTransformTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncScrollTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncSelectTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncStartTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncStartTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncSubmitTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncTransformChangedTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncTransformChangedTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncTrigger2DTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncTriggerBase.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncTriggerBase.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncTriggerExtensions.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncTriggerExtensions.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncTriggerTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncUpdateSelectedTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncUpdateSelectedTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncUpdateTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncUpdateTrigger.cs.meta create mode 100644 Assets/UniRx.Async/Triggers/AsyncVisibleTrigger.cs create mode 100644 Assets/UniRx.Async/Triggers/AsyncVisibleTrigger.cs.meta create mode 100644 Assets/UniRx.Async/UniRx.Async.asmdef create mode 100644 Assets/UniRx.Async/UniRx.Async.asmdef.meta create mode 100644 Assets/UniRx.Async/UniTask.Bridge.cs create mode 100644 Assets/UniRx.Async/UniTask.Bridge.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.Delay.cs create mode 100644 Assets/UniRx.Async/UniTask.Delay.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.Factory.cs create mode 100644 Assets/UniRx.Async/UniTask.Factory.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.Run.cs create mode 100644 Assets/UniRx.Async/UniTask.Run.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.Threading.cs create mode 100644 Assets/UniRx.Async/UniTask.Threading.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.WaitUntil.cs create mode 100644 Assets/UniRx.Async/UniTask.WaitUntil.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.WhenAll.Generated.cs create mode 100644 Assets/UniRx.Async/UniTask.WhenAll.Generated.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.WhenAll.cs create mode 100644 Assets/UniRx.Async/UniTask.WhenAll.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.WhenAny.Generated.cs create mode 100644 Assets/UniRx.Async/UniTask.WhenAny.Generated.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.WhenAny.cs create mode 100644 Assets/UniRx.Async/UniTask.WhenAny.cs.meta create mode 100644 Assets/UniRx.Async/UniTask.cs create mode 100644 Assets/UniRx.Async/UniTask.cs.meta create mode 100644 Assets/UniRx.Async/UniTaskCompletionSource.cs create mode 100644 Assets/UniRx.Async/UniTaskCompletionSource.cs.meta create mode 100644 Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs create mode 100644 Assets/UniRx.Async/UniTaskExtensions.Shorthand.cs.meta create mode 100644 Assets/UniRx.Async/UniTaskExtensions.cs create mode 100644 Assets/UniRx.Async/UniTaskExtensions.cs.meta create mode 100644 Assets/UniRx.Async/UniTaskObservableExtensions.cs create mode 100644 Assets/UniRx.Async/UniTaskObservableExtensions.cs.meta create mode 100644 Assets/UniRx.Async/UniTaskScheduler.cs create mode 100644 Assets/UniRx.Async/UniTaskScheduler.cs.meta create mode 100644 Assets/UniRx.Async/UniTaskVoid.cs create mode 100644 Assets/UniRx.Async/UniTaskVoid.cs.meta create mode 100644 Assets/UniRx.Async/UnityAsyncExtensions.Jobs.cs create mode 100644 Assets/UniRx.Async/UnityAsyncExtensions.Jobs.cs.meta create mode 100644 Assets/UniRx.Async/UnityAsyncExtensions.cs create mode 100644 Assets/UniRx.Async/UnityAsyncExtensions.cs.meta create mode 100644 Assets/UniRx.Async/UnityAsyncExtensions.uGUI.cs create mode 100644 Assets/UniRx.Async/UnityAsyncExtensions.uGUI.cs.meta rename LICENSE.md => LICENSE (95%) create mode 100644 ProjectSettings/AudioManager.asset create mode 100644 ProjectSettings/ClusterInputManager.asset create mode 100644 ProjectSettings/DynamicsManager.asset create mode 100644 ProjectSettings/EditorBuildSettings.asset create mode 100644 ProjectSettings/EditorSettings.asset create mode 100644 ProjectSettings/GraphicsSettings.asset create mode 100644 ProjectSettings/InputManager.asset create mode 100644 ProjectSettings/NavMeshAreas.asset create mode 100644 ProjectSettings/NetworkManager.asset create mode 100644 ProjectSettings/Physics2DSettings.asset create mode 100644 ProjectSettings/PresetManager.asset create mode 100644 ProjectSettings/ProjectSettings.asset create mode 100644 ProjectSettings/ProjectVersion.txt create mode 100644 ProjectSettings/QualitySettings.asset create mode 100644 ProjectSettings/TagManager.asset create mode 100644 ProjectSettings/TimeManager.asset create mode 100644 ProjectSettings/UnityConnectSettings.asset create mode 100644 ProjectSettings/VFXManager.asset create mode 100644 ProjectSettings/XRSettings.asset diff --git a/.gitignore b/.gitignore index 9de9409..174b65e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,143 @@ -/[Ll]ibrary/ -/[Tt]emp/ -/[Oo]bj/ -/[Bb]uild/ +# Unity -# Autogenerated VS/MD solution and project files -*.csproj -*.unityproj -*.sln -*.suo -*.tmp -*.user -*.userprefs *.pidb -*.booproj +*.suo +*.userprefs +*.vsmdi +*.testsettings +*/bin +*/obj +*/publish +$tf +TestResults +!*.sln +!*.csproj +!*/*.csproj +[Ll]ibrary/ +[Tt]emp/ +[Oo]bj/ -# Unity3D generated meta files -*.pidb.meta +# VS2013 -# Unity3D Generated File On Crash Reports -sysinfo.txt +# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) +[Bb]in/ +[Oo]bj/ + +# mstest test results +TestResults + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Rr]elease/ +x64/ +*_i.c +*_p.c +*.ilk +# *.meta # already ignored in Unity section +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.log +*.vspscc +*.vssscc +.builds + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper* + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish + +# Publish Web Output +*.Publish.xml + +# NuGet Packages Directory +packages + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +[Bb]in +[Oo]bj +sql +TestResults +[Tt]est[Rr]esult* +*.Cache +ClientBin +[Ss]tyle[Cc]op.* +~$* +*.dbmdl +Generated_Code #added for RIA/Silverlight projects + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +Assets/WSATestCertificate.pfx +.vs/ + +Assembly-CSharp\.csproj + +UniRx\.Async\.csproj + +UniRx\.Async\.Editor\.csproj + +UniRx\.Async\.Tests\.csproj + +UniTask\.sln + +RuntimeUnitTestToolkit\.csproj diff --git a/Assets/RuntimeUnitTestToolkit.meta b/Assets/RuntimeUnitTestToolkit.meta new file mode 100644 index 0000000..aa095c6 --- /dev/null +++ b/Assets/RuntimeUnitTestToolkit.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 894f21dfce4e82343a91661e1ec1a455 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/RuntimeUnitTestToolkit/Editor.meta b/Assets/RuntimeUnitTestToolkit/Editor.meta new file mode 100644 index 0000000..903f676 --- /dev/null +++ b/Assets/RuntimeUnitTestToolkit/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 959c1472a5d812843bedf9341e87af3b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs b/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs new file mode 100644 index 0000000..9a2adc2 --- /dev/null +++ b/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs @@ -0,0 +1,133 @@ +#if UNITY_EDITOR + +using System; +using UnityEngine; + +namespace RuntimeUnitTestToolkit.Editor +{ + // functional declarative construction like flutter. + + internal interface IBuilder + { + GameObject GameObject { get; } + T GetComponent(); + } + + internal class Builder : IBuilder + where T : Component + { + public T Component1 { get; private set; } + public GameObject GameObject { get; private set; } + + public Transform Transform { get { return GameObject.transform; } } + public RectTransform RectTransform { get { return GameObject.GetComponent(); } } + + public Action SetTarget + { + set + { + value(this.GameObject); + } + } + + + public IBuilder Child + { + set + { + value.GameObject.transform.SetParent(GameObject.transform); + } + } + + public IBuilder[] Children + { + set + { + foreach (var item in value) + { + item.GameObject.transform.SetParent(GameObject.transform); + } + } + } + + public Builder(string name) + { + this.GameObject = new GameObject(name); + this.Component1 = GameObject.AddComponent(); + } + + public Builder(string name, out T referenceSelf) // out primary reference. + { + this.GameObject = new GameObject(name); + this.Component1 = GameObject.AddComponent(); + referenceSelf = this.Component1; + } + + public TComponent GetComponent() + { + return this.GameObject.GetComponent(); + } + } + + internal class Builder : Builder + where T1 : Component + where T2 : Component + { + public T2 Component2 { get; private set; } + + public Builder(string name) + : base(name) + { + this.Component2 = GameObject.AddComponent(); + } + + public Builder(string name, out T1 referenceSelf) + : base(name, out referenceSelf) + { + this.Component2 = GameObject.AddComponent(); + } + } + + internal class Builder : Builder + where T1 : Component + where T2 : Component + where T3 : Component + { + public T3 Component3 { get; private set; } + + public Builder(string name) + : base(name) + { + this.Component3 = GameObject.AddComponent(); + } + + public Builder(string name, out T1 referenceSelf) + : base(name, out referenceSelf) + { + this.Component3 = GameObject.AddComponent(); + } + } + + internal class Builder : Builder + where T1 : Component + where T2 : Component + where T3 : Component + where T4 : Component + { + public T4 Component4 { get; private set; } + + public Builder(string name) + : base(name) + { + this.Component4 = GameObject.AddComponent(); + } + + public Builder(string name, out T1 referenceSelf) + : base(name, out referenceSelf) + { + this.Component4 = GameObject.AddComponent(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta b/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta new file mode 100644 index 0000000..82c8e9b --- /dev/null +++ b/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8760bbbab905a534eb6fb7b61b736926 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs new file mode 100644 index 0000000..9ec1c54 --- /dev/null +++ b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs @@ -0,0 +1,341 @@ +#if UNITY_EDITOR +using UnityEditor; + +// Settings MenuItems. + +public static partial class UnitTestBuilder +{ + [MenuItem("Test/Settings/ScriptBackend/Mono", validate = true, priority = 1)] + static bool ValidateScriptBackendMono() + { + Menu.SetChecked("Test/Settings/ScriptBackend/Mono", LoadOrGetDefaultSettings().ScriptBackend == ScriptingImplementation.Mono2x); + return true; + } + + [MenuItem("Test/Settings/ScriptBackend/Mono", validate = false, priority = 1)] + static void ScriptBackendMono() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentScriptBackend = false; + settings.ScriptBackend = ScriptingImplementation.Mono2x; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/ScriptBackend/IL2CPP", validate = true, priority = 2)] + static bool ValidateScriptBackendIL2CPP() + { + Menu.SetChecked("Test/Settings/ScriptBackend/IL2CPP", LoadOrGetDefaultSettings().ScriptBackend == ScriptingImplementation.IL2CPP); + return true; + } + + [MenuItem("Test/Settings/ScriptBackend/IL2CPP", validate = false, priority = 2)] + static void ScriptBackendIL2CPP() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentScriptBackend = false; + settings.ScriptBackend = ScriptingImplementation.IL2CPP; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/AutoRunPlayer", validate = true, priority = 3)] + static bool ValidateAutoRun() + { + Menu.SetChecked("Test/Settings/AutoRunPlayer", LoadOrGetDefaultSettings().AutoRunPlayer); + return true; + } + + [MenuItem("Test/Settings/AutoRunPlayer", validate = false, priority = 3)] + static void AutoRun() + { + var settings = LoadOrGetDefaultSettings(); + settings.AutoRunPlayer = !settings.AutoRunPlayer; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/Headless", validate = true, priority = 4)] + static bool ValidateHeadless() + { + Menu.SetChecked("Test/Settings/Headless", LoadOrGetDefaultSettings().Headless); + return true; + } + + [MenuItem("Test/Settings/Headless", validate = false, priority = 4)] + static void Headless() + { + var settings = LoadOrGetDefaultSettings(); + settings.Headless = !settings.Headless; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/DisableAutoClose", validate = true, priority = 5)] + static bool ValidateDisableAutoClose() + { + Menu.SetChecked("Test/Settings/DisableAutoClose", LoadOrGetDefaultSettings().DisableAutoClose); + return true; + } + + [MenuItem("Test/Settings/DisableAutoClose", validate = false, priority = 5)] + static void DisableAutoClose() + { + var settings = LoadOrGetDefaultSettings(); + settings.DisableAutoClose = !settings.DisableAutoClose; + SaveSettings(settings); + } + + // generated + + /* + * + void Main() +{ +var sb = new StringBuilder(); + +var p = 1; +foreach (var target in Enum.GetNames(typeof(BuildTarget))) +{ + var path = $"Test/Settings/BuildTarget/{target}"; + var priority = p++; + + var template = $@" +[MenuItem(""{path}"", validate = true, priority = {priority})] +static bool ValidateBuildTarget{target}() +{{ +Menu.SetChecked(""{path}"", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.{target}); +return true; +}} + +[MenuItem(""{path}"", validate = false, priority = {priority})] +static void BuildTarget{target}() +{{ +var settings = LoadOrGetDefaultSettings(); +settings.UseCurrentBuildTarget = false; +settings.BuildTarget = BuildTarget.{target}; +SaveSettings(settings); +}}"; + + sb.AppendLine(template); +} + +sb.ToString().Dump(); +} + +public enum BuildTarget +{ +StandaloneWindows, +StandaloneWindows64, +StandaloneLinux, +StandaloneLinux64, +StandaloneOSX, +WebGL, +iOS, +Android, +WSAPlayer, +PS4, +XboxOne, +Switch, +} + */ + + + [MenuItem("Test/Settings/BuildTarget/StandaloneWindows", validate = true, priority = 1)] + static bool ValidateBuildTargetStandaloneWindows() + { + Menu.SetChecked("Test/Settings/BuildTarget/StandaloneWindows", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneWindows); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneWindows", validate = false, priority = 1)] + static void BuildTargetStandaloneWindows() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.StandaloneWindows; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneWindows64", validate = true, priority = 2)] + static bool ValidateBuildTargetStandaloneWindows64() + { + Menu.SetChecked("Test/Settings/BuildTarget/StandaloneWindows64", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneWindows64); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneWindows64", validate = false, priority = 2)] + static void BuildTargetStandaloneWindows64() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.StandaloneWindows64; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = true, priority = 3)] + static bool ValidateBuildTargetStandaloneLinux() + { + Menu.SetChecked("Test/Settings/BuildTarget/StandaloneLinux", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneLinux); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = false, priority = 3)] + static void BuildTargetStandaloneLinux() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.StandaloneLinux; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = true, priority = 4)] + static bool ValidateBuildTargetStandaloneLinux64() + { + Menu.SetChecked("Test/Settings/BuildTarget/StandaloneLinux64", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneLinux64); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = false, priority = 4)] + static void BuildTargetStandaloneLinux64() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.StandaloneLinux64; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneOSX", validate = true, priority = 5)] + static bool ValidateBuildTargetStandaloneOSX() + { + Menu.SetChecked("Test/Settings/BuildTarget/StandaloneOSX", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneOSX); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/StandaloneOSX", validate = false, priority = 5)] + static void BuildTargetStandaloneOSX() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.StandaloneOSX; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/WebGL", validate = true, priority = 6)] + static bool ValidateBuildTargetWebGL() + { + Menu.SetChecked("Test/Settings/BuildTarget/WebGL", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.WebGL); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/WebGL", validate = false, priority = 6)] + static void BuildTargetWebGL() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.WebGL; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/iOS", validate = true, priority = 7)] + static bool ValidateBuildTargetiOS() + { + Menu.SetChecked("Test/Settings/BuildTarget/iOS", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.iOS); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/iOS", validate = false, priority = 7)] + static void BuildTargetiOS() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.iOS; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/Android", validate = true, priority = 8)] + static bool ValidateBuildTargetAndroid() + { + Menu.SetChecked("Test/Settings/BuildTarget/Android", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.Android); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/Android", validate = false, priority = 8)] + static void BuildTargetAndroid() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.Android; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/WSAPlayer", validate = true, priority = 9)] + static bool ValidateBuildTargetWSAPlayer() + { + Menu.SetChecked("Test/Settings/BuildTarget/WSAPlayer", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.WSAPlayer); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/WSAPlayer", validate = false, priority = 9)] + static void BuildTargetWSAPlayer() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.WSAPlayer; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/PS4", validate = true, priority = 10)] + static bool ValidateBuildTargetPS4() + { + Menu.SetChecked("Test/Settings/BuildTarget/PS4", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.PS4); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/PS4", validate = false, priority = 10)] + static void BuildTargetPS4() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.PS4; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/XboxOne", validate = true, priority = 11)] + static bool ValidateBuildTargetXboxOne() + { + Menu.SetChecked("Test/Settings/BuildTarget/XboxOne", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.XboxOne); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/XboxOne", validate = false, priority = 11)] + static void BuildTargetXboxOne() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.XboxOne; + SaveSettings(settings); + } + + [MenuItem("Test/Settings/BuildTarget/Switch", validate = true, priority = 12)] + static bool ValidateBuildTargetSwitch() + { + Menu.SetChecked("Test/Settings/BuildTarget/Switch", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.Switch); + return true; + } + + [MenuItem("Test/Settings/BuildTarget/Switch", validate = false, priority = 12)] + static void BuildTargetSwitch() + { + var settings = LoadOrGetDefaultSettings(); + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = BuildTarget.Switch; + SaveSettings(settings); + } + + + + + + + + +} + +#endif diff --git a/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta new file mode 100644 index 0000000..7c99172 --- /dev/null +++ b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 12bdad0556e999f4aa82da29415d361f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs new file mode 100644 index 0000000..8ca1068 --- /dev/null +++ b/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs @@ -0,0 +1,515 @@ +#if UNITY_EDITOR + +using RuntimeUnitTestToolkit; +using RuntimeUnitTestToolkit.Editor; +using System; +using UnityEditor; +using UnityEditor.Build.Reporting; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.SceneManagement; +using UnityEngine.UI; + +internal class RuntimeUnitTestSettings +{ + public ScriptingImplementation ScriptBackend; + public bool UseCurrentScriptBackend; + public BuildTarget BuildTarget; + public bool UseCurrentBuildTarget; + + public bool Headless; + public bool AutoRunPlayer; + public bool DisableAutoClose; + + public RuntimeUnitTestSettings() + { + UseCurrentBuildTarget = true; + UseCurrentScriptBackend = true; + Headless = false; + AutoRunPlayer = true; + DisableAutoClose = false; + } + + public override string ToString() + { + return $"{ScriptBackend} {BuildTarget} Headless:{Headless} AutoRunPlayer:{AutoRunPlayer} DisableAutoClose:{DisableAutoClose}"; + } +} + +// no namespace(because invoke from commandline) +public static partial class UnitTestBuilder +{ + const string SettingsKeyBase = "RuntimeUnitTest.Settings."; + + [MenuItem("Test/BuildUnitTest")] + public static void BuildUnitTest() + { + var settings = new RuntimeUnitTestSettings(); // default + + string buildPath = null; + + if (Application.isBatchMode) // from commandline + { + settings.AutoRunPlayer = false; + settings.DisableAutoClose = false; + + var cmdArgs = Environment.GetCommandLineArgs(); + for (int i = 0; i < cmdArgs.Length; i++) + { + if (string.Equals(cmdArgs[i].Trim('-', '/'), "ScriptBackend", StringComparison.OrdinalIgnoreCase)) + { + settings.UseCurrentScriptBackend = false; + var str = cmdArgs[++i]; + if (str.StartsWith("mono", StringComparison.OrdinalIgnoreCase)) + { + settings.ScriptBackend = ScriptingImplementation.Mono2x; + } + else if (str.StartsWith("IL2CPP", StringComparison.OrdinalIgnoreCase)) + { + settings.ScriptBackend = ScriptingImplementation.IL2CPP; + } + else + { + settings.ScriptBackend = (ScriptingImplementation)Enum.Parse(typeof(ScriptingImplementation), str, true); + } + } + else if (string.Equals(cmdArgs[i].Trim('-', '/'), "BuildTarget", StringComparison.OrdinalIgnoreCase)) + { + settings.UseCurrentBuildTarget = false; + settings.BuildTarget = (BuildTarget)Enum.Parse(typeof(BuildTarget), cmdArgs[++i], true); + } + else if (string.Equals(cmdArgs[i].Trim('-', '/'), "Headless", StringComparison.OrdinalIgnoreCase)) + { + settings.Headless = true; + } + else if (string.Equals(cmdArgs[i].Trim('-', '/'), "buildPath", StringComparison.OrdinalIgnoreCase)) + { + buildPath = cmdArgs[++i]; + } + } + } + else + { + var key = SettingsKeyBase + Application.productName; + var settingsValue = EditorPrefs.GetString(key, null); + try + { + if (!string.IsNullOrWhiteSpace(settingsValue)) + { + settings = JsonUtility.FromJson(settingsValue); + } + } + catch + { + UnityEngine.Debug.LogError("Fail to load RuntimeUnitTest settings"); + EditorPrefs.SetString(key, null); + } + } + + if (settings.UseCurrentBuildTarget) + { + settings.BuildTarget = EditorUserBuildSettings.activeBuildTarget; + } + if (settings.UseCurrentScriptBackend) + { + settings.ScriptBackend = PlayerSettings.GetScriptingBackend(ToBuildTargetGroup(settings.BuildTarget)); + } + + if (buildPath == null) + { + buildPath = $"bin/UnitTest/{settings.BuildTarget}_{settings.ScriptBackend}/test" + (IsWindows(settings.BuildTarget) ? ".exe" : ""); + } + + var originalScene = SceneManager.GetActiveScene().path; + + BuildUnitTest(buildPath, settings.ScriptBackend, settings.BuildTarget, settings.Headless, settings.AutoRunPlayer, settings.DisableAutoClose); + + // reopen original scene + if (!string.IsNullOrWhiteSpace(originalScene)) + { + EditorSceneManager.OpenScene(originalScene, OpenSceneMode.Single); + } + else + { + EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); + } + } + + static RuntimeUnitTestSettings LoadOrGetDefaultSettings() + { + var key = SettingsKeyBase + Application.productName; + + var settingsValue = EditorPrefs.GetString(key, null); + RuntimeUnitTestSettings settings = null; + try + { + if (!string.IsNullOrWhiteSpace(settingsValue)) + { + settings = JsonUtility.FromJson(settingsValue); + } + } + catch + { + UnityEngine.Debug.LogError("Fail to load RuntimeUnitTest settings"); + EditorPrefs.SetString(key, null); + settings = null; + } + + if (settings == null) + { + // default + settings = new RuntimeUnitTestSettings + { + UseCurrentBuildTarget = true, + UseCurrentScriptBackend = true, + Headless = false, + AutoRunPlayer = true, + }; + } + + return settings; + } + + static void SaveSettings(RuntimeUnitTestSettings settings) + { + var key = SettingsKeyBase + Application.productName; + EditorPrefs.SetString(key, JsonUtility.ToJson(settings)); + } + + public static void BuildUnitTest(string buildPath, ScriptingImplementation scriptBackend, BuildTarget buildTarget, bool headless, bool autoRunPlayer, bool disableAutoClose) + { + var sceneName = "Assets/TempRuntimeUnitTestScene_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + if (disableAutoClose) + { + sceneName += "_DisableAutoClose"; + } + sceneName += ".unity"; + + var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); + + BuildUnitTestRunnerScene(); + + EditorSceneManager.MarkSceneDirty(scene); + AssetDatabase.SaveAssets(); + EditorSceneManager.SaveScene(scene, sceneName, false); + try + { + Build(sceneName, buildPath, new RuntimeUnitTestSettings { ScriptBackend = scriptBackend, BuildTarget = buildTarget, Headless = headless, AutoRunPlayer = autoRunPlayer, DisableAutoClose = disableAutoClose }); + } + finally + { + AssetDatabase.DeleteAsset(sceneName); + } + } + + public static UnitTestRunner BuildUnitTestRunnerScene() + { + const string kStandardSpritePath = "UI/Skin/UISprite.psd"; + const string kBackgroundSpritePath = "UI/Skin/Background.psd"; + var uisprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); + var background = AssetDatabase.GetBuiltinExtraResource(kBackgroundSpritePath); + + ScrollRect buttonList; + VerticalLayoutGroup listLayout; + Scrollbar refListScrollbar; + ScrollRect logList; + Scrollbar refLogScrollbar; + Button clearButton; + Text logText; + + // Flutter like coded build utility + + var rootObject = new Builder("SceneRoot") + { + Children = new IBuilder[] { + new Builder("EventSystem"), + new Builder("Canvas") { + Component1 = { renderMode = RenderMode.ScreenSpaceOverlay }, + Children = new IBuilder[] { + new Builder("HorizontalSplitter") { + RectTransform = { anchorMin = new Vector2(0, 0), anchorMax = new Vector2(1, 1) }, + Component1 = { childControlWidth = true, childControlHeight = true, spacing = 10 }, + Children = new IBuilder[] { + new Builder("ButtonList", out buttonList) { + RectTransform = { pivot = new Vector2(0.5f, 0.5f) }, + Component1 = { horizontal =false, vertical = true, movementType = ScrollRect.MovementType.Clamped }, + Children = new IBuilder[] { + new Builder("ListLayoutToAttach", out listLayout) { + RectTransform = { anchorMin = new Vector2(0, 0), anchorMax = new Vector2(1, 1), pivot = new Vector2(0, 1) }, + Component1 = { childControlWidth = true, childControlHeight = true, childForceExpandWidth = true, childForceExpandHeight = false, spacing = 10, padding = new RectOffset(10,20,10,10) }, + Component2 = { horizontalFit = ContentSizeFitter.FitMode.Unconstrained, verticalFit = ContentSizeFitter.FitMode.PreferredSize }, + SetTarget = self => { buttonList.content = self.GetComponent(); }, + Child = new Builder("ClearButton", out clearButton) { + Component2 = { sprite = uisprite, type = Image.Type.Sliced }, + Component3 = { minHeight = 50 }, + SetTarget = self => { self.GetComponent