├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe ├── NuGet.targets ├── UniRx.nuspec ├── pack.bat └── push.bat ├── Analyzer └── UniRxAnalyzer │ ├── UniRxAnalyzer.Test │ ├── HandleObservableAnalyzerTest.cs │ ├── Helpers │ │ ├── CodeFixVerifier.Helper.cs │ │ ├── DiagnosticResult.cs │ │ └── DiagnosticVerifier.Helper.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── UniRxAnalyzer.Test.csproj │ ├── Verifiers │ │ ├── CodeFixVerifier.cs │ │ └── DiagnosticVerifier.cs │ └── packages.config │ ├── UniRxAnalyzer.Vsix │ ├── UniRxAnalyzer.Vsix.csproj │ └── source.extension.vsixmanifest │ └── UniRxAnalyzer │ ├── Diagnostic.nuspec │ ├── HandleObservableAnalyzer.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── UniRxAnalyzer.csproj │ ├── packages.config │ └── tools │ ├── install.ps1 │ └── uninstall.ps1 ├── Assets ├── AssetStoreTools.meta ├── AssetStoreTools │ └── Editor │ │ ├── DroidSansMono.ttf │ │ └── icon.png ├── ObjectTest.meta ├── ObjectTest │ ├── Button.controller │ ├── Button.controller.meta │ ├── Clicker.cs │ ├── Clicker.cs.meta │ ├── CountOnly.cs │ ├── CountOnly.cs.meta │ ├── DispatcherCullingTest.cs │ ├── DispatcherCullingTest.cs.meta │ ├── EditorBehaviourTest.cs │ ├── EditorBehaviourTest.cs.meta │ ├── GameObjectDisplacer.cs │ ├── GameObjectDisplacer.cs.meta │ ├── IntervalTest.cs │ ├── IntervalTest.cs.meta │ ├── LoadLevelTest.cs │ ├── LoadLevelTest.cs.meta │ ├── MyStateMachine.cs │ ├── MyStateMachine.cs.meta │ ├── New Animator Controller.controller │ ├── New Animator Controller.controller.meta │ ├── RotateGameObject.cs │ ├── RotateGameObject.cs.meta │ ├── Sandbox2.cs │ ├── Sandbox2.cs.meta │ ├── SimpleMultiline.cs │ ├── SimpleMultiline.cs.meta │ ├── UniRxTestSandbox.cs │ ├── UniRxTestSandbox.cs.meta │ ├── WorkerThreadTest.cs │ ├── WorkerThreadTest.cs.meta │ ├── YieldTest.cs │ ├── YieldTest.cs.meta │ ├── clicker.jpg │ └── clicker.jpg.meta ├── Scenes.meta ├── Scenes │ ├── Clean.unity │ ├── Clean.unity.meta │ ├── LoadLevelTest.unity │ ├── LoadLevelTest.unity.meta │ ├── LoadLevelTestAdditive.unity │ ├── LoadLevelTestAdditive.unity.meta │ ├── LoadLevelTestNew.unity │ ├── LoadLevelTestNew.unity.meta │ ├── MultipleDispatchersTest.unity │ ├── MultipleDispatchersTest.unity.meta │ ├── NextSandBox.unity │ ├── NextSandBox.unity.meta │ ├── TestSandbox.unity │ ├── TestSandbox.unity.meta │ ├── UnitAssertion.unity │ ├── UnitAssertion.unity.meta │ ├── WorkerThreadTest.unity │ └── WorkerThreadTest.unity.meta ├── UniRx.meta ├── UniRx │ ├── Examples │ │ ├── Sample01_ObservableWWW.cs │ │ ├── Sample01_ObservableWWW.cs.meta │ │ ├── Sample02_ObservableTriggers.cs │ │ ├── Sample02_ObservableTriggers.cs.meta │ │ ├── Sample03_GameObjectAsObservable.cs │ │ ├── Sample03_GameObjectAsObservable.cs.meta │ │ ├── Sample04_ConvertFromUnityCallback.cs │ │ ├── Sample04_ConvertFromUnityCallback.cs.meta │ │ ├── Sample05_ConvertFromCoroutine.cs │ │ ├── Sample05_ConvertFromCoroutine.cs.meta │ │ ├── Sample06_ConvertToCoroutine.cs │ │ ├── Sample06_ConvertToCoroutine.cs.meta │ │ ├── Sample07_OrchestratIEnumerator.cs │ │ ├── Sample07_OrchestratIEnumerator.cs.meta │ │ ├── Sample08_DetectDoubleClick.cs │ │ ├── Sample08_DetectDoubleClick.cs.meta │ │ ├── Sample09_EventHandling.cs │ │ ├── Sample09_EventHandling.cs.meta │ │ ├── Sample10_MainThreadDispatcher.cs │ │ ├── Sample10_MainThreadDispatcher.cs.meta │ │ ├── Sample11_Logger.cs │ │ ├── Sample11_Logger.cs.meta │ │ ├── Sample12Scene.unity │ │ ├── Sample12Scene.unity.meta │ │ ├── Sample12_ReactiveProperty.cs │ │ ├── Sample12_ReactiveProperty.cs.meta │ │ ├── Sample13Scene.unity │ │ ├── Sample13Scene.unity.meta │ │ ├── Sample13_ToDoApp.cs │ │ ├── Sample13_ToDoApp.cs.meta │ │ ├── Sample13_ToDoItem.prefab │ │ ├── Sample13_ToDoItem.prefab.meta │ │ ├── Sample14Scene.unity │ │ ├── Sample14Scene.unity.meta │ │ ├── Sample14_CubeLevel1.cs │ │ ├── Sample14_CubeLevel1.cs.meta │ │ ├── Sample14_CubeLevel2.cs │ │ ├── Sample14_CubeLevel2.cs.meta │ │ ├── Sample14_PresenterBase.cs │ │ └── Sample14_PresenterBase.cs.meta │ ├── ReadMe.txt │ └── Scripts │ │ ├── Asynchronous │ │ └── WebRequestExtensions.cs │ │ ├── Disposables │ │ ├── BooleanDisposable.cs │ │ ├── CompositeDisposable.cs │ │ ├── DictionaryDisposable.cs │ │ ├── Disposable.cs │ │ ├── DisposableExtensions.cs │ │ ├── ICancelable.cs │ │ ├── MultipleAssignmentDisposable.cs │ │ ├── RefCountDisposable.cs │ │ ├── ScheduledDisposable.cs │ │ ├── SerialDisposable.cs │ │ ├── SingleAssignmentDisposable.cs │ │ └── StableCompositeDisposable.cs │ │ ├── EventPattern.cs │ │ ├── InternalUtil │ │ ├── AscynLock.cs │ │ ├── ImmutableList.cs │ │ ├── ListObserver.cs │ │ ├── PriorityQueue.cs │ │ ├── ReflectionAccessor.cs │ │ ├── ScheduledItem.cs │ │ └── ThreadSafeQueueWorker.cs │ │ ├── Notification.cs │ │ ├── Notifiers │ │ ├── BooleanNotifier.cs │ │ ├── CountNotifier.cs │ │ ├── MessageBroker.cs │ │ └── ScheduledNotifier.cs │ │ ├── Observable.Aggregate.cs │ │ ├── Observable.Binding.cs │ │ ├── Observable.Blocking.cs │ │ ├── Observable.Concatenate.cs │ │ ├── Observable.Concurrency.cs │ │ ├── Observable.Conversions.cs │ │ ├── Observable.Creation.cs │ │ ├── Observable.ErrorHandling.cs │ │ ├── Observable.Events.cs │ │ ├── Observable.FromAsync.cs │ │ ├── Observable.Joins.cs │ │ ├── Observable.Paging.cs │ │ ├── Observable.Time.cs │ │ ├── Observable.cs │ │ ├── Observer.cs │ │ ├── Operators │ │ ├── Aggregate.cs │ │ ├── Amb.cs │ │ ├── AsObservable.cs │ │ ├── AsUnitObservable.cs │ │ ├── Buffer.cs │ │ ├── Cast.cs │ │ ├── Catch.cs │ │ ├── CombineLatest.cs │ │ ├── Concat.cs │ │ ├── ContinueWith.cs │ │ ├── Create.cs │ │ ├── DefaultIfEmpty.cs │ │ ├── Defer.cs │ │ ├── Delay.cs │ │ ├── DelaySubscription.cs │ │ ├── Dematerialize.cs │ │ ├── Distinct.cs │ │ ├── DistinctUntilChanged.cs │ │ ├── Do.cs │ │ ├── Empty.cs │ │ ├── Finally.cs │ │ ├── First.cs │ │ ├── ForEachAsync.cs │ │ ├── FromEvent.cs │ │ ├── IgnoreElements.cs │ │ ├── Last.cs │ │ ├── Materialize.cs │ │ ├── Merge.cs │ │ ├── Never.cs │ │ ├── ObserveOn.cs │ │ ├── OfType.cs │ │ ├── OperatorObservableBase.cs │ │ ├── OperatorObserverBase.cs │ │ ├── PairWise.cs │ │ ├── Range.cs │ │ ├── RefCount.cs │ │ ├── Repeat.cs │ │ ├── RepeatSafe.cs │ │ ├── Return.cs │ │ ├── Sample.cs │ │ ├── Scan.cs │ │ ├── Select.cs │ │ ├── SelectMany.cs │ │ ├── Single.cs │ │ ├── Skip.cs │ │ ├── SkipUntil.cs │ │ ├── SkipWhile.cs │ │ ├── Start.cs │ │ ├── StartWith.cs │ │ ├── SubscribeOn.cs │ │ ├── Switch.cs │ │ ├── Synchronize.cs │ │ ├── Take.cs │ │ ├── TakeUntil.cs │ │ ├── TakeWhile.cs │ │ ├── Throttle.cs │ │ ├── ThrottleFirst.cs │ │ ├── Throw.cs │ │ ├── TimeInterval.cs │ │ ├── Timeout.cs │ │ ├── Timer.cs │ │ ├── Timestamp.cs │ │ ├── ToArray.cs │ │ ├── ToList.cs │ │ ├── ToObservable.cs │ │ ├── Wait.cs │ │ ├── WhenAll.cs │ │ ├── Where.cs │ │ └── Zip.cs │ │ ├── Pair.cs │ │ ├── Schedulers │ │ ├── CurrentThreadScheduler.cs │ │ ├── IScheduler.cs │ │ ├── ImmediateScheduler.cs │ │ ├── Scheduler.cs │ │ └── ThreadPoolScheduler.cs │ │ ├── Subjects │ │ ├── AsyncSubject.cs │ │ ├── BehaviorSubject.cs │ │ ├── ConnectableObservable.cs │ │ ├── ISubject.cs │ │ ├── ReplaySubject.cs │ │ └── Subject.cs │ │ ├── System │ │ ├── IObservable.cs │ │ ├── IObserver.cs │ │ ├── IOptimizedObservable.cs │ │ ├── IProgress.cs │ │ ├── Tuple.cs │ │ └── Unit.cs │ │ ├── TimeInterval.cs │ │ ├── Timestamped.cs │ │ ├── UnityEngineBridge │ │ ├── AotSafeExtensions.cs │ │ ├── AsyncOperationExtensions.cs │ │ ├── CancellationToken.cs │ │ ├── Diagnostics │ │ │ ├── LogEntry.cs │ │ │ ├── LogEntryExtensions.cs │ │ │ ├── Logger.cs │ │ │ ├── ObservableLogger.cs │ │ │ └── UnityDebugSink.cs │ │ ├── InspectableReactiveProperty.cs │ │ ├── InspectorDisplayDrawer.cs │ │ ├── LazyTask.cs │ │ ├── LifetimeDisposableExtensions.cs │ │ ├── MainThreadDispatcher.cs │ │ ├── MainThreadScheduler.cs │ │ ├── Observable.Unity.cs │ │ ├── ObservableMonoBehaviour.cs │ │ ├── ObservableWWW.cs │ │ ├── ObservableWebRequest.cs │ │ ├── ObserveExtensions.cs │ │ ├── Operators │ │ │ ├── DelayFrame.cs │ │ │ ├── DelayFrameSubscription.cs │ │ │ ├── FromCoroutine.cs │ │ │ ├── RepeatUntil.cs │ │ │ ├── SampleFrame.cs │ │ │ ├── SubscribeOnMainThread.cs │ │ │ ├── ThrottleFirstFrame.cs │ │ │ ├── ThrottleFrame.cs │ │ │ └── TimeoutFrame.cs │ │ ├── PresenterBase.cs │ │ ├── ReactiveCollection.cs │ │ ├── ReactiveDictionary.cs │ │ ├── ReactiveProperty.cs │ │ ├── ScenePlaybackDetector.cs │ │ ├── Triggers │ │ │ ├── ObservableAnimatorTrigger.cs │ │ │ ├── ObservableBeginDragTrigger.cs │ │ │ ├── ObservableCancelTrigger.cs │ │ │ ├── ObservableCanvasGroupChangedTrigger.cs │ │ │ ├── ObservableCollision2DTrigger.cs │ │ │ ├── ObservableCollisionTrigger.cs │ │ │ ├── ObservableDeselectTrigger.cs │ │ │ ├── ObservableDestroyTrigger.cs │ │ │ ├── ObservableDragTrigger.cs │ │ │ ├── ObservableDropTrigger.cs │ │ │ ├── ObservableEnableTrigger.cs │ │ │ ├── ObservableEndDragTrigger.cs │ │ │ ├── ObservableEventTrigger.cs │ │ │ ├── ObservableFixedUpdateTrigger.cs │ │ │ ├── ObservableInitializePotentialDragTrigger.cs │ │ │ ├── ObservableLateUpdateTrigger.cs │ │ │ ├── ObservableMouseTrigger.cs │ │ │ ├── ObservableMoveTrigger.cs │ │ │ ├── ObservablePointerClickTrigger.cs │ │ │ ├── ObservablePointerDownTrigger.cs │ │ │ ├── ObservablePointerEnterTrigger.cs │ │ │ ├── ObservablePointerExitTrigger.cs │ │ │ ├── ObservablePointerUpTrigger.cs │ │ │ ├── ObservableRectTransformTrigger.cs │ │ │ ├── ObservableScrollTrigger.cs │ │ │ ├── ObservableSelectTrigger.cs │ │ │ ├── ObservableStateMachineTrigger.cs │ │ │ ├── ObservableSubmitTrigger.cs │ │ │ ├── ObservableTransformChangedTrigger.cs │ │ │ ├── ObservableTrigger2DTrigger.cs │ │ │ ├── ObservableTriggerBase.cs │ │ │ ├── ObservableTriggerExtensions.Component.cs │ │ │ ├── ObservableTriggerExtensions.cs │ │ │ ├── ObservableTriggerTrigger.cs │ │ │ ├── ObservableUpdateSelectedTrigger.cs │ │ │ ├── ObservableUpdateTrigger.cs │ │ │ └── ObservableVisibleTrigger.cs │ │ ├── TypedMonoBehaviour.cs │ │ ├── UnityEqualityComparer.cs │ │ ├── UnityEventExtensions.cs │ │ ├── UnityGraphicExtensions.cs │ │ ├── UnityUIComponentExtensions.cs │ │ └── YieldInstructionCache.cs │ │ └── UnityWinRTBridge │ │ ├── Thread.cs │ │ └── ThreadPoolScheduler_UnityWinRT.cs ├── UnitTests.meta ├── UnitTests │ ├── SceneItems.meta │ ├── SceneItems │ │ ├── Result.cs │ │ ├── Result.cs.meta │ │ ├── UnitTestScene.cs │ │ └── UnitTestScene.cs.meta │ ├── Tools.meta │ ├── Tools │ │ ├── ChainingAssertion.Unity.cs │ │ ├── ChainingAssertion.Unity.cs.meta │ │ ├── Container.cs │ │ ├── Container.cs.meta │ │ ├── Shim.cs │ │ ├── Shim.cs.meta │ │ ├── TestUtil.cs │ │ └── TestUtil.cs.meta │ ├── UnitTests.cs │ ├── UnitTests.cs.meta │ ├── UnitTests.tt │ └── UnitTests.tt.meta ├── UnityVS.meta ├── UnityVS │ └── Editor │ │ ├── SyntaxTree.VisualStudio.Unity.Bridge.dll │ │ ├── SyntaxTree.VisualStudio.Unity.Messaging.dll │ │ └── UnityVS.VersionSpecific.dll ├── smcs.rsp └── smcs.rsp.meta ├── Dlls ├── UniRx.Library.Unity │ ├── Properties │ │ └── AssemblyInfo.cs │ └── UniRx.Library.Unity.csproj └── UniRx.Library │ ├── Properties │ └── AssemblyInfo.cs │ └── UniRx.Library.csproj ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset ├── README.md ├── StoreDocument ├── AnalyzerReference.jpg ├── MVP_Pattern.png ├── MVRP_Loop.png ├── OriginalIcon_511x511.png ├── RxPropInspector.png ├── VSAnalyzer.jpg ├── big_precise.jpg ├── big_precise.psd ├── icon_precise.jpg ├── icon_precise.psd ├── presenterbase_steps.gif ├── small_precise.jpg ├── small_precise.psd ├── ss1.jpg ├── ss2.jpg └── ss3.jpg ├── Tests ├── UniRx.Console │ ├── App.config │ ├── CombineLatestGenerator.tt │ ├── CombineLatestGenerator.txt │ ├── Playground.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── UniRx.Console.csproj │ ├── ZipGenerator.tt │ └── ZipGenerator.txt └── UniRx.Tests │ ├── AggregateTest.cs │ ├── ContinueWithTest.cs │ ├── ConversionTest.cs │ ├── DisposableTest.cs │ ├── DoTest.cs │ ├── DurabilityTest.cs │ ├── Observable.ConcatTest.cs │ ├── Observable.ConcurrencyTest.cs │ ├── Observable.ErrorHandlingTest.cs │ ├── Observable.Events.cs │ ├── Observable.GeneratorTest.cs │ ├── Observable.PagingTest.cs │ ├── Observable.TimeTest.cs │ ├── ObservableTest.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── QueueWorkerTest.cs │ ├── RangeTest.cs │ ├── ReactivePropertyTest.cs │ ├── ReactriveDictionaryTest.cs │ ├── SchedulerTest.cs │ ├── SelectMany.cs │ ├── SubjectTest.cs │ ├── TakeTest.cs │ ├── ToTest.cs │ ├── Tools │ ├── ChainingAssertion.Unity.cs │ ├── Init.cs │ └── TestUtil.cs │ ├── UniRx.Tests.csproj │ ├── WhenAllTest.cs │ └── packages.config ├── UniRx.CSharp.csproj └── UniRx.sln /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/UniRx.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | UniRx 5 | 5.1.0 6 | UniRx 7 | neuecc 8 | neuecc 9 | false 10 | Reactive Extensions for Unity. This is .NET 3.5 subset of UniRx. 11 | 12 | 15 | 16 | en-US 17 | http://opensource.org/licenses/MIT 18 | https://github.com/neuecc/UniRx 19 | Rx Unity LINQ 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /.nuget/pack.bat: -------------------------------------------------------------------------------- 1 | nuget pack UniRx.nuspec -------------------------------------------------------------------------------- /.nuget/push.bat: -------------------------------------------------------------------------------- 1 | nuget push UniRx.5.0.0.nupkg -------------------------------------------------------------------------------- /Analyzer/UniRxAnalyzer/UniRxAnalyzer.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("UniRxAnalyzer.Test")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("UniRxAnalyzer.Test")] 12 | [assembly: AssemblyCopyright("Copyright © 2015")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // Version information for an assembly consists of the following four values: 22 | // 23 | // Major Version 24 | // Minor Version 25 | // Build Number 26 | // Revision 27 | // 28 | // You can specify all the values or you can default the Build and Revision Numbers 29 | // by using the '*' as shown below: 30 | // [assembly: AssemblyVersion("1.0.*")] 31 | [assembly: AssemblyVersion("1.0.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /Analyzer/UniRxAnalyzer/UniRxAnalyzer.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Analyzer/UniRxAnalyzer/UniRxAnalyzer.Vsix/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | UniRxAnalyzer.Vsix 6 | UniRx analyzers. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Analyzer/UniRxAnalyzer/UniRxAnalyzer/Diagnostic.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | UniRxAnalyzer 5 | 1.0.3.2 6 | UniRxAnalyzer 7 | neuecc 8 | https://github.com/neuecc/UniRx 9 | false 10 | Various Analyzers for UniRx 11 | Update for VS2015 RTM. 12 | UniRx, analyzers 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Analyzer/UniRxAnalyzer/UniRxAnalyzer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("UniRxAnalyzer")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("UniRxAnalyzer")] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | 15 | // Setting ComVisible to false makes the types in this assembly not visible 16 | // to COM components. If you need to access a type in this assembly from 17 | // COM, set the ComVisible attribute to true on that type. 18 | [assembly: ComVisible(false)] 19 | 20 | // Version information for an assembly consists of the following four values: 21 | // 22 | // Major Version 23 | // Minor Version 24 | // Build Number 25 | // Revision 26 | // 27 | // You can specify all the values or you can default the Build and Revision Numbers 28 | // by using the '*' as shown below: 29 | [assembly: AssemblyVersion("1.0.3.2")] 30 | [assembly: AssemblyFileVersion("1.0.3.2")] -------------------------------------------------------------------------------- /Analyzer/UniRxAnalyzer/UniRxAnalyzer/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Analyzer/UniRxAnalyzer/UniRxAnalyzer/tools/install.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | 3 | $analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve 4 | 5 | foreach($analyzersPath in $analyzersPaths) 6 | { 7 | # Install the language agnostic analyzers. 8 | if (Test-Path $analyzersPath) 9 | { 10 | foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll) 11 | { 12 | if($project.Object.AnalyzerReferences) 13 | { 14 | $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName) 15 | } 16 | } 17 | } 18 | } 19 | 20 | # $project.Type gives the language name like (C# or VB.NET) 21 | $languageFolder = "" 22 | if($project.Type -eq "C#") 23 | { 24 | $languageFolder = "cs" 25 | } 26 | if($project.Type -eq "VB.NET") 27 | { 28 | $languageFolder = "vb" 29 | } 30 | if($languageFolder -eq "") 31 | { 32 | return 33 | } 34 | 35 | foreach($analyzersPath in $analyzersPaths) 36 | { 37 | # Install language specific analyzers. 38 | $languageAnalyzersPath = join-path $analyzersPath $languageFolder 39 | if (Test-Path $languageAnalyzersPath) 40 | { 41 | foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll) 42 | { 43 | if($project.Object.AnalyzerReferences) 44 | { 45 | $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName) 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Analyzer/UniRxAnalyzer/UniRxAnalyzer/tools/uninstall.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | 3 | $analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve 4 | 5 | foreach($analyzersPath in $analyzersPaths) 6 | { 7 | # Uninstall the language agnostic analyzers. 8 | if (Test-Path $analyzersPath) 9 | { 10 | foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll) 11 | { 12 | if($project.Object.AnalyzerReferences) 13 | { 14 | $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName) 15 | } 16 | } 17 | } 18 | } 19 | 20 | # $project.Type gives the language name like (C# or VB.NET) 21 | $languageFolder = "" 22 | if($project.Type -eq "C#") 23 | { 24 | $languageFolder = "cs" 25 | } 26 | if($project.Type -eq "VB.NET") 27 | { 28 | $languageFolder = "vb" 29 | } 30 | if($languageFolder -eq "") 31 | { 32 | return 33 | } 34 | 35 | foreach($analyzersPath in $analyzersPaths) 36 | { 37 | # Uninstall language specific analyzers. 38 | $languageAnalyzersPath = join-path $analyzersPath $languageFolder 39 | if (Test-Path $languageAnalyzersPath) 40 | { 41 | foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll) 42 | { 43 | if($project.Object.AnalyzerReferences) 44 | { 45 | try 46 | { 47 | $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName) 48 | } 49 | catch 50 | { 51 | 52 | } 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/AssetStoreTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8951e7b9687d74949af2854b82e3601c 3 | folderAsset: yes 4 | timeCreated: 1425282656 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/DroidSansMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/Assets/AssetStoreTools/Editor/DroidSansMono.ttf -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/Assets/AssetStoreTools/Editor/icon.png -------------------------------------------------------------------------------- /Assets/ObjectTest.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50e8d464f8f33c84cb49c3af8e898ceb 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/ObjectTest/Button.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fdaf095aa7510d41888da62d7bd413d 3 | timeCreated: 1435156774 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/Clicker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UniRx.ObjectTest 5 | { 6 | public class Clicker : MonoBehaviour 7 | { 8 | public event Action OnClicked = delegate { }; 9 | 10 | public event Action OnEntered = delegate { }; 11 | 12 | public event Action OnExited = delegate { }; 13 | 14 | #if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO) 15 | 16 | // Disable OnMouse_ event handlers to make it easy to confirm warning. 17 | 18 | void OnMouseDown() 19 | { 20 | OnClicked(); 21 | } 22 | 23 | void OnMouseEnter() 24 | { 25 | OnEntered(); 26 | } 27 | 28 | void OnMouseExit() 29 | { 30 | OnExited(); 31 | } 32 | 33 | #endif 34 | 35 | Subject update; 36 | public int VVV; 37 | 38 | public void Update() 39 | { 40 | var t = (int)Time.time; 41 | if (t % 5 == 0) 42 | { 43 | VVV = t; 44 | } 45 | 46 | if (update != null) update.OnNext(Unit.Default); 47 | } 48 | 49 | public IObservable UpdateAsObservable() 50 | { 51 | return update ?? (update = new Subject()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Assets/ObjectTest/Clicker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4043b787d3435404bb4205088677fdb2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/CountOnly.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEngine.UI; 4 | 5 | public class CountOnly : MonoBehaviour 6 | { 7 | public Text text; 8 | 9 | int count = 0; 10 | 11 | public void Update() 12 | { 13 | text.text = (count++).ToString(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/ObjectTest/CountOnly.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57f661840470c90418e47e6200b71261 3 | timeCreated: 1450100793 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ObjectTest/DispatcherCullingTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace UniRx.ObjectTest 8 | { 9 | public class DispatcherCullingTest : MonoBehaviour 10 | { 11 | public GUIText cullLabel; 12 | private string cullingModeDescription = string.Empty; 13 | 14 | void Start() 15 | { 16 | var cullClicker = cullLabel.gameObject.AddComponent(); 17 | var cullClickerColor = cullClicker.GetComponent().color; 18 | cullClicker.OnEntered += () => cullLabel.GetComponent().color = Color.blue; 19 | cullClicker.OnExited += () => cullLabel.GetComponent().color = cullClickerColor; 20 | cullClicker.OnClicked += () => 21 | { 22 | var values = Enum.GetValues(typeof(MainThreadDispatcher.CullingMode)); 23 | var currentValue = (int)MainThreadDispatcher.cullingMode; 24 | MainThreadDispatcher.cullingMode = (MainThreadDispatcher.CullingMode)((currentValue + 1 == values.Length) ? 0 : currentValue + 1); 25 | }; 26 | } 27 | 28 | void Update() 29 | { 30 | switch (MainThreadDispatcher.cullingMode) 31 | { 32 | case MainThreadDispatcher.CullingMode.Disabled: 33 | cullingModeDescription = "Won't remove any MainThreadDispatchers."; 34 | break; 35 | 36 | case MainThreadDispatcher.CullingMode.Self: 37 | cullingModeDescription = "A new MainThreadDispatcher will remove itself when there's an existing dispatcher."; 38 | break; 39 | 40 | case MainThreadDispatcher.CullingMode.All: 41 | cullingModeDescription = "When a new MainThreadDispatcher is added, search and destroy any excess dispatchers."; 42 | break; 43 | } 44 | cullLabel.text = string.Format("Click to toggle Dispatcher Culling Mode: {0}\n{1}" 45 | , MainThreadDispatcher.cullingMode.ToString(), cullingModeDescription); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Assets/ObjectTest/DispatcherCullingTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5390ee4ca9f48645b5af618e5b4947a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/EditorBehaviourTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d08a9165edad27148bf7f277471be591 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/GameObjectDisplacer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | 5 | namespace UniRx.ObjectTest 6 | { 7 | public class GameObjectDisplacer : MonoBehaviour 8 | { 9 | public GameObject originalObject; 10 | public Vector3 displacement; 11 | 12 | private int Counter = 0; 13 | private static GameObjectDisplacer _instance; 14 | 15 | void Awake() 16 | { 17 | originalObject.AddComponent(); 18 | 19 | if (_instance == null) 20 | { 21 | _instance = this; 22 | 23 | AwakeDetector.OnAwake += (g) => GameObjectCloned(g); 24 | } 25 | else 26 | { 27 | Destroy(this.gameObject); 28 | } 29 | } 30 | 31 | public void GameObjectCloned(GameObject g) 32 | { 33 | if (originalObject != null) 34 | { 35 | g.name = string.Format("{0} #{1}", originalObject.name, Counter++); 36 | g.transform.position += displacement * Counter; 37 | } 38 | } 39 | } 40 | 41 | public class AwakeDetector : MonoBehaviour 42 | { 43 | public static event Action OnAwake = delegate { }; 44 | 45 | void Awake() 46 | { 47 | OnAwake(this.gameObject); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Assets/ObjectTest/GameObjectDisplacer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fa67989512d4214488451dcafef6425 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/IntervalTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd1302d3c1666e241928a17e7cf0abdb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/LoadLevelTest.cs: -------------------------------------------------------------------------------- 1 | #if !UNITY_5_3 2 | using System; 3 | using System.Collections; 4 | using UnityEngine; 5 | 6 | namespace UniRx.ObjectTest 7 | { 8 | public class LoadLevelTest : MonoBehaviour 9 | { 10 | void Start() 11 | { 12 | var ll = GameObject.Find("LoadLevel"); 13 | var llcolor = ll.GetComponent().color; 14 | var cll = ll.AddComponent(); 15 | cll.OnClicked += () => Application.LoadLevel("LoadLevelTestNew"); 16 | cll.OnEntered += () => cll.GetComponent().color = Color.blue; 17 | cll.OnExited += () => cll.GetComponent().color = llcolor; 18 | 19 | var lla = GameObject.Find("LoadLevelAdditive"); 20 | var llacolor = lla.GetComponent().color; 21 | var clla = lla.AddComponent(); 22 | 23 | clla.OnClicked += () => Application.LoadLevelAdditive("LoadLevelTestAdditive"); 24 | clla.OnEntered += () => clla.GetComponent().color = Color.blue; 25 | clla.OnExited += () => clla.GetComponent().color = llacolor; 26 | } 27 | } 28 | } 29 | 30 | #endif -------------------------------------------------------------------------------- /Assets/ObjectTest/LoadLevelTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 917c041d082a38f40bda99bf1b7738be 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/MyStateMachine.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_5 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using UnityEngine; 8 | 9 | namespace Assets.ObjectTest 10 | { 11 | 12 | public class MyStateMachine : StateMachineBehaviour 13 | { 14 | //public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 15 | //{ 16 | // base.OnStateMove(animator, stateInfo, layerIndex); 17 | // Debug.Log("Move Called"); 18 | //} 19 | 20 | //public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 21 | //{ 22 | // base.OnStateEnter(animator, stateInfo, layerIndex); 23 | // Debug.Log("State Enter"); 24 | //} 25 | } 26 | } 27 | 28 | #endif -------------------------------------------------------------------------------- /Assets/ObjectTest/MyStateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2057d72c185c0340b0e8cfc794127f9 3 | timeCreated: 1435156738 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ObjectTest/New Animator Controller.controller: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!91 &9100000 4 | AnimatorController: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: New Animator Controller 9 | serializedVersion: 5 10 | m_AnimatorParameters: [] 11 | m_AnimatorLayers: 12 | - serializedVersion: 5 13 | m_Name: Base Layer 14 | m_StateMachine: {fileID: 110797916} 15 | m_Mask: {fileID: 0} 16 | m_Motions: [] 17 | m_Behaviours: [] 18 | m_BlendingMode: 0 19 | m_SyncedLayerIndex: -1 20 | m_DefaultWeight: 0 21 | m_IKPass: 0 22 | m_SyncedLayerAffectsTiming: 0 23 | m_Controller: {fileID: 0} 24 | --- !u!114 &11421932 25 | MonoBehaviour: 26 | m_ObjectHideFlags: 1 27 | m_PrefabParentObject: {fileID: 0} 28 | m_PrefabInternal: {fileID: 0} 29 | m_GameObject: {fileID: 0} 30 | m_Enabled: 1 31 | m_EditorHideFlags: 0 32 | m_Script: {fileID: 11500000, guid: b2057d72c185c0340b0e8cfc794127f9, type: 3} 33 | m_Name: 34 | m_EditorClassIdentifier: 35 | --- !u!1107 &110797916 36 | AnimatorStateMachine: 37 | serializedVersion: 5 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 0} 41 | m_Name: Base Layer 42 | m_ChildStates: [] 43 | m_ChildStateMachines: [] 44 | m_AnyStateTransitions: [] 45 | m_EntryTransitions: [] 46 | m_StateMachineTransitions: 47 | data: 48 | first: {fileID: 110797916} 49 | second: [] 50 | m_StateMachineBehaviours: 51 | - {fileID: 11421932} 52 | m_AnyStatePosition: {x: 144, y: -36, z: 0} 53 | m_EntryPosition: {x: 180, y: 84, z: 0} 54 | m_ExitPosition: {x: 800, y: 120, z: 0} 55 | m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} 56 | m_DefaultState: {fileID: 0} 57 | -------------------------------------------------------------------------------- /Assets/ObjectTest/New Animator Controller.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 106fa5ee00061b5499ea7ab2eead334e 3 | timeCreated: 1435156687 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/RotateGameObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRx; 3 | using UnityEngine; 4 | 5 | namespace UniRx.ObjectTest 6 | { 7 | public class RotateGameObject : MonoBehaviour 8 | { 9 | public GameObject target; 10 | public Vector3 angle; 11 | 12 | void Awake() 13 | { 14 | if (angle == Vector3.zero) 15 | { 16 | angle = new Vector3(2, 4, 4); 17 | } 18 | } 19 | 20 | void Start() 21 | { 22 | var interval = Observable 23 | .Interval(System.TimeSpan.FromMilliseconds(20)) 24 | .Do((l) => target.transform.Rotate(angle)); 25 | 26 | interval 27 | .CatchIgnore((Exception ex) => Debug.LogWarning(ex)) 28 | .Subscribe(); 29 | 30 | /* 31 | .Subscribe((s) => 32 | { 33 | if (g != null) 34 | g.transform.Rotate(angle); 35 | else 36 | throw new Exception("Can't find GameObject `Cylinder`!"); 37 | }); 38 | */ 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Assets/ObjectTest/RotateGameObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61bb465eaef753741836179da83c606a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/Sandbox2.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UniRx; 3 | using UniRx.Triggers; 4 | using System.Collections; 5 | using System.Linq; 6 | using System; 7 | using System.Collections.Generic; 8 | using UnityEngine.UI; 9 | // using UnityEngine.SceneManagement; 10 | 11 | public class MyEventClass 12 | { 13 | public event Action Hoge; 14 | public void Push(int x) 15 | { 16 | Hoge(x); 17 | } 18 | } 19 | 20 | public class MoGe 21 | { 22 | public void Huga() 23 | { 24 | } 25 | } 26 | 27 | // for Scenes/NextSandBox 28 | public class Sandbox2 : MonoBehaviour 29 | { 30 | public Button button; 31 | 32 | void Awake() 33 | { 34 | MainThreadDispatcher.Initialize(); 35 | } 36 | 37 | void Aaa(Action action) 38 | { 39 | } 40 | 41 | //int clickCount = 0; 42 | //AsyncOperation ao = null; 43 | 44 | void Start() 45 | { 46 | 47 | button.OnClickAsObservable().Subscribe(_ => 48 | { 49 | 50 | var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); 51 | 52 | cube.UpdateAsObservable() 53 | .SampleFrame(30) 54 | .TakeUntilDestroy(cube) // add line. 55 | .Subscribe( 56 | __ => 57 | { 58 | var p = cube.transform.position; 59 | cube.transform.position = new Vector3(p.x + 0.4f, p.y, p.z); 60 | }, 61 | e => Debug.LogError("Error! " + e), 62 | () => Debug.Log("Completed!")); 63 | 64 | GameObject.Destroy(cube, 3f); 65 | 66 | Debug.Log(cube); 67 | }); 68 | } 69 | } -------------------------------------------------------------------------------- /Assets/ObjectTest/Sandbox2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e866ab5ccb1eda45a190fce8c1a4729 3 | timeCreated: 1430930095 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ObjectTest/SimpleMultiline.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UniRx; 4 | 5 | public class SimpleMultiline : MonoBehaviour 6 | { 7 | 8 | public StringReactiveProperty SinglelineString; 9 | 10 | [MultilineReactiveProperty] 11 | public StringReactiveProperty MultineString; 12 | 13 | [Multiline(3)] 14 | public string ML; 15 | 16 | [TextArea(5, 10)] 17 | public string TA; 18 | 19 | void Start() 20 | { 21 | SinglelineString.Subscribe(x => 22 | { 23 | Debug.Log(x); 24 | }); 25 | 26 | MultineString.Subscribe(x => 27 | { 28 | Debug.Log(x); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/ObjectTest/SimpleMultiline.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a15fa4fd14a9c24a94c88d95ccc0eb6 3 | timeCreated: 1448634214 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ObjectTest/UniRxTestSandbox.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02440cdbc97b02245978ad23e78a3189 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/WorkerThreadTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using UniRx; 4 | using UnityEngine; 5 | 6 | namespace UniRx.ObjectTest 7 | { 8 | public class WorkerThreadTest : MonoBehaviour 9 | { 10 | void Awake() 11 | { 12 | #if UNITY_METRO 13 | // Windows Store doesn't support System.Threading.Thread. 14 | // Other platforms can use both ThreadPool and System.Threading.Thread. 15 | // ThreadPool.QueueUserWorkItem(RegisterApplicationQuitEvent); 16 | // ThreadPool.QueueUserWorkItem(SpawnCapsules); 17 | #else 18 | Thread thread = new Thread(SpawnCapsules); 19 | thread.Start(); 20 | #endif 21 | } 22 | 23 | private void RegisterApplicationQuitEvent(object a) 24 | { 25 | MainThreadDispatcher.OnApplicationQuitAsObservable().Subscribe(_ => Debug.Log("OnApplicationQuitAsObservable")); 26 | } 27 | 28 | private void SpawnCapsules(object a) 29 | { 30 | // Create capsules one by one. 31 | Observable.Interval(TimeSpan.FromMilliseconds(300)) 32 | .Take(5) 33 | .Subscribe((s) => 34 | { 35 | var g = GameObject.CreatePrimitive(PrimitiveType.Capsule); 36 | g.name = "Capsule " + s; 37 | g.transform.position += new Vector3(s, 0, 0); 38 | }); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Assets/ObjectTest/WorkerThreadTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dca0dc71a1038104391fbfe361f092e7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ObjectTest/YieldTest.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UniRx; 4 | using System; 5 | 6 | public class YieldTest : MonoBehaviour 7 | { 8 | public void Start() 9 | { 10 | //Observable.Create(observer => 11 | //{ 12 | // observer.OnNext(Unit.Default); 13 | // observer.OnCompleted(); 14 | // return Disposable.Empty; 15 | //}) 16 | //Observable.ReturnUnit() 17 | // .Finally(() => 18 | // { 19 | // Debug.Log("finally"); 20 | // }) 21 | // .Subscribe(_ => 22 | // { 23 | // Debug.Log("onnext"); 24 | // }, () => Debug.Log("comp")); 25 | this.StartCoroutine(this.SomeCoroutine()); 26 | } 27 | 28 | private IEnumerator SomeCoroutine() 29 | { 30 | Debug.Log("begin SomeCoroutine"); 31 | yield return this.SomeObservable().StartAsCoroutine(); 32 | Debug.Log("end SomeCoroutine"); //not called! 33 | } 34 | 35 | private IObservable SomeObservable() 36 | { 37 | Debug.Log("begin SomeObservable"); 38 | return Observable.ReturnUnit() 39 | .Do(_ => Debug.Log("end SomeObservable")); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Assets/ObjectTest/YieldTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b80633b2d5102df4b8c4a7b82962f65b 3 | timeCreated: 1444309959 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ObjectTest/clicker.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/Assets/ObjectTest/clicker.jpg -------------------------------------------------------------------------------- /Assets/ObjectTest/clicker.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f4f1075987dfa746b1b6a1043bfdfe0 3 | TextureImporter: 4 | fileIDToRecycleName: 5 | 21300000: clicker 6 | serializedVersion: 2 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | linearTexture: 0 11 | correctGamma: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapFadeDistanceStart: 1 15 | mipMapFadeDistanceEnd: 3 16 | bumpmap: 17 | convertToNormalMap: 0 18 | externalNormalMap: 0 19 | heightScale: .25 20 | normalMapFilter: 0 21 | isReadable: 0 22 | grayScaleToAlpha: 0 23 | generateCubemap: 0 24 | seamlessCubemap: 0 25 | textureFormat: -1 26 | maxTextureSize: 1024 27 | textureSettings: 28 | filterMode: -1 29 | aniso: 1 30 | mipBias: -1 31 | wrapMode: 1 32 | nPOTScale: 0 33 | lightmap: 0 34 | compressionQuality: 50 35 | spriteMode: 1 36 | spriteExtrude: 1 37 | spriteMeshType: 1 38 | alignment: 0 39 | spritePivot: {x: .5, y: .5} 40 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 41 | spritePixelsToUnits: 100 42 | alphaIsTransparency: 1 43 | textureType: 8 44 | buildTargetSettings: 45 | - buildTarget: iPhone 46 | maxTextureSize: 1024 47 | textureFormat: -2 48 | compressionQuality: 50 49 | spriteSheet: 50 | sprites: [] 51 | spritePackingTag: 52 | userData: 53 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fb33e56c9bfdf9449525a90016ce863 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Scenes/Clean.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93251f6ee005afd4f8ff524f0bee41fe 3 | timeCreated: 1450100742 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/LoadLevelTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2efb166056ec684583f4c1b0a9d072c 3 | timeCreated: 1425282656 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/LoadLevelTestAdditive.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47ef72962a830f647a965e97fa833fd5 3 | timeCreated: 1425282656 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/LoadLevelTestNew.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e998d404e335b24887738e21451f8ed 3 | timeCreated: 1425282656 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/MultipleDispatchersTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 242f9f44d749cd848b4f44ec1b111afd 3 | timeCreated: 1425282656 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/NextSandBox.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9746d751da96ee9488fe35e2b9ee2dfd 3 | timeCreated: 1427099831 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/TestSandbox.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76ec0772b181e9b46b00cfa89d2c4d48 3 | timeCreated: 1425282656 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/UnitAssertion.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0ada73eb8475644e93cb8c9a31279cc 3 | timeCreated: 1450073810 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/WorkerThreadTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab31ecac1ccd4f143a354b7f5a87ba5e 3 | timeCreated: 1425282656 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniRx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 635d02b0a3adf8344b83acd8706240c3 3 | folderAsset: yes 4 | timeCreated: 1425282656 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample01_ObservableWWW.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d18d2078e0118cf4a9454f0a3b855691 3 | timeCreated: 1425282659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample02_ObservableTriggers.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UniRx.Triggers; // Triggers Namepsace 3 | using System; 4 | 5 | namespace UniRx.Examples 6 | { 7 | public class Sample02_ObservableTriggers : MonoBehaviour 8 | { 9 | void Start() 10 | { 11 | // Get the plain object 12 | var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); 13 | 14 | // Add ObservableXxxTrigger for handle MonoBehaviour's event as Observable 15 | cube.AddComponent() 16 | .UpdateAsObservable() 17 | .SampleFrame(30) 18 | .Subscribe(x => Debug.Log("cube"), () => Debug.Log("destroy")); 19 | 20 | // destroy after 3 second:) 21 | GameObject.Destroy(cube, 3f); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample02_ObservableTriggers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dbe06d7ba757f3240a61f3c13bd0e4a0 3 | timeCreated: 1425282659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample03_GameObjectAsObservable.cs: -------------------------------------------------------------------------------- 1 | #if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO) 2 | 3 | using UnityEngine; 4 | using UniRx.Triggers; // for enable gameObject.EventAsObservbale() 5 | 6 | namespace UniRx.Examples 7 | { 8 | public class Sample03_GameObjectAsObservable : MonoBehaviour 9 | { 10 | void Start() 11 | { 12 | // All events can subscribe by ***AsObservable if enables UniRx.Triggers 13 | this.OnMouseDownAsObservable() 14 | .SelectMany(_ => this.gameObject.UpdateAsObservable()) 15 | .TakeUntil(this.gameObject.OnMouseUpAsObservable()) 16 | .Select(_ => Input.mousePosition) 17 | .RepeatUntilDestroy(this) 18 | .Subscribe(x => Debug.Log(x), ()=> Debug.Log("!!!" + "complete")); 19 | } 20 | } 21 | } 22 | 23 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample03_GameObjectAsObservable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee855b2348c6bfd4a86774265bc64356 3 | timeCreated: 1425282659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample04_ConvertFromUnityCallback.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad39f59973882ae4d8a1e4b8cc71b24b 3 | timeCreated: 1425282659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample05_ConvertFromCoroutine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | 5 | namespace UniRx.Examples 6 | { 7 | public class Sample05_ConvertFromCoroutine 8 | { 9 | // public method 10 | public static IObservable GetWWW(string url) 11 | { 12 | // convert coroutine to IObservable 13 | return Observable.FromCoroutine((observer, cancellationToken) => GetWWWCore(url, observer, cancellationToken)); 14 | } 15 | 16 | // IEnumerator with callback 17 | static IEnumerator GetWWWCore(string url, IObserver observer, CancellationToken cancellationToken) 18 | { 19 | var www = new UnityEngine.WWW(url); 20 | while (!www.isDone && !cancellationToken.IsCancellationRequested) 21 | { 22 | yield return null; 23 | } 24 | 25 | if (cancellationToken.IsCancellationRequested) yield break; 26 | 27 | if (www.error != null) 28 | { 29 | observer.OnError(new Exception(www.error)); 30 | } 31 | else 32 | { 33 | observer.OnNext(www.text); 34 | observer.OnCompleted(); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample05_ConvertFromCoroutine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b5cfe9d61a58ad4ca44c889d82ccc2c 3 | timeCreated: 1425282658 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample06_ConvertToCoroutine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2af227a4ed7f39042a636f10696a2c0d 3 | timeCreated: 1425282658 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample07_OrchestratIEnumerator.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable 0168 2 | 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using UnityEngine; 9 | 10 | namespace UniRx.Examples 11 | { 12 | public class Sample07_OrchestratIEnumerator : MonoBehaviour 13 | { 14 | // two coroutines 15 | IEnumerator AsyncA() 16 | { 17 | Debug.Log("a start"); 18 | yield return new WaitForSeconds(3); 19 | Debug.Log("a end"); 20 | } 21 | 22 | IEnumerator AsyncB() 23 | { 24 | Debug.Log("b start"); 25 | yield return new WaitForEndOfFrame(); 26 | Debug.Log("b end"); 27 | } 28 | 29 | void Start() 30 | { 31 | // after completed AsyncA, run AsyncB as continuous routine. 32 | // UniRx expands SelectMany(IEnumerator) as SelectMany(IEnumerator.ToObservable()) 33 | var cancel = Observable.FromCoroutine(AsyncA) 34 | .SelectMany(AsyncB) 35 | .Subscribe(); 36 | 37 | // If you want to stop Coroutine(as cancel), call subscription.Dispose() 38 | // cancel.Dispose(); 39 | } 40 | } 41 | } 42 | 43 | 44 | #pragma warning restore 0168 -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample07_OrchestratIEnumerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7f36d874287ba845942ca19312b77b4 3 | timeCreated: 1425282659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample08_DetectDoubleClick.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using UnityEngine; 7 | 8 | namespace UniRx.Examples 9 | { 10 | public class Sample08_DetectDoubleClick : MonoBehaviour 11 | { 12 | void Start() 13 | { 14 | // Global event handling is very useful. 15 | // UniRx can handle there events. 16 | // Observable.EveryUpdate/EveryFixedUpdate/EveryEndOfFrame 17 | // Observable.EveryApplicationFocus/EveryApplicationPause 18 | // Observable.OnceApplicationQuit 19 | 20 | // This DoubleCLick Sample is from 21 | // The introduction to Reactive Programming you've been missing 22 | // https://gist.github.com/staltz/868e7e9bc2a7b8c1f754 23 | 24 | var clickStream = Observable.EveryUpdate() 25 | .Where(_ => Input.GetMouseButtonDown(0)); 26 | 27 | clickStream.Buffer(clickStream.Throttle(TimeSpan.FromMilliseconds(250))) 28 | .Where(xs => xs.Count >= 2) 29 | .Subscribe(xs => Debug.Log("DoubleClick Detected! Count:" + xs.Count)); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample08_DetectDoubleClick.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b528bbabea03ac841844a40408326ffc 3 | timeCreated: 1425282659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample09_EventHandling.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 03bb64cbe2323dc49b3f4277c2fb534d 3 | timeCreated: 1425282656 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample10_MainThreadDispatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | 5 | namespace UniRx.Examples 6 | { 7 | public class Sample10_MainThreadDispatcher 8 | { 9 | public void Run() 10 | { 11 | // MainThreadDispatcher is heart of Rx and Unity integration 12 | 13 | // StartCoroutine can start coroutine besides MonoBehaviour. 14 | MainThreadDispatcher.StartCoroutine(TestAsync()); 15 | 16 | // We have two way of run coroutine, FromCoroutine or StartCoroutine. 17 | // StartCoroutine is Unity primitive way and it's awaitable by yield return. 18 | // FromCoroutine is Rx, it's composable and cancellable by subscription's IDisposable. 19 | // FromCoroutine's overload can have return value, see:Sample05_ConvertFromCoroutine 20 | Observable.FromCoroutine(TestAsync).Subscribe(); 21 | 22 | // Add Action to MainThreadDispatcher. Action is saved queue, run on next update. 23 | MainThreadDispatcher.Post(_ => Debug.Log("test"), null); 24 | 25 | // Timebased operations is run on MainThread(as default) 26 | // All timebased operation(Interval, Timer, Delay, Buffer, etc...)is single thread, thread safe! 27 | Observable.Interval(TimeSpan.FromSeconds(1)) 28 | .Subscribe(x => Debug.Log(x)); 29 | 30 | // Observable.Start use ThreadPool Scheduler as default. 31 | // ObserveOnMainThread return to mainthread 32 | Observable.Start(() => Unit.Default) // asynchronous work 33 | .ObserveOnMainThread() 34 | .Subscribe(x => Debug.Log(x)); 35 | } 36 | 37 | IEnumerator TestAsync() 38 | { 39 | Debug.Log("a"); 40 | yield return new WaitForSeconds(1); 41 | Debug.Log("b"); 42 | yield return new WaitForSeconds(1); 43 | Debug.Log("c"); 44 | yield return new WaitForSeconds(1); 45 | Debug.Log("d"); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample10_MainThreadDispatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7e9627c7376c5e4abad3a2982051721 3 | timeCreated: 1425282659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample11_Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UniRx.Diagnostics; 4 | using UnityEngine; 5 | 6 | namespace UniRx.Examples 7 | { 8 | public class Sample11_Logger 9 | { 10 | // UniRx.Diagnostics.Logger 11 | // logger is threadsafe, define per class with name. 12 | static readonly UniRx.Diagnostics.Logger logger = new UniRx.Diagnostics.Logger("Sample11"); 13 | 14 | // call once at applicationinit 15 | public void ApplicationInitialize() 16 | { 17 | // Log as Stream, UniRx.Diagnostics.ObservableLogger.Listener is IObservable 18 | // You can subscribe and output to any place. 19 | ObservableLogger.Listener.LogToUnityDebug(); 20 | 21 | // for example, filter only Exception and upload to web. 22 | // (make custom sink(IObserver) is better to use) 23 | ObservableLogger.Listener 24 | .Where(x => x.LogType == LogType.Exception) 25 | .Subscribe(x => 26 | { 27 | // ObservableWWW.Post("", null).Subscribe(); 28 | }); 29 | } 30 | 31 | public void Run() 32 | { 33 | // Debug is write only DebugBuild. 34 | logger.Debug("Debug Message"); 35 | 36 | // or other logging methods 37 | logger.Log("Message"); 38 | logger.Exception(new Exception("test exception")); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample11_Logger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69a86d851de4ff84aaf023d707d0f1ad 3 | timeCreated: 1425282658 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample12Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e11e18571780f7344a92e1a45974701a 3 | timeCreated: 1425643117 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample12_ReactiveProperty.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 577cad547552f9f4e9e993261db7ab44 3 | timeCreated: 1425637242 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample13Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 862645bd3c32c054ebb7c31d903605be 3 | timeCreated: 1425907486 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample13_ToDoApp.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89a489c663a87e348ac12644ee59f898 3 | timeCreated: 1425907659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample13_ToDoItem.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7059502be0050c4a9cd9ef0e82a720b 3 | timeCreated: 1426146513 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample14Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e388e4fa5c5dec9408daacff8d477857 3 | timeCreated: 1429741593 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample14_CubeLevel1.cs: -------------------------------------------------------------------------------- 1 | using UniRx; 2 | using UnityEngine; 3 | 4 | namespace Assets.UniRx.Examples 5 | { 6 | // see:Sample14_PresenterBase 7 | public class Sample14_CubeLevel1 : PresenterBase 8 | { 9 | public IReactiveProperty Number { get; private set; } 10 | 11 | public Sample14_CubeLevel2 child1; 12 | public Sample14_CubeLevel2 child2; 13 | 14 | protected override IPresenter[] Children 15 | { 16 | get 17 | { 18 | return new IPresenter[] { child1, child2 }; 19 | } 20 | } 21 | 22 | protected override void OnAwake() 23 | { 24 | AnimationMarker.MarkAwakePhase(this); 25 | } 26 | 27 | protected override void BeforeInitialize(float argument) 28 | { 29 | AnimationMarker.MarkCapturePhase(this); 30 | 31 | child1.PropagateArgument(argument * 2); 32 | child2.PropagateArgument(argument * 2); 33 | } 34 | 35 | // Initialize is like constructor. 36 | // This phase, called child -> parent. 37 | // Therefore you can touch child's property safety. 38 | protected override void Initialize(float argument) 39 | { 40 | AnimationMarker.MarkBubblingPhase(this); 41 | 42 | Number = new ReactiveProperty(argument); 43 | Number.Subscribe(x => 44 | { 45 | child1.Number.Value = x; 46 | child2.Number.Value = x; 47 | this.GetComponent().material.color = new Color(0.2f, x, 0.2f, 0); 48 | }); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample14_CubeLevel1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9894994bae43b94ca032056937e378c 3 | timeCreated: 1429739583 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 50 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample14_CubeLevel2.cs: -------------------------------------------------------------------------------- 1 | using UniRx; 2 | using UnityEngine; 3 | 4 | namespace Assets.UniRx.Examples 5 | { 6 | public class Sample14_CubeLevel2 : PresenterBase 7 | { 8 | public IReactiveProperty Number { get;private set; } 9 | 10 | protected override IPresenter[] Children 11 | { 12 | get 13 | { 14 | return EmptyChildren; 15 | } 16 | } 17 | 18 | protected override void OnAwake() 19 | { 20 | AnimationMarker.MarkAwakePhase(this); 21 | } 22 | 23 | protected override void BeforeInitialize(float argument) 24 | { 25 | AnimationMarker.MarkCapturePhase(this); 26 | } 27 | 28 | protected override void Initialize(float argument) 29 | { 30 | AnimationMarker.MarkBubblingPhase(this); 31 | 32 | Number = new ReactiveProperty(argument); 33 | Number.Subscribe(x => 34 | { 35 | this.GetComponent().material.color = new Color(x, 0.2f, 0.2f, 0); 36 | }); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample14_CubeLevel2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6a11a427af74204dad7e88d3204a889 3 | timeCreated: 1429739565 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 100 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Examples/Sample14_PresenterBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4c7b0029a0874243b11788de7d1e4aa 3 | timeCreated: 1429739565 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 300 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Disposables/BooleanDisposable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace UniRx 5 | { 6 | public class BooleanDisposable : IDisposable, ICancelable 7 | { 8 | public bool IsDisposed { get; private set; } 9 | 10 | public BooleanDisposable() 11 | { 12 | 13 | } 14 | 15 | internal BooleanDisposable(bool isDisposed) 16 | { 17 | IsDisposed = isDisposed; 18 | } 19 | 20 | public void Dispose() 21 | { 22 | if (!IsDisposed) IsDisposed = true; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Disposables/Disposable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace UniRx 5 | { 6 | public static class Disposable 7 | { 8 | public static readonly IDisposable Empty = EmptyDisposable.Singleton; 9 | 10 | public static IDisposable Create(Action disposeAction) 11 | { 12 | return new AnonymousDisposable(disposeAction); 13 | } 14 | 15 | class EmptyDisposable : IDisposable 16 | { 17 | public static EmptyDisposable Singleton = new EmptyDisposable(); 18 | 19 | private EmptyDisposable() 20 | { 21 | 22 | } 23 | 24 | public void Dispose() 25 | { 26 | } 27 | } 28 | 29 | class AnonymousDisposable : IDisposable 30 | { 31 | bool isDisposed = false; 32 | readonly Action dispose; 33 | 34 | public AnonymousDisposable(Action dispose) 35 | { 36 | this.dispose = dispose; 37 | } 38 | 39 | public void Dispose() 40 | { 41 | if (!isDisposed) 42 | { 43 | isDisposed = true; 44 | dispose(); 45 | } 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Disposables/DisposableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniRx 5 | { 6 | public static partial class DisposableExtensions 7 | { 8 | /// Add disposable(self) to CompositeDisposable(or other ICollection). Return value is self disposable. 9 | public static T AddTo(this T disposable, ICollection container) 10 | where T : IDisposable 11 | { 12 | if (disposable == null) throw new ArgumentNullException("disposable"); 13 | if (container == null) throw new ArgumentNullException("container"); 14 | 15 | container.Add(disposable); 16 | 17 | return disposable; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Disposables/ICancelable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace UniRx 6 | { 7 | public interface ICancelable : IDisposable 8 | { 9 | bool IsDisposed { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Disposables/MultipleAssignmentDisposable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace UniRx 5 | { 6 | public class MultipleAssignmentDisposable : IDisposable, ICancelable 7 | { 8 | static readonly BooleanDisposable True = new BooleanDisposable(true); 9 | 10 | object gate = new object(); 11 | IDisposable current; 12 | 13 | public bool IsDisposed 14 | { 15 | get 16 | { 17 | lock (gate) 18 | { 19 | return current == True; 20 | } 21 | } 22 | } 23 | 24 | public IDisposable Disposable 25 | { 26 | get 27 | { 28 | lock (gate) 29 | { 30 | return (current == True) 31 | ? UniRx.Disposable.Empty 32 | : current; 33 | } 34 | } 35 | set 36 | { 37 | var shouldDispose = false; 38 | lock (gate) 39 | { 40 | shouldDispose = (current == True); 41 | if (!shouldDispose) 42 | { 43 | current = value; 44 | } 45 | } 46 | if (shouldDispose && value != null) 47 | { 48 | value.Dispose(); 49 | } 50 | } 51 | } 52 | 53 | public void Dispose() 54 | { 55 | IDisposable old = null; 56 | 57 | lock (gate) 58 | { 59 | if (current != True) 60 | { 61 | old = current; 62 | current = True; 63 | } 64 | } 65 | 66 | if (old != null) old.Dispose(); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Disposables/ScheduledDisposable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace UniRx 5 | { 6 | public sealed class ScheduledDisposable : ICancelable 7 | { 8 | private readonly IScheduler scheduler; 9 | private volatile IDisposable disposable; 10 | private int isDisposed = 0; 11 | 12 | public ScheduledDisposable(IScheduler scheduler, IDisposable disposable) 13 | { 14 | this.scheduler = scheduler; 15 | this.disposable = disposable; 16 | } 17 | 18 | public IScheduler Scheduler 19 | { 20 | get { return scheduler; } 21 | } 22 | 23 | public IDisposable Disposable 24 | { 25 | get { return disposable; } 26 | } 27 | 28 | public bool IsDisposed 29 | { 30 | get { return isDisposed != 0; } 31 | } 32 | 33 | public void Dispose() 34 | { 35 | Scheduler.Schedule(DisposeInner); 36 | } 37 | 38 | private void DisposeInner() 39 | { 40 | if (Interlocked.Increment(ref isDisposed) == 1) 41 | { 42 | disposable.Dispose(); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Disposables/SerialDisposable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace UniRx 5 | { 6 | public class SerialDisposable : IDisposable, ICancelable 7 | { 8 | readonly object gate = new object(); 9 | IDisposable current; 10 | bool disposed; 11 | 12 | public bool IsDisposed { get { lock (gate) { return disposed; } } } 13 | 14 | public IDisposable Disposable 15 | { 16 | get 17 | { 18 | return current; 19 | } 20 | set 21 | { 22 | var shouldDispose = false; 23 | var old = default(IDisposable); 24 | lock (gate) 25 | { 26 | shouldDispose = disposed; 27 | if (!shouldDispose) 28 | { 29 | old = current; 30 | current = value; 31 | } 32 | } 33 | if (old != null) 34 | { 35 | old.Dispose(); 36 | } 37 | if (shouldDispose && value != null) 38 | { 39 | value.Dispose(); 40 | } 41 | } 42 | } 43 | 44 | public void Dispose() 45 | { 46 | var old = default(IDisposable); 47 | 48 | lock (gate) 49 | { 50 | if (!disposed) 51 | { 52 | disposed = true; 53 | old = current; 54 | current = null; 55 | } 56 | } 57 | 58 | if (old != null) 59 | { 60 | old.Dispose(); 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Disposables/SingleAssignmentDisposable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace UniRx 5 | { 6 | // should be use Interlocked.CompareExchange for Threadsafe? 7 | // but CompareExchange cause ExecutionEngineException on iOS. 8 | // AOT... 9 | // use lock instead 10 | 11 | public class SingleAssignmentDisposable : IDisposable, ICancelable 12 | { 13 | readonly object gate = new object(); 14 | IDisposable current; 15 | bool disposed; 16 | 17 | public bool IsDisposed { get { lock (gate) { return disposed; } } } 18 | 19 | public IDisposable Disposable 20 | { 21 | get 22 | { 23 | return current; 24 | } 25 | set 26 | { 27 | var old = default(IDisposable); 28 | bool alreadyDisposed; 29 | lock (gate) 30 | { 31 | alreadyDisposed = disposed; 32 | old = current; 33 | if (!alreadyDisposed) 34 | { 35 | if (value == null) return; 36 | current = value; 37 | } 38 | } 39 | 40 | if (alreadyDisposed && value != null) 41 | { 42 | value.Dispose(); 43 | return; 44 | } 45 | 46 | if (old != null) throw new InvalidOperationException("Disposable is already set"); 47 | } 48 | } 49 | 50 | 51 | public void Dispose() 52 | { 53 | IDisposable old = null; 54 | 55 | lock (gate) 56 | { 57 | if (!disposed) 58 | { 59 | disposed = true; 60 | old = current; 61 | current = null; 62 | } 63 | } 64 | 65 | if (old != null) old.Dispose(); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/InternalUtil/ImmutableList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.InternalUtil 4 | { 5 | public class ImmutableList 6 | { 7 | public static readonly ImmutableList Empty = new ImmutableList(); 8 | 9 | T[] data; 10 | 11 | public T[] Data 12 | { 13 | get { return data; } 14 | } 15 | 16 | ImmutableList() 17 | { 18 | data = new T[0]; 19 | } 20 | 21 | public ImmutableList(T[] data) 22 | { 23 | this.data = data; 24 | } 25 | 26 | public ImmutableList Add(T value) 27 | { 28 | var newData = new T[data.Length + 1]; 29 | Array.Copy(data, newData, data.Length); 30 | newData[data.Length] = value; 31 | return new ImmutableList(newData); 32 | } 33 | 34 | public ImmutableList Remove(T value) 35 | { 36 | var i = IndexOf(value); 37 | if (i < 0) return this; 38 | 39 | var length = data.Length; 40 | if (length == 1) return Empty; 41 | 42 | var newData = new T[length - 1]; 43 | 44 | Array.Copy(data, 0, newData, 0, i); 45 | Array.Copy(data, i + 1, newData, i, length - i - 1); 46 | 47 | return new ImmutableList(newData); 48 | } 49 | 50 | public int IndexOf(T value) 51 | { 52 | for (var i = 0; i < data.Length; ++i) 53 | { 54 | // ImmutableList only use for IObserver(no worry for boxed) 55 | if (object.Equals(data[i], value)) return i; 56 | } 57 | return -1; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Notifiers/BooleanNotifier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace UniRx 6 | { 7 | /// 8 | /// Notify boolean flag. 9 | /// 10 | public class BooleanNotifier : IObservable 11 | { 12 | readonly Subject boolTrigger = new Subject(); 13 | 14 | bool boolValue; 15 | /// Current flag value 16 | public bool Value 17 | { 18 | get { return boolValue; } 19 | set 20 | { 21 | boolValue = value; 22 | boolTrigger.OnNext(value); 23 | } 24 | } 25 | 26 | /// 27 | /// Setup initial flag. 28 | /// 29 | public BooleanNotifier(bool initialValue = false) 30 | { 31 | this.Value = initialValue; 32 | } 33 | 34 | /// 35 | /// Set and raise true if current value isn't true. 36 | /// 37 | public void TurnOn() 38 | { 39 | if (Value != true) 40 | { 41 | Value = true; 42 | } 43 | } 44 | 45 | /// 46 | /// Set and raise false if current value isn't false. 47 | /// 48 | public void TurnOff() 49 | { 50 | if (Value != false) 51 | { 52 | Value = false; 53 | } 54 | } 55 | 56 | /// 57 | /// Set and raise reverse value. 58 | /// 59 | public void SwitchValue() 60 | { 61 | Value = !Value; 62 | } 63 | 64 | 65 | /// 66 | /// Subscribe observer. 67 | /// 68 | public IDisposable Subscribe(IObserver observer) 69 | { 70 | return boolTrigger.Subscribe(observer); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Observable.Aggregate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UniRx.Operators; 5 | 6 | namespace UniRx 7 | { 8 | public static partial class Observable 9 | { 10 | public static IObservable Scan(this IObservable source, Func accumulator) 11 | { 12 | return new ScanObservable(source, accumulator); 13 | } 14 | 15 | public static IObservable Scan(this IObservable source, TAccumulate seed, Func accumulator) 16 | { 17 | return new ScanObservable(source, seed, accumulator); 18 | } 19 | 20 | public static IObservable Aggregate(this IObservable source, Func accumulator) 21 | { 22 | return new AggregateObservable(source, accumulator); 23 | } 24 | 25 | public static IObservable Aggregate(this IObservable source, TAccumulate seed, Func accumulator) 26 | { 27 | return new AggregateObservable(source, seed, accumulator); 28 | } 29 | 30 | public static IObservable Aggregate(this IObservable source, TAccumulate seed, Func accumulator, Func resultSelector) 31 | { 32 | return new AggregateObservable(source, seed, accumulator, resultSelector); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Observable.Blocking.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx 4 | { 5 | public static partial class Observable 6 | { 7 | public static T Wait(this IObservable source) 8 | { 9 | return new UniRx.Operators.Wait(source, InfiniteTimeSpan).Run(); 10 | } 11 | 12 | public static T Wait(this IObservable source, TimeSpan timeout) 13 | { 14 | return new UniRx.Operators.Wait(source, timeout).Run(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Observable.Events.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRx.Operators; 3 | 4 | namespace UniRx 5 | { 6 | public static partial class Observable 7 | { 8 | public static IObservable> FromEventPattern(Func, TDelegate> conversion, Action addHandler, Action removeHandler) 9 | where TEventArgs : EventArgs 10 | { 11 | return new FromEventPatternObservable(conversion, addHandler, removeHandler); 12 | } 13 | 14 | public static IObservable FromEvent(Func conversion, Action addHandler, Action removeHandler) 15 | { 16 | return new FromEventObservable(conversion, addHandler, removeHandler); 17 | } 18 | 19 | public static IObservable FromEvent(Func, TDelegate> conversion, Action addHandler, Action removeHandler) 20 | { 21 | return new FromEventObservable(conversion, addHandler, removeHandler); 22 | } 23 | 24 | public static IObservable FromEvent(Action addHandler, Action removeHandler) 25 | { 26 | return new FromEventObservable(addHandler, removeHandler); 27 | } 28 | 29 | public static IObservable FromEvent(Action> addHandler, Action> removeHandler) 30 | { 31 | return new FromEventObservable_(addHandler, removeHandler); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Observable.Joins.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace UniRx 6 | { 7 | public static partial class Observable 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/AsObservable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRx.Operators; 3 | 4 | namespace UniRx.Operators 5 | { 6 | internal class AsObservableObservable : OperatorObservableBase 7 | { 8 | readonly IObservable source; 9 | 10 | public AsObservableObservable(IObservable source) 11 | : base(source.IsRequiredSubscribeOnCurrentThread()) 12 | { 13 | this.source = source; 14 | } 15 | 16 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 17 | { 18 | return source.Subscribe(new AsObservable(observer, cancel)); 19 | } 20 | 21 | class AsObservable : OperatorObserverBase 22 | { 23 | public AsObservable(IObserver observer, IDisposable cancel) : base(observer, cancel) 24 | { 25 | } 26 | 27 | public override void OnNext(T value) 28 | { 29 | base.observer.OnNext(value); 30 | } 31 | 32 | public override void OnError(Exception error) 33 | { 34 | try { observer.OnError(error); } 35 | finally { Dispose(); } 36 | } 37 | 38 | public override void OnCompleted() 39 | { 40 | try { observer.OnCompleted(); } 41 | finally { Dispose(); } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/AsUnitObservable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class AsUnitObservableObservable : OperatorObservableBase 6 | { 7 | readonly IObservable source; 8 | 9 | public AsUnitObservableObservable(IObservable source) 10 | : base(source.IsRequiredSubscribeOnCurrentThread()) 11 | { 12 | this.source = source; 13 | } 14 | 15 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 16 | { 17 | return source.Subscribe(new AsUnitObservable(observer, cancel)); 18 | } 19 | 20 | class AsUnitObservable : OperatorObserverBase 21 | { 22 | public AsUnitObservable(IObserver observer, IDisposable cancel) 23 | : base(observer, cancel) 24 | { 25 | } 26 | 27 | public override void OnNext(T value) 28 | { 29 | base.observer.OnNext(Unit.Default); 30 | } 31 | 32 | public override void OnError(Exception error) 33 | { 34 | try { observer.OnError(error); } 35 | finally { Dispose(); } 36 | } 37 | 38 | public override void OnCompleted() 39 | { 40 | try { observer.OnCompleted(); } 41 | finally { Dispose(); } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Cast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class CastObservable : OperatorObservableBase 6 | { 7 | readonly IObservable source; 8 | 9 | public CastObservable(IObservable source) 10 | : base(source.IsRequiredSubscribeOnCurrentThread()) 11 | { 12 | this.source = source; 13 | } 14 | 15 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 16 | { 17 | return source.Subscribe(new Cast(observer, cancel)); 18 | } 19 | 20 | class Cast : OperatorObserverBase 21 | { 22 | public Cast(IObserver observer, IDisposable cancel) 23 | : base(observer, cancel) 24 | { 25 | } 26 | 27 | public override void OnNext(TSource value) 28 | { 29 | var castValue = default(TResult); 30 | try 31 | { 32 | castValue = (TResult)(object)value; 33 | } 34 | catch (Exception ex) 35 | { 36 | try { observer.OnError(ex); } 37 | finally { Dispose(); } 38 | return; 39 | } 40 | 41 | observer.OnNext(castValue); 42 | } 43 | 44 | public override void OnError(Exception error) 45 | { 46 | try { observer.OnError(error); } 47 | finally { Dispose(); } 48 | } 49 | 50 | public override void OnCompleted() 51 | { 52 | try { observer.OnCompleted(); } 53 | finally { Dispose(); } 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/DefaultIfEmpty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRx.Operators; 3 | 4 | namespace UniRx.Operators 5 | { 6 | internal class DefaultIfEmptyObservable : OperatorObservableBase 7 | { 8 | readonly IObservable source; 9 | readonly T defaultValue; 10 | 11 | public DefaultIfEmptyObservable(IObservable source, T defaultValue) 12 | : base(source.IsRequiredSubscribeOnCurrentThread()) 13 | { 14 | this.source = source; 15 | this.defaultValue = defaultValue; 16 | } 17 | 18 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 19 | { 20 | return source.Subscribe(new DefaultIfEmpty(this, observer, cancel)); 21 | } 22 | 23 | class DefaultIfEmpty : OperatorObserverBase 24 | { 25 | readonly DefaultIfEmptyObservable parent; 26 | bool hasValue; 27 | 28 | public DefaultIfEmpty(DefaultIfEmptyObservable parent, IObserver observer, IDisposable cancel) : base(observer, cancel) 29 | { 30 | this.parent = parent; 31 | this.hasValue = false; 32 | } 33 | 34 | public override void OnNext(T value) 35 | { 36 | hasValue = true; 37 | observer.OnNext(value); 38 | } 39 | 40 | public override void OnError(Exception error) 41 | { 42 | try { observer.OnError(error); } 43 | finally { Dispose(); } 44 | } 45 | 46 | public override void OnCompleted() 47 | { 48 | if (!hasValue) 49 | { 50 | observer.OnNext(parent.defaultValue); 51 | } 52 | 53 | try { observer.OnCompleted(); } 54 | finally { Dispose(); } 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Defer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class DeferObservable : OperatorObservableBase 6 | { 7 | readonly Func> observableFactory; 8 | 9 | public DeferObservable(Func> observableFactory) 10 | : base(false) 11 | { 12 | this.observableFactory = observableFactory; 13 | } 14 | 15 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 16 | { 17 | observer = new Defer(observer, cancel); 18 | 19 | IObservable source; 20 | try 21 | { 22 | source = observableFactory(); 23 | } 24 | catch (Exception ex) 25 | { 26 | source = Observable.Throw(ex); 27 | } 28 | 29 | return source.Subscribe(observer); 30 | } 31 | 32 | class Defer : OperatorObserverBase 33 | { 34 | public Defer(IObserver observer, IDisposable cancel) : base(observer, cancel) 35 | { 36 | } 37 | 38 | public override void OnNext(T value) 39 | { 40 | try 41 | { 42 | base.observer.OnNext(value); 43 | } 44 | catch 45 | { 46 | Dispose(); 47 | throw; 48 | } 49 | } 50 | 51 | public override void OnError(Exception error) 52 | { 53 | try { observer.OnError(error); } 54 | finally { Dispose(); } 55 | } 56 | 57 | public override void OnCompleted() 58 | { 59 | try { observer.OnCompleted(); } 60 | finally { Dispose(); } 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/DelaySubscription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniRx.Operators 5 | { 6 | internal class DelaySubscriptionObservable : OperatorObservableBase 7 | { 8 | readonly IObservable source; 9 | readonly IScheduler scheduler; 10 | readonly TimeSpan? dueTimeT; 11 | readonly DateTimeOffset? dueTimeD; 12 | 13 | public DelaySubscriptionObservable(IObservable source,TimeSpan dueTime, IScheduler scheduler) 14 | : base(scheduler == Scheduler.CurrentThread || source.IsRequiredSubscribeOnCurrentThread()) 15 | { 16 | this.source = source; 17 | this.scheduler = scheduler; 18 | this.dueTimeT = dueTime; 19 | } 20 | 21 | public DelaySubscriptionObservable(IObservable source, DateTimeOffset dueTime, IScheduler scheduler) 22 | : base(scheduler == Scheduler.CurrentThread || source.IsRequiredSubscribeOnCurrentThread()) 23 | { 24 | this.source = source; 25 | this.scheduler = scheduler; 26 | this.dueTimeD = dueTime; 27 | } 28 | 29 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 30 | { 31 | if (dueTimeT != null) 32 | { 33 | var d = new MultipleAssignmentDisposable(); 34 | var dt = Scheduler.Normalize(dueTimeT.Value); 35 | 36 | d.Disposable = scheduler.Schedule(dt, () => 37 | { 38 | d.Disposable = source.Subscribe(observer); 39 | }); 40 | 41 | return d; 42 | } 43 | else 44 | { 45 | var d = new MultipleAssignmentDisposable(); 46 | 47 | d.Disposable = scheduler.Schedule(dueTimeD.Value, () => 48 | { 49 | d.Disposable = source.Subscribe(observer); 50 | }); 51 | 52 | return d; 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Empty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class EmptyObservable : OperatorObservableBase 6 | { 7 | readonly IScheduler scheduler; 8 | 9 | public EmptyObservable(IScheduler scheduler) 10 | : base(false) 11 | { 12 | this.scheduler = scheduler; 13 | } 14 | 15 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 16 | { 17 | observer = new Empty(observer, cancel); 18 | 19 | if (scheduler == Scheduler.Immediate) 20 | { 21 | observer.OnCompleted(); 22 | return Disposable.Empty; 23 | } 24 | else 25 | { 26 | return scheduler.Schedule(observer.OnCompleted); 27 | } 28 | } 29 | 30 | class Empty : OperatorObserverBase 31 | { 32 | public Empty(IObserver observer, IDisposable cancel) : base(observer, cancel) 33 | { 34 | } 35 | 36 | public override void OnNext(T value) 37 | { 38 | try 39 | { 40 | base.observer.OnNext(value); 41 | } 42 | catch 43 | { 44 | Dispose(); 45 | throw; 46 | } 47 | } 48 | 49 | public override void OnError(Exception error) 50 | { 51 | try { observer.OnError(error); } 52 | finally { Dispose(); } 53 | } 54 | 55 | public override void OnCompleted() 56 | { 57 | try { observer.OnCompleted(); } 58 | finally { Dispose(); } 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/IgnoreElements.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRx.Operators; 3 | 4 | namespace UniRx.Operators 5 | { 6 | internal class IgnoreElementsObservable : OperatorObservableBase 7 | { 8 | readonly IObservable source; 9 | 10 | public IgnoreElementsObservable(IObservable source) 11 | : base(source.IsRequiredSubscribeOnCurrentThread()) 12 | { 13 | this.source = source; 14 | } 15 | 16 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 17 | { 18 | return source.Subscribe(new IgnoreElements(observer, cancel)); 19 | } 20 | 21 | class IgnoreElements : OperatorObserverBase 22 | { 23 | public IgnoreElements(IObserver observer, IDisposable cancel) : base(observer, cancel) 24 | { 25 | } 26 | 27 | public override void OnNext(T value) 28 | { 29 | } 30 | 31 | public override void OnError(Exception error) 32 | { 33 | try { observer.OnError(error); } 34 | finally { Dispose(); } 35 | } 36 | 37 | public override void OnCompleted() 38 | { 39 | try { observer.OnCompleted(); } 40 | finally { Dispose(); } 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Materialize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class MaterializeObservable : OperatorObservableBase> 6 | { 7 | readonly IObservable source; 8 | 9 | public MaterializeObservable(IObservable source) 10 | : base(source.IsRequiredSubscribeOnCurrentThread()) 11 | { 12 | this.source = source; 13 | } 14 | 15 | protected override IDisposable SubscribeCore(IObserver> observer, IDisposable cancel) 16 | { 17 | return new Materialize(this, observer, cancel).Run(); 18 | } 19 | 20 | class Materialize : OperatorObserverBase> 21 | { 22 | readonly MaterializeObservable parent; 23 | 24 | public Materialize(MaterializeObservable parent, IObserver> observer, IDisposable cancel) 25 | : base(observer, cancel) 26 | { 27 | this.parent = parent; 28 | } 29 | 30 | public IDisposable Run() 31 | { 32 | return parent.source.Subscribe(this); 33 | } 34 | 35 | public override void OnNext(T value) 36 | { 37 | observer.OnNext(Notification.CreateOnNext(value)); 38 | } 39 | 40 | public override void OnError(Exception error) 41 | { 42 | observer.OnNext(Notification.CreateOnError(error)); 43 | try { observer.OnCompleted(); } finally { Dispose(); } 44 | } 45 | 46 | public override void OnCompleted() 47 | { 48 | observer.OnNext(Notification.CreateOnCompleted()); 49 | try { observer.OnCompleted(); } finally { Dispose(); } 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Never.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class NeverObservable : OperatorObservableBase 6 | { 7 | public NeverObservable() 8 | : base(false) 9 | { 10 | } 11 | 12 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 13 | { 14 | return Disposable.Empty; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/OfType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class OfTypeObservable : OperatorObservableBase 6 | { 7 | readonly IObservable source; 8 | 9 | public OfTypeObservable(IObservable source) 10 | : base(source.IsRequiredSubscribeOnCurrentThread()) 11 | { 12 | this.source = source; 13 | } 14 | 15 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 16 | { 17 | return source.Subscribe(new OfType(observer, cancel)); 18 | } 19 | 20 | class OfType : OperatorObserverBase 21 | { 22 | public OfType(IObserver observer, IDisposable cancel) 23 | : base(observer, cancel) 24 | { 25 | } 26 | 27 | public override void OnNext(TSource value) 28 | { 29 | if (value is TResult) 30 | { 31 | var castValue = (TResult)(object)value; 32 | observer.OnNext(castValue); 33 | } 34 | } 35 | 36 | public override void OnError(Exception error) 37 | { 38 | try { observer.OnError(error); } finally { Dispose(); } 39 | } 40 | 41 | public override void OnCompleted() 42 | { 43 | try { observer.OnCompleted(); } finally { Dispose(); } 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/OperatorObservableBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | // implements note : all field must be readonly. 6 | public abstract class OperatorObservableBase : IObservable, IOptimizedObservable 7 | { 8 | readonly bool isRequiredSubscribeOnCurrentThread; 9 | 10 | public OperatorObservableBase(bool isRequiredSubscribeOnCurrentThread) 11 | { 12 | this.isRequiredSubscribeOnCurrentThread = isRequiredSubscribeOnCurrentThread; 13 | } 14 | 15 | public bool IsRequiredSubscribeOnCurrentThread() 16 | { 17 | return isRequiredSubscribeOnCurrentThread; 18 | } 19 | 20 | public IDisposable Subscribe(IObserver observer) 21 | { 22 | var subscription = new SingleAssignmentDisposable(); 23 | 24 | // note: 25 | // does not make the safe observer, it breaks exception durability. 26 | // var safeObserver = Observer.CreateAutoDetachObserver(observer, subscription); 27 | 28 | if (isRequiredSubscribeOnCurrentThread && Scheduler.IsCurrentThreadSchedulerScheduleRequired) 29 | { 30 | Scheduler.CurrentThread.Schedule(() => subscription.Disposable = SubscribeCore(observer, subscription)); 31 | } 32 | else 33 | { 34 | subscription.Disposable = SubscribeCore(observer, subscription); 35 | } 36 | 37 | return subscription; 38 | } 39 | 40 | protected abstract IDisposable SubscribeCore(IObserver observer, IDisposable cancel); 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/OperatorObserverBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace UniRx.Operators 5 | { 6 | public abstract class OperatorObserverBase : IDisposable, IObserver 7 | { 8 | protected internal volatile IObserver observer; 9 | IDisposable cancel; 10 | 11 | public OperatorObserverBase(IObserver observer, IDisposable cancel) 12 | { 13 | this.observer = observer; 14 | this.cancel = cancel; 15 | } 16 | 17 | public abstract void OnNext(TSource value); 18 | 19 | public abstract void OnError(Exception error); 20 | 21 | public abstract void OnCompleted(); 22 | 23 | public void Dispose() 24 | { 25 | observer = UniRx.InternalUtil.EmptyObserver.Instance; 26 | var target = System.Threading.Interlocked.Exchange(ref cancel, null); 27 | if (target != null) 28 | { 29 | target.Dispose(); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Return.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class ReturnObservable : OperatorObservableBase 6 | { 7 | readonly T value; 8 | readonly IScheduler scheduler; 9 | 10 | public ReturnObservable(T value, IScheduler scheduler) 11 | : base(scheduler == Scheduler.CurrentThread) 12 | { 13 | this.value = value; 14 | this.scheduler = scheduler; 15 | } 16 | 17 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 18 | { 19 | observer = new Return(observer, cancel); 20 | 21 | if (scheduler == Scheduler.Immediate) 22 | { 23 | observer.OnNext(value); 24 | observer.OnCompleted(); 25 | return Disposable.Empty; 26 | } 27 | else 28 | { 29 | return scheduler.Schedule(() => 30 | { 31 | observer.OnNext(value); 32 | observer.OnCompleted(); 33 | }); 34 | } 35 | } 36 | 37 | class Return : OperatorObserverBase 38 | { 39 | public Return(IObserver observer, IDisposable cancel) 40 | : base(observer, cancel) 41 | { 42 | } 43 | 44 | public override void OnNext(T value) 45 | { 46 | try 47 | { 48 | base.observer.OnNext(value); 49 | } 50 | catch 51 | { 52 | Dispose(); 53 | throw; 54 | } 55 | } 56 | 57 | public override void OnError(Exception error) 58 | { 59 | try { observer.OnError(error); } 60 | finally { Dispose(); } 61 | } 62 | 63 | public override void OnCompleted() 64 | { 65 | try { observer.OnCompleted(); } 66 | finally { Dispose(); } 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/SubscribeOn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniRx.Operators 5 | { 6 | internal class SubscribeOnObservable : OperatorObservableBase 7 | { 8 | readonly IObservable source; 9 | readonly IScheduler scheduler; 10 | 11 | public SubscribeOnObservable(IObservable source, IScheduler scheduler) 12 | : base(scheduler == Scheduler.CurrentThread || source.IsRequiredSubscribeOnCurrentThread()) 13 | { 14 | this.source = source; 15 | this.scheduler = scheduler; 16 | } 17 | 18 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 19 | { 20 | var m = new SingleAssignmentDisposable(); 21 | var d = new SerialDisposable(); 22 | d.Disposable = m; 23 | 24 | m.Disposable = scheduler.Schedule(() => 25 | { 26 | d.Disposable = new ScheduledDisposable(scheduler, source.Subscribe(observer)); 27 | }); 28 | 29 | return d; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Synchronize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniRx.Operators; 3 | 4 | namespace UniRx.Operators 5 | { 6 | internal class SynchronizeObservable : OperatorObservableBase 7 | { 8 | readonly IObservable source; 9 | readonly object gate; 10 | 11 | public SynchronizeObservable(IObservable source, object gate) 12 | : base(source.IsRequiredSubscribeOnCurrentThread()) 13 | { 14 | this.source = source; 15 | this.gate = gate; 16 | } 17 | 18 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 19 | { 20 | return source.Subscribe(new Synchronize(this, observer, cancel)); 21 | } 22 | 23 | class Synchronize : OperatorObserverBase 24 | { 25 | readonly SynchronizeObservable parent; 26 | 27 | public Synchronize(SynchronizeObservable parent, IObserver observer, IDisposable cancel) : base(observer, cancel) 28 | { 29 | this.parent = parent; 30 | } 31 | 32 | public override void OnNext(T value) 33 | { 34 | lock (parent.gate) 35 | { 36 | base.observer.OnNext(value); 37 | } 38 | } 39 | 40 | public override void OnError(Exception error) 41 | { 42 | lock (parent.gate) 43 | { 44 | try { observer.OnError(error); } finally { Dispose(); }; 45 | } 46 | } 47 | 48 | public override void OnCompleted() 49 | { 50 | lock (parent.gate) 51 | { 52 | try { observer.OnCompleted(); } finally { Dispose(); }; 53 | } 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Throw.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class ThrowObservable : OperatorObservableBase 6 | { 7 | readonly Exception error; 8 | readonly IScheduler scheduler; 9 | 10 | public ThrowObservable(Exception error, IScheduler scheduler) 11 | : base(scheduler == Scheduler.CurrentThread) 12 | { 13 | this.error = error; 14 | this.scheduler = scheduler; 15 | } 16 | 17 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 18 | { 19 | observer = new Throw(observer, cancel); 20 | 21 | if (scheduler == Scheduler.Immediate) 22 | { 23 | observer.OnError(error); 24 | return Disposable.Empty; 25 | } 26 | else 27 | { 28 | return scheduler.Schedule(() => 29 | { 30 | observer.OnError(error); 31 | observer.OnCompleted(); 32 | }); 33 | } 34 | } 35 | 36 | class Throw : OperatorObserverBase 37 | { 38 | public Throw(IObserver observer, IDisposable cancel) 39 | : base(observer, cancel) 40 | { 41 | } 42 | 43 | public override void OnNext(T value) 44 | { 45 | try 46 | { 47 | base.observer.OnNext(value); 48 | } 49 | catch 50 | { 51 | Dispose(); 52 | throw; 53 | } 54 | } 55 | 56 | public override void OnError(Exception error) 57 | { 58 | try { observer.OnError(error); } 59 | finally { Dispose(); } 60 | } 61 | 62 | public override void OnCompleted() 63 | { 64 | try { observer.OnCompleted(); } 65 | finally { Dispose(); } 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/TimeInterval.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class TimeIntervalObservable : OperatorObservableBase> 6 | { 7 | readonly IObservable source; 8 | readonly IScheduler scheduler; 9 | 10 | public TimeIntervalObservable(IObservable source, IScheduler scheduler) 11 | : base(scheduler == Scheduler.CurrentThread || source.IsRequiredSubscribeOnCurrentThread()) 12 | { 13 | this.source = source; 14 | this.scheduler = scheduler; 15 | } 16 | 17 | protected override IDisposable SubscribeCore(IObserver> observer, IDisposable cancel) 18 | { 19 | return source.Subscribe(new TimeInterval(this, observer, cancel)); 20 | } 21 | 22 | class TimeInterval : OperatorObserverBase> 23 | { 24 | readonly TimeIntervalObservable parent; 25 | DateTimeOffset lastTime; 26 | 27 | public TimeInterval(TimeIntervalObservable parent, IObserver> observer, IDisposable cancel) 28 | : base(observer, cancel) 29 | { 30 | this.parent = parent; 31 | this.lastTime = parent.scheduler.Now; 32 | } 33 | 34 | public override void OnNext(T value) 35 | { 36 | var now = parent.scheduler.Now; 37 | var span = now.Subtract(lastTime); 38 | lastTime = now; 39 | 40 | base.observer.OnNext(new UniRx.TimeInterval(value, span)); 41 | } 42 | 43 | public override void OnError(Exception error) 44 | { 45 | try { observer.OnError(error); } 46 | finally { Dispose(); } 47 | } 48 | 49 | public override void OnCompleted() 50 | { 51 | try { observer.OnCompleted(); } 52 | finally { Dispose(); } 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Timestamp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class TimestampObservable : OperatorObservableBase> 6 | { 7 | readonly IObservable source; 8 | readonly IScheduler scheduler; 9 | 10 | public TimestampObservable(IObservable source, IScheduler scheduler) 11 | : base(scheduler == Scheduler.CurrentThread || source.IsRequiredSubscribeOnCurrentThread()) 12 | { 13 | this.source = source; 14 | this.scheduler = scheduler; 15 | } 16 | 17 | protected override IDisposable SubscribeCore(IObserver> observer, IDisposable cancel) 18 | { 19 | return source.Subscribe(new Timestamp(this, observer, cancel)); 20 | } 21 | 22 | class Timestamp : OperatorObserverBase> 23 | { 24 | readonly TimestampObservable parent; 25 | 26 | public Timestamp(TimestampObservable parent, IObserver> observer, IDisposable cancel) 27 | : base(observer, cancel) 28 | { 29 | this.parent = parent; 30 | } 31 | 32 | public override void OnNext(T value) 33 | { 34 | base.observer.OnNext(new Timestamped(value, parent.scheduler.Now)); 35 | } 36 | 37 | public override void OnError(Exception error) 38 | { 39 | try { observer.OnError(error); } 40 | finally { Dispose(); } 41 | } 42 | 43 | public override void OnCompleted() 44 | { 45 | try { observer.OnCompleted(); } 46 | finally { Dispose(); } 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/ToList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniRx.Operators 5 | { 6 | internal class ToListObservable : OperatorObservableBase> 7 | { 8 | readonly IObservable source; 9 | 10 | public ToListObservable(IObservable source) 11 | : base(source.IsRequiredSubscribeOnCurrentThread()) 12 | { 13 | this.source = source; 14 | } 15 | 16 | protected override IDisposable SubscribeCore(IObserver> observer, IDisposable cancel) 17 | { 18 | return source.Subscribe(new ToList(observer, cancel)); 19 | } 20 | 21 | class ToList : OperatorObserverBase> 22 | { 23 | readonly List list = new List(); 24 | 25 | public ToList(IObserver> observer, IDisposable cancel) 26 | : base(observer, cancel) 27 | { 28 | } 29 | 30 | public override void OnNext(TSource value) 31 | { 32 | try 33 | { 34 | list.Add(value); // sometimes cause error on multithread 35 | } 36 | catch (Exception ex) 37 | { 38 | try { observer.OnError(ex); } finally { Dispose(); } 39 | return; 40 | } 41 | } 42 | 43 | public override void OnError(Exception error) 44 | { 45 | try { observer.OnError(error); } finally { Dispose(); } 46 | } 47 | 48 | public override void OnCompleted() 49 | { 50 | base.observer.OnNext(list); 51 | try { observer.OnCompleted(); } finally { Dispose(); }; 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Operators/Wait.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class Wait : IObserver 6 | { 7 | static readonly TimeSpan InfiniteTimeSpan = new TimeSpan(0, 0, 0, 0, -1); // from .NET 4.5 8 | 9 | readonly IObservable source; 10 | readonly TimeSpan timeout; 11 | 12 | System.Threading.ManualResetEvent semaphore; 13 | 14 | bool seenValue = false; 15 | T value = default(T); 16 | Exception ex = default(Exception); 17 | 18 | public Wait(IObservable source, TimeSpan timeout) 19 | { 20 | this.source = source; 21 | this.timeout = timeout; 22 | } 23 | 24 | public T Run() 25 | { 26 | semaphore = new System.Threading.ManualResetEvent(false); 27 | using (source.Subscribe(this)) 28 | { 29 | var waitComplete = (timeout == InfiniteTimeSpan) 30 | ? semaphore.WaitOne() 31 | : semaphore.WaitOne(timeout); 32 | 33 | if (!waitComplete) 34 | { 35 | throw new TimeoutException("OnCompleted not fired."); 36 | } 37 | } 38 | 39 | if (ex != null) throw ex; 40 | if (!seenValue) throw new InvalidOperationException("No Elements."); 41 | 42 | return value; 43 | } 44 | 45 | public void OnNext(T value) 46 | { 47 | seenValue = true; 48 | this.value = value; 49 | } 50 | 51 | public void OnError(Exception error) 52 | { 53 | this.ex = error; 54 | semaphore.Set(); 55 | } 56 | 57 | public void OnCompleted() 58 | { 59 | semaphore.Set(); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Pair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniRx 5 | { 6 | // Pair is used for Observable.Pairwise 7 | [Serializable] 8 | public struct Pair : IEquatable> 9 | { 10 | readonly T previous; 11 | readonly T current; 12 | 13 | public T Previous 14 | { 15 | get { return previous; } 16 | } 17 | 18 | public T Current 19 | { 20 | get { return current; } 21 | } 22 | 23 | public Pair(T previous, T current) 24 | { 25 | this.previous = previous; 26 | this.current = current; 27 | } 28 | 29 | public override int GetHashCode() 30 | { 31 | var comparer = EqualityComparer.Default; 32 | 33 | int h0; 34 | h0 = comparer.GetHashCode(previous); 35 | h0 = (h0 << 5) + h0 ^ comparer.GetHashCode(current); 36 | return h0; 37 | } 38 | 39 | public override bool Equals(object obj) 40 | { 41 | if (!(obj is Pair)) return false; 42 | 43 | return Equals((Pair)obj); 44 | } 45 | 46 | public bool Equals(Pair other) 47 | { 48 | var comparer = EqualityComparer.Default; 49 | 50 | return comparer.Equals(previous, other.Previous) && 51 | comparer.Equals(current, other.Current); 52 | } 53 | 54 | public override string ToString() 55 | { 56 | return string.Format("({0}, {1})", previous, current); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Schedulers/IScheduler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx 4 | { 5 | public interface IScheduler 6 | { 7 | DateTimeOffset Now { get; } 8 | 9 | // Interface is changed from official Rx for avoid iOS AOT problem (state is dangerous). 10 | 11 | IDisposable Schedule(Action action); 12 | 13 | IDisposable Schedule(TimeSpan dueTime, Action action); 14 | } 15 | 16 | public interface ISchedulerPeriodic 17 | { 18 | IDisposable SchedulePeriodic(TimeSpan period, Action action); 19 | } 20 | 21 | public interface ISchedulerLongRunning 22 | { 23 | IDisposable ScheduleLongRunning(Action action); 24 | } 25 | 26 | public interface ISchedulerQueueing 27 | { 28 | void ScheduleQueueing(ICancelable cancel, T state, Action action); 29 | } 30 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Schedulers/ImmediateScheduler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading; 6 | 7 | namespace UniRx 8 | { 9 | public static partial class Scheduler 10 | { 11 | public static readonly IScheduler Immediate = new ImmediateScheduler(); 12 | 13 | class ImmediateScheduler : IScheduler 14 | { 15 | public ImmediateScheduler() 16 | { 17 | } 18 | 19 | public DateTimeOffset Now 20 | { 21 | get { return Scheduler.Now; } 22 | } 23 | 24 | public IDisposable Schedule(Action action) 25 | { 26 | action(); 27 | return Disposable.Empty; 28 | } 29 | 30 | public IDisposable Schedule(TimeSpan dueTime, Action action) 31 | { 32 | var wait = Scheduler.Normalize(dueTime); 33 | if (wait.Ticks > 0) 34 | { 35 | Thread.Sleep(wait); 36 | } 37 | 38 | action(); 39 | return Disposable.Empty; 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/Subjects/ISubject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace UniRx 6 | { 7 | public interface ISubject : IObserver, IObservable 8 | { 9 | } 10 | 11 | public interface ISubject : ISubject, IObserver, IObservable 12 | { 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/System/IObservable.cs: -------------------------------------------------------------------------------- 1 | // defined from .NET Framework 4.0 and NETFX_CORE 2 | 3 | #if !NETFX_CORE 4 | 5 | using System; 6 | 7 | namespace UniRx 8 | { 9 | public interface IObservable 10 | { 11 | IDisposable Subscribe(IObserver observer); 12 | } 13 | } 14 | 15 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/System/IObserver.cs: -------------------------------------------------------------------------------- 1 | // defined from .NET Framework 4.0 and NETFX_CORE 2 | 3 | #if !NETFX_CORE 4 | 5 | using System; 6 | 7 | namespace UniRx 8 | { 9 | public interface IObserver 10 | { 11 | void OnCompleted(); 12 | void OnError(Exception error); 13 | void OnNext(T value); 14 | } 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/System/IOptimizedObservable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx 4 | { 5 | public interface IOptimizedObservable : IObservable 6 | { 7 | bool IsRequiredSubscribeOnCurrentThread(); 8 | } 9 | 10 | public static class OptimizedObservableExtensions 11 | { 12 | public static bool IsRequiredSubscribeOnCurrentThread(this IObservable source) 13 | { 14 | var obs = source as IOptimizedObservable; 15 | if (obs == null) return true; 16 | 17 | return obs.IsRequiredSubscribeOnCurrentThread(); 18 | } 19 | 20 | public static bool IsRequiredSubscribeOnCurrentThread(this IObservable source, IScheduler scheduler) 21 | { 22 | if (scheduler == Scheduler.CurrentThread) return true; 23 | 24 | return IsRequiredSubscribeOnCurrentThread(source); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/System/IProgress.cs: -------------------------------------------------------------------------------- 1 | // defined from .NET Framework 4.5 and NETFX_CORE 2 | 3 | #if !NETFX_CORE 4 | 5 | using System; 6 | 7 | namespace UniRx 8 | { 9 | public interface IProgress 10 | { 11 | void Report(T value); 12 | } 13 | 14 | public class Progress : IProgress 15 | { 16 | readonly Action report; 17 | 18 | public Progress(Action report) 19 | { 20 | this.report = report; 21 | } 22 | 23 | public void Report(T value) 24 | { 25 | report(value); 26 | } 27 | } 28 | } 29 | 30 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/System/Unit.cs: -------------------------------------------------------------------------------- 1 | // from Rx Official, but convert struct to class(for iOS AOT issue) 2 | 3 | using System; 4 | 5 | namespace UniRx 6 | { 7 | [Serializable] 8 | public struct Unit : IEquatable 9 | { 10 | static readonly Unit @default = new Unit(); 11 | 12 | public static Unit Default { get { return @default; } } 13 | 14 | public static bool operator ==(Unit first, Unit second) 15 | { 16 | return true; 17 | } 18 | 19 | public static bool operator !=(Unit first, Unit second) 20 | { 21 | return false; 22 | } 23 | 24 | public bool Equals(Unit other) 25 | { 26 | return true; 27 | } 28 | public override bool Equals(object obj) 29 | { 30 | return obj is Unit; 31 | } 32 | 33 | public override int GetHashCode() 34 | { 35 | return 0; 36 | } 37 | 38 | public override string ToString() 39 | { 40 | return "()"; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/AotSafeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace UniRx 6 | { 7 | public static class AotSafeExtensions 8 | { 9 | public static IEnumerable AsSafeEnumerable(this IEnumerable source) 10 | { 11 | var e = ((IEnumerable)source).GetEnumerator(); 12 | using (e as IDisposable) 13 | { 14 | while (e.MoveNext()) 15 | { 16 | yield return (T)e.Current; 17 | } 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/CancellationToken.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx 4 | { 5 | public struct CancellationToken 6 | { 7 | readonly ICancelable source; 8 | 9 | public static readonly CancellationToken Empty = new CancellationToken(null); 10 | 11 | public CancellationToken(ICancelable source) 12 | { 13 | this.source = source; 14 | } 15 | 16 | public bool IsCancellationRequested 17 | { 18 | get 19 | { 20 | return (source == null) ? false : source.IsDisposed; 21 | } 22 | } 23 | 24 | public void ThrowIfCancellationRequested() 25 | { 26 | if (IsCancellationRequested) 27 | { 28 | throw new OperationCanceledException(); 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Diagnostics/LogEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UnityEngine; 5 | 6 | namespace UniRx.Diagnostics 7 | { 8 | public class LogEntry 9 | { 10 | // requires 11 | public string LoggerName { get; private set; } 12 | public LogType LogType { get; private set; } 13 | public string Message { get; private set; } 14 | public DateTime Timestamp { get; private set; } 15 | 16 | // options 17 | 18 | /// [Optional] 19 | public UnityEngine.Object Context { get; private set; } 20 | /// [Optional] 21 | public Exception Exception { get; private set; } 22 | /// [Optional] 23 | public string StackTrace { get; private set; } 24 | /// [Optional] 25 | public object State { get; private set; } 26 | 27 | public LogEntry(string loggerName, LogType logType, DateTime timestamp, string message, UnityEngine.Object context = null, Exception exception = null, string stackTrace = null, object state = null) 28 | { 29 | this.LoggerName = loggerName; 30 | this.LogType = logType; 31 | this.Timestamp = timestamp; 32 | this.Message = message; 33 | this.Context = context; 34 | this.Exception = exception; 35 | this.StackTrace = stackTrace; 36 | this.State = state; 37 | } 38 | 39 | public override string ToString() 40 | { 41 | var plusEx = (Exception != null) ? (Environment.NewLine + Exception.ToString()) : ""; 42 | return "[" + Timestamp.ToString() + "]" 43 | + "[" + LoggerName + "]" 44 | + "[" + LogType.ToString() + "]" 45 | + Message 46 | + plusEx; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Diagnostics/LogEntryExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace UniRx.Diagnostics 6 | { 7 | public static partial class LogEntryExtensions 8 | { 9 | public static IDisposable LogToUnityDebug(this IObservable source) 10 | { 11 | return source.Subscribe(new UnityDebugSink()); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Diagnostics/ObservableLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UnityEngine; 5 | 6 | namespace UniRx.Diagnostics 7 | { 8 | public class ObservableLogger : IObservable 9 | { 10 | static readonly Subject logPublisher = new Subject(); 11 | 12 | public static readonly ObservableLogger Listener = new ObservableLogger(); 13 | 14 | private ObservableLogger() 15 | { 16 | 17 | } 18 | 19 | public static Action RegisterLogger(Logger logger) 20 | { 21 | if (logger.Name == null) throw new ArgumentNullException("logger.Name is null"); 22 | 23 | return logPublisher.OnNext; 24 | } 25 | 26 | public IDisposable Subscribe(IObserver observer) 27 | { 28 | return logPublisher.Subscribe(observer); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Operators/DelayFrameSubscription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #if UniRxLibrary 4 | using UnityObservable = UniRx.ObservableUnity; 5 | #else 6 | using UnityObservable = UniRx.Observable; 7 | #endif 8 | 9 | namespace UniRx.Operators 10 | { 11 | internal class DelayFrameSubscriptionObservable : OperatorObservableBase 12 | { 13 | readonly IObservable source; 14 | readonly int frameCount; 15 | readonly FrameCountType frameCountType; 16 | 17 | public DelayFrameSubscriptionObservable(IObservable source, int frameCount, FrameCountType frameCountType) 18 | : base(source.IsRequiredSubscribeOnCurrentThread()) 19 | { 20 | this.source = source; 21 | this.frameCount = frameCount; 22 | this.frameCountType = frameCountType; 23 | } 24 | 25 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 26 | { 27 | var d = new MultipleAssignmentDisposable(); 28 | d.Disposable = UnityObservable.TimerFrame(frameCount, frameCountType) 29 | .Subscribe(_ => 30 | { 31 | d.Disposable = source.Subscribe(observer); 32 | }); 33 | 34 | return d; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Operators/FromCoroutine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace UniRx.Operators 5 | { 6 | internal class FromCoroutine : OperatorObservableBase 7 | { 8 | readonly Func, CancellationToken, IEnumerator> coroutine; 9 | 10 | public FromCoroutine(Func, CancellationToken, IEnumerator> coroutine) 11 | : base(false) 12 | { 13 | this.coroutine = coroutine; 14 | } 15 | 16 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 17 | { 18 | var fromCoroutineObserver = new FromCoroutineObserver(observer, cancel); 19 | 20 | var moreCancel = new BooleanDisposable(); 21 | 22 | MainThreadDispatcher.SendStartCoroutine(coroutine(fromCoroutineObserver, new CancellationToken(moreCancel))); 23 | 24 | return moreCancel; 25 | } 26 | 27 | class FromCoroutineObserver : OperatorObserverBase 28 | { 29 | public FromCoroutineObserver(IObserver observer, IDisposable cancel) : base(observer, cancel) 30 | { 31 | } 32 | 33 | public override void OnNext(T value) 34 | { 35 | try 36 | { 37 | base.observer.OnNext(value); 38 | } 39 | catch 40 | { 41 | Dispose(); 42 | throw; 43 | } 44 | } 45 | 46 | public override void OnError(Exception error) 47 | { 48 | try { observer.OnError(error); } 49 | finally { Dispose(); } 50 | } 51 | 52 | public override void OnCompleted() 53 | { 54 | try { observer.OnCompleted(); } 55 | finally { Dispose(); } 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Operators/SubscribeOnMainThread.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniRx.Operators 4 | { 5 | internal class SubscribeOnMainThreadObservable : OperatorObservableBase 6 | { 7 | readonly IObservable source; 8 | readonly IObservable subscribeTrigger; 9 | 10 | public SubscribeOnMainThreadObservable(IObservable source, IObservable subscribeTrigger) 11 | : base(source.IsRequiredSubscribeOnCurrentThread()) 12 | { 13 | this.source = source; 14 | this.subscribeTrigger = subscribeTrigger; 15 | } 16 | 17 | protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) 18 | { 19 | var m = new SingleAssignmentDisposable(); 20 | var d = new SerialDisposable(); 21 | d.Disposable = m; 22 | 23 | m.Disposable = subscribeTrigger.Subscribe(_ => 24 | { 25 | d.Disposable = source.Subscribe(observer); 26 | }); 27 | 28 | return d; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableAnimatorTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; // require keep for Windows Universal App 2 | using UnityEngine; 3 | 4 | namespace UniRx.Triggers 5 | { 6 | [DisallowMultipleComponent] 7 | public class ObservableAnimatorTrigger : ObservableTriggerBase 8 | { 9 | Subject onAnimatorIK; 10 | 11 | /// Callback for setting up animation IK (inverse kinematics). 12 | void OnAnimatorIK(int layerIndex) 13 | { 14 | if (onAnimatorIK != null) onAnimatorIK.OnNext(layerIndex); 15 | } 16 | 17 | /// Callback for setting up animation IK (inverse kinematics). 18 | public IObservable OnAnimatorIKAsObservable() 19 | { 20 | return onAnimatorIK ?? (onAnimatorIK = new Subject()); 21 | } 22 | 23 | Subject onAnimatorMove; 24 | 25 | /// Callback for processing animation movements for modifying root motion. 26 | void OnAnimatorMove() 27 | { 28 | if (onAnimatorMove != null) onAnimatorMove.OnNext(Unit.Default); 29 | } 30 | 31 | /// Callback for processing animation movements for modifying root motion. 32 | public IObservable OnAnimatorMoveAsObservable() 33 | { 34 | return onAnimatorMove ?? (onAnimatorMove = new Subject()); 35 | } 36 | 37 | protected override void RaiseOnCompletedOnDestroy() 38 | { 39 | if (onAnimatorIK != null) 40 | { 41 | onAnimatorIK.OnCompleted(); 42 | } 43 | if (onAnimatorMove != null) 44 | { 45 | onAnimatorMove.OnCompleted(); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableBeginDragTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableBeginDragTrigger : ObservableTriggerBase, IEventSystemHandler, IBeginDragHandler 12 | { 13 | Subject onBeginDrag; 14 | 15 | void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) 16 | { 17 | if (onBeginDrag != null) onBeginDrag.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnBeginDragAsObservable() 21 | { 22 | return onBeginDrag ?? (onBeginDrag = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onBeginDrag != null) 28 | { 29 | onBeginDrag.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableCancelTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableCancelTrigger : ObservableTriggerBase, IEventSystemHandler, ICancelHandler 12 | { 13 | Subject onCancel; 14 | 15 | void ICancelHandler.OnCancel(BaseEventData eventData) 16 | { 17 | if (onCancel != null) onCancel.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnCancelAsObservable() 21 | { 22 | return onCancel ?? (onCancel = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onCancel != null) 28 | { 29 | onCancel.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableCanvasGroupChangedTrigger.cs: -------------------------------------------------------------------------------- 1 | // after uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; 5 | using UnityEngine; 6 | 7 | namespace UniRx.Triggers 8 | { 9 | [DisallowMultipleComponent] 10 | public class ObservableCanvasGroupChangedTrigger : ObservableTriggerBase 11 | { 12 | Subject onCanvasGroupChanged; 13 | 14 | // Callback that is sent if the canvas group is changed 15 | void OnCanvasGroupChanged() 16 | { 17 | if (onCanvasGroupChanged != null) onCanvasGroupChanged.OnNext(Unit.Default); 18 | } 19 | 20 | /// Callback that is sent if the canvas group is changed. 21 | public IObservable OnCanvasGroupChangedAsObservable() 22 | { 23 | return onCanvasGroupChanged ?? (onCanvasGroupChanged = new Subject()); 24 | } 25 | 26 | protected override void RaiseOnCompletedOnDestroy() 27 | { 28 | if (onCanvasGroupChanged != null) 29 | { 30 | onCanvasGroupChanged.OnCompleted(); 31 | } 32 | } 33 | } 34 | } 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableDeselectTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableDeselectTrigger : ObservableTriggerBase, IEventSystemHandler, IDeselectHandler 12 | { 13 | Subject onDeselect; 14 | 15 | void IDeselectHandler.OnDeselect(BaseEventData eventData) 16 | { 17 | if (onDeselect != null) onDeselect.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnDeselectAsObservable() 21 | { 22 | return onDeselect ?? (onDeselect = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onDeselect != null) 28 | { 29 | onDeselect.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableDestroyTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; // require keep for Windows Universal App 2 | using UnityEngine; 3 | 4 | namespace UniRx.Triggers 5 | { 6 | [DisallowMultipleComponent] 7 | public class ObservableDestroyTrigger : MonoBehaviour 8 | { 9 | bool calledDestroy = false; 10 | Subject onDestroy; 11 | 12 | /// This function is called when the MonoBehaviour will be destroyed. 13 | void OnDestroy() 14 | { 15 | calledDestroy = true; 16 | if (onDestroy != null) { onDestroy.OnNext(Unit.Default); onDestroy.OnCompleted(); } 17 | } 18 | 19 | /// This function is called when the MonoBehaviour will be destroyed. 20 | public IObservable OnDestroyAsObservable() 21 | { 22 | if (this == null) return Observable.Return(Unit.Default); 23 | if (calledDestroy) return Observable.Return(Unit.Default); 24 | return onDestroy ?? (onDestroy = new Subject()); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableDragTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableDragTrigger : ObservableTriggerBase, IEventSystemHandler, IDragHandler 12 | { 13 | Subject onDrag; 14 | 15 | void IDragHandler.OnDrag(PointerEventData eventData) 16 | { 17 | if (onDrag != null) onDrag.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnDragAsObservable() 21 | { 22 | return onDrag ?? (onDrag = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onDrag != null) 28 | { 29 | onDrag.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableDropTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableDropTrigger : ObservableTriggerBase, IEventSystemHandler, IDropHandler 12 | { 13 | Subject onDrop; 14 | 15 | void IDropHandler.OnDrop(PointerEventData eventData) 16 | { 17 | if (onDrop != null) onDrop.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnDropAsObservable() 21 | { 22 | return onDrop ?? (onDrop = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onDrop != null) 28 | { 29 | onDrop.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableEnableTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; // require keep for Windows Universal App 2 | using UnityEngine; 3 | 4 | namespace UniRx.Triggers 5 | { 6 | [DisallowMultipleComponent] 7 | public class ObservableEnableTrigger : ObservableTriggerBase 8 | { 9 | Subject onEnable; 10 | 11 | /// This function is called when the object becomes enabled and active. 12 | void OnEnable() 13 | { 14 | if (onEnable != null) onEnable.OnNext(Unit.Default); 15 | } 16 | 17 | /// This function is called when the object becomes enabled and active. 18 | public IObservable OnEnableAsObservable() 19 | { 20 | return onEnable ?? (onEnable = new Subject()); 21 | } 22 | 23 | Subject onDisable; 24 | 25 | /// This function is called when the behaviour becomes disabled () or inactive. 26 | void OnDisable() 27 | { 28 | if (onDisable != null) onDisable.OnNext(Unit.Default); 29 | } 30 | 31 | /// This function is called when the behaviour becomes disabled () or inactive. 32 | public IObservable OnDisableAsObservable() 33 | { 34 | return onDisable ?? (onDisable = new Subject()); 35 | } 36 | 37 | protected override void RaiseOnCompletedOnDestroy() 38 | { 39 | if (onEnable != null) 40 | { 41 | onEnable.OnCompleted(); 42 | } 43 | if (onDisable != null) 44 | { 45 | onDisable.OnCompleted(); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableEndDragTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableEndDragTrigger : ObservableTriggerBase, IEventSystemHandler, IEndDragHandler 12 | { 13 | Subject onEndDrag; 14 | 15 | void IEndDragHandler.OnEndDrag(PointerEventData eventData) 16 | { 17 | if (onEndDrag != null) onEndDrag.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnEndDragAsObservable() 21 | { 22 | return onEndDrag ?? (onEndDrag = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onEndDrag != null) 28 | { 29 | onEndDrag.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableFixedUpdateTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; // require keep for Windows Universal App 2 | using UnityEngine; 3 | 4 | namespace UniRx.Triggers 5 | { 6 | [DisallowMultipleComponent] 7 | public class ObservableFixedUpdateTrigger : ObservableTriggerBase 8 | { 9 | Subject fixedUpdate; 10 | 11 | /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. 12 | void FixedUpdate() 13 | { 14 | if (fixedUpdate != null) fixedUpdate.OnNext(Unit.Default); 15 | } 16 | 17 | /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. 18 | public IObservable FixedUpdateAsObservable() 19 | { 20 | return fixedUpdate ?? (fixedUpdate = new Subject()); 21 | } 22 | 23 | protected override void RaiseOnCompletedOnDestroy() 24 | { 25 | if (fixedUpdate != null) 26 | { 27 | fixedUpdate.OnCompleted(); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableInitializePotentialDragTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableInitializePotentialDragTrigger : ObservableTriggerBase, IEventSystemHandler, IInitializePotentialDragHandler 12 | { 13 | Subject onInitializePotentialDrag; 14 | 15 | void IInitializePotentialDragHandler.OnInitializePotentialDrag(PointerEventData eventData) 16 | { 17 | if (onInitializePotentialDrag != null) onInitializePotentialDrag.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnInitializePotentialDragAsObservable() 21 | { 22 | return onInitializePotentialDrag ?? (onInitializePotentialDrag = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onInitializePotentialDrag != null) 28 | { 29 | onInitializePotentialDrag.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableLateUpdateTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; // require keep for Windows Universal App 2 | using UnityEngine; 3 | 4 | namespace UniRx.Triggers 5 | { 6 | [DisallowMultipleComponent] 7 | public class ObservableLateUpdateTrigger : ObservableTriggerBase 8 | { 9 | Subject lateUpdate; 10 | 11 | /// LateUpdate is called every frame, if the Behaviour is enabled. 12 | void LateUpdate() 13 | { 14 | if (lateUpdate != null) lateUpdate.OnNext(Unit.Default); 15 | } 16 | 17 | /// LateUpdate is called every frame, if the Behaviour is enabled. 18 | public IObservable LateUpdateAsObservable() 19 | { 20 | return lateUpdate ?? (lateUpdate = new Subject()); 21 | } 22 | 23 | protected override void RaiseOnCompletedOnDestroy() 24 | { 25 | if (lateUpdate != null) 26 | { 27 | lateUpdate.OnCompleted(); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableMoveTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableMoveTrigger : ObservableTriggerBase, IEventSystemHandler, IMoveHandler 12 | { 13 | Subject onMove; 14 | 15 | void IMoveHandler.OnMove(AxisEventData eventData) 16 | { 17 | if (onMove != null) onMove.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnMoveAsObservable() 21 | { 22 | return onMove ?? (onMove = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onMove != null) 28 | { 29 | onMove.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservablePointerClickTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservablePointerClickTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerClickHandler 12 | { 13 | Subject onPointerClick; 14 | 15 | void IPointerClickHandler.OnPointerClick(PointerEventData eventData) 16 | { 17 | if (onPointerClick != null) onPointerClick.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnPointerClickAsObservable() 21 | { 22 | return onPointerClick ?? (onPointerClick = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onPointerClick != null) 28 | { 29 | onPointerClick.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservablePointerDownTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservablePointerDownTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerDownHandler 12 | { 13 | Subject onPointerDown; 14 | 15 | void IPointerDownHandler.OnPointerDown(PointerEventData eventData) 16 | { 17 | if (onPointerDown != null) onPointerDown.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnPointerDownAsObservable() 21 | { 22 | return onPointerDown ?? (onPointerDown = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onPointerDown != null) 28 | { 29 | onPointerDown.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservablePointerEnterTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservablePointerEnterTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerEnterHandler 12 | { 13 | Subject onPointerEnter; 14 | 15 | void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData) 16 | { 17 | if (onPointerEnter != null) onPointerEnter.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnPointerEnterAsObservable() 21 | { 22 | return onPointerEnter ?? (onPointerEnter = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onPointerEnter != null) 28 | { 29 | onPointerEnter.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservablePointerExitTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservablePointerExitTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerExitHandler 12 | { 13 | Subject onPointerExit; 14 | 15 | void IPointerExitHandler.OnPointerExit(PointerEventData eventData) 16 | { 17 | if (onPointerExit != null) onPointerExit.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnPointerExitAsObservable() 21 | { 22 | return onPointerExit ?? (onPointerExit = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onPointerExit != null) 28 | { 29 | onPointerExit.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservablePointerUpTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservablePointerUpTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerUpHandler 12 | { 13 | Subject onPointerUp; 14 | 15 | void IPointerUpHandler.OnPointerUp(PointerEventData eventData) 16 | { 17 | if (onPointerUp != null) onPointerUp.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnPointerUpAsObservable() 21 | { 22 | return onPointerUp ?? (onPointerUp = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onPointerUp != null) 28 | { 29 | onPointerUp.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableRectTransformTrigger.cs: -------------------------------------------------------------------------------- 1 | // after uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; 5 | using UnityEngine; 6 | 7 | namespace UniRx.Triggers 8 | { 9 | [DisallowMultipleComponent] 10 | public class ObservableRectTransformTrigger : ObservableTriggerBase 11 | { 12 | Subject onRectTransformDimensionsChange; 13 | 14 | // Callback that is sent if an associated RectTransform has it's dimensions changed 15 | public void OnRectTransformDimensionsChange() 16 | { 17 | if (onRectTransformDimensionsChange != null) onRectTransformDimensionsChange.OnNext(Unit.Default); 18 | } 19 | 20 | /// Callback that is sent if an associated RectTransform has it's dimensions changed. 21 | public IObservable OnRectTransformDimensionsChangeAsObservable() 22 | { 23 | return onRectTransformDimensionsChange ?? (onRectTransformDimensionsChange = new Subject()); 24 | } 25 | 26 | Subject onRectTransformRemoved; 27 | 28 | // Callback that is sent if an associated RectTransform is removed 29 | public void OnRectTransformRemoved() 30 | { 31 | if (onRectTransformRemoved != null) onRectTransformRemoved.OnNext(Unit.Default); 32 | } 33 | 34 | /// Callback that is sent if an associated RectTransform is removed. 35 | public IObservable OnRectTransformRemovedAsObservable() 36 | { 37 | return onRectTransformRemoved ?? (onRectTransformRemoved = new Subject()); 38 | } 39 | 40 | protected override void RaiseOnCompletedOnDestroy() 41 | { 42 | if (onRectTransformDimensionsChange != null) 43 | { 44 | onRectTransformDimensionsChange.OnCompleted(); 45 | } 46 | if (onRectTransformRemoved != null) 47 | { 48 | onRectTransformRemoved.OnCompleted(); 49 | } 50 | } 51 | 52 | } 53 | } 54 | 55 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableScrollTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableScrollTrigger : ObservableTriggerBase, IEventSystemHandler, IScrollHandler 12 | { 13 | Subject onScroll; 14 | 15 | void IScrollHandler.OnScroll(PointerEventData eventData) 16 | { 17 | if (onScroll != null) onScroll.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnScrollAsObservable() 21 | { 22 | return onScroll ?? (onScroll = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onScroll != null) 28 | { 29 | onScroll.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableSelectTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableSelectTrigger : ObservableTriggerBase, IEventSystemHandler, ISelectHandler 12 | { 13 | Subject onSelect; 14 | 15 | void ISelectHandler.OnSelect(BaseEventData eventData) 16 | { 17 | if (onSelect != null) onSelect.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnSelectAsObservable() 21 | { 22 | return onSelect ?? (onSelect = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onSelect != null) 28 | { 29 | onSelect.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableSubmitTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableSubmitTrigger : ObservableTriggerBase, IEventSystemHandler, ISubmitHandler 12 | { 13 | Subject onSubmit; 14 | 15 | void ISubmitHandler.OnSubmit(BaseEventData eventData) 16 | { 17 | if (onSubmit != null) onSubmit.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnSubmitAsObservable() 21 | { 22 | return onSubmit ?? (onSubmit = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onSubmit != null) 28 | { 29 | onSubmit.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableUpdateSelectedTrigger.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; // require keep for Windows Universal App 5 | using UnityEngine; 6 | using UnityEngine.EventSystems; 7 | 8 | namespace UniRx.Triggers 9 | { 10 | [DisallowMultipleComponent] 11 | public class ObservableUpdateSelectedTrigger : ObservableTriggerBase, IEventSystemHandler, IUpdateSelectedHandler 12 | { 13 | Subject onUpdateSelected; 14 | 15 | void IUpdateSelectedHandler.OnUpdateSelected(BaseEventData eventData) 16 | { 17 | if (onUpdateSelected != null) onUpdateSelected.OnNext(eventData); 18 | } 19 | 20 | public IObservable OnUpdateSelectedAsObservable() 21 | { 22 | return onUpdateSelected ?? (onUpdateSelected = new Subject()); 23 | } 24 | 25 | protected override void RaiseOnCompletedOnDestroy() 26 | { 27 | if (onUpdateSelected != null) 28 | { 29 | onUpdateSelected.OnCompleted(); 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableUpdateTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; // require keep for Windows Universal App 2 | using UnityEngine; 3 | 4 | namespace UniRx.Triggers 5 | { 6 | [DisallowMultipleComponent] 7 | public class ObservableUpdateTrigger : ObservableTriggerBase 8 | { 9 | Subject update; 10 | 11 | /// Update is called every frame, if the MonoBehaviour is enabled. 12 | void Update() 13 | { 14 | if (update != null) update.OnNext(Unit.Default); 15 | } 16 | 17 | /// Update is called every frame, if the MonoBehaviour is enabled. 18 | public IObservable UpdateAsObservable() 19 | { 20 | return update ?? (update = new Subject()); 21 | } 22 | 23 | protected override void RaiseOnCompletedOnDestroy() 24 | { 25 | if (update != null) 26 | { 27 | update.OnCompleted(); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableVisibleTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; // require keep for Windows Universal App 2 | using UnityEngine; 3 | 4 | namespace UniRx.Triggers 5 | { 6 | [DisallowMultipleComponent] 7 | public class ObservableVisibleTrigger : ObservableTriggerBase 8 | { 9 | Subject onBecameInvisible; 10 | 11 | /// OnBecameInvisible is called when the renderer is no longer visible by any camera. 12 | void OnBecameInvisible() 13 | { 14 | if (onBecameInvisible != null) onBecameInvisible.OnNext(Unit.Default); 15 | } 16 | 17 | /// OnBecameInvisible is called when the renderer is no longer visible by any camera. 18 | public IObservable OnBecameInvisibleAsObservable() 19 | { 20 | return onBecameInvisible ?? (onBecameInvisible = new Subject()); 21 | } 22 | 23 | Subject onBecameVisible; 24 | 25 | /// OnBecameVisible is called when the renderer became visible by any camera. 26 | void OnBecameVisible() 27 | { 28 | if (onBecameVisible != null) onBecameVisible.OnNext(Unit.Default); 29 | } 30 | 31 | /// OnBecameVisible is called when the renderer became visible by any camera. 32 | public IObservable OnBecameVisibleAsObservable() 33 | { 34 | return onBecameVisible ?? (onBecameVisible = new Subject()); 35 | } 36 | 37 | protected override void RaiseOnCompletedOnDestroy() 38 | { 39 | if (onBecameInvisible != null) 40 | { 41 | onBecameInvisible.OnCompleted(); 42 | } 43 | if (onBecameVisible != null) 44 | { 45 | onBecameVisible.OnCompleted(); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/UnityGraphicExtensions.cs: -------------------------------------------------------------------------------- 1 | // for uGUI(from 4.6) 2 | #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) 3 | 4 | using System; 5 | using UnityEngine.Events; 6 | using UnityEngine.UI; 7 | 8 | namespace UniRx 9 | { 10 | public static partial class UnityGraphicExtensions 11 | { 12 | public static IObservable DirtyLayoutCallbackAsObservable(this Graphic graphic) 13 | { 14 | return Observable.Create(observer => 15 | { 16 | UnityAction registerHandler = () => observer.OnNext(Unit.Default); 17 | graphic.RegisterDirtyLayoutCallback(registerHandler); 18 | return Disposable.Create(() => graphic.UnregisterDirtyLayoutCallback(registerHandler)); 19 | }); 20 | } 21 | 22 | public static IObservable DirtyMaterialCallbackAsObservable(this Graphic graphic) 23 | { 24 | return Observable.Create(observer => 25 | { 26 | UnityAction registerHandler = () => observer.OnNext(Unit.Default); 27 | graphic.RegisterDirtyMaterialCallback(registerHandler); 28 | return Disposable.Create(() => graphic.UnregisterDirtyMaterialCallback(registerHandler)); 29 | }); 30 | } 31 | 32 | public static IObservable DirtyVerticesCallbackAsObservable(this Graphic graphic) 33 | { 34 | return Observable.Create(observer => 35 | { 36 | UnityAction registerHandler = () => observer.OnNext(Unit.Default); 37 | graphic.RegisterDirtyVerticesCallback(registerHandler); 38 | return Disposable.Create(() => graphic.UnregisterDirtyVerticesCallback(registerHandler)); 39 | }); 40 | } 41 | } 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityEngineBridge/YieldInstructionCache.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UniRx 4 | { 5 | internal static class YieldInstructionCache 6 | { 7 | public static readonly WaitForEndOfFrame WaitForEndOfFrame = new WaitForEndOfFrame(); 8 | public static readonly WaitForFixedUpdate WaitForFixedUpdate = new WaitForFixedUpdate(); 9 | } 10 | } -------------------------------------------------------------------------------- /Assets/UniRx/Scripts/UnityWinRTBridge/Thread.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_METRO 2 | 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading; 9 | 10 | namespace UniRx 11 | { 12 | public static class Thread 13 | { 14 | public static void Sleep(TimeSpan wait) 15 | { 16 | new System.Threading.ManualResetEvent(false).WaitOne(wait); 17 | } 18 | 19 | public static void Sleep(int ms) 20 | { 21 | new System.Threading.ManualResetEvent(false).WaitOne(ms); 22 | } 23 | } 24 | } 25 | 26 | #endif -------------------------------------------------------------------------------- /Assets/UnitTests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50a4b6844a91a0c429bc0f18eb20405d 3 | folderAsset: yes 4 | timeCreated: 1450102907 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnitTests/SceneItems.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7261125281f841d478485ab5274b3b26 3 | folderAsset: yes 4 | timeCreated: 1450073182 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnitTests/SceneItems/Result.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using UnityEngine.UI; 5 | using System; 6 | 7 | namespace UniRx.Tests 8 | { 9 | public class Result : PresenterBase 10 | { 11 | public UnityEngine.UI.Text text; 12 | 13 | public ReactiveProperty Message { get; private set; } 14 | public ReactiveProperty Color { get; private set; } 15 | 16 | protected override IPresenter[] Children 17 | { 18 | get 19 | { 20 | return EmptyChildren; 21 | } 22 | } 23 | 24 | protected override void BeforeInitialize() 25 | { 26 | } 27 | 28 | protected override void Initialize() 29 | { 30 | var image = this.GetComponent(); 31 | 32 | Message = new ReactiveProperty(""); 33 | Message.SubscribeToText(text); 34 | 35 | Color = new ReactiveProperty(); 36 | Color.Subscribe(x => image.color = x); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Assets/UnitTests/SceneItems/Result.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a46b5e47d35c3fe4eb23775386133be5 3 | timeCreated: 1450080867 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitTests/SceneItems/UnitTestScene.cs: -------------------------------------------------------------------------------- 1 | #if !UNITY_METRO 2 | 3 | using UnityEngine; 4 | using System.Collections; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | using UnityEngine.UI; 7 | using System; 8 | 9 | namespace UniRx.Tests 10 | { 11 | public class UnitTestScene : MonoBehaviour 12 | { 13 | public Button buttonPrefab; 14 | public GameObject buttonVertical; 15 | 16 | public Result resultPrefab; 17 | public GameObject resultVertical; 18 | 19 | 20 | void Start() 21 | { 22 | // UnitTest uses Wait, it can't run on MainThreadScheduler. 23 | Scheduler.DefaultSchedulers.SetDotNetCompatible(); 24 | MainThreadDispatcher.Initialize(); 25 | 26 | UnitTests.SetButtons(buttonPrefab, buttonVertical, resultPrefab, resultVertical); 27 | } 28 | } 29 | } 30 | 31 | #endif -------------------------------------------------------------------------------- /Assets/UnitTests/SceneItems/UnitTestScene.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b57116993f98544ab6b3e24273476ca 3 | timeCreated: 1450079786 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitTests/Tools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d625ee5efe7f94c4d9f0fe3ec10f04cd 3 | folderAsset: yes 4 | timeCreated: 1449667794 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnitTests/Tools/ChainingAssertion.Unity.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02a0c91cd48d1384a8ecbb0359acbde1 3 | timeCreated: 1449667794 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitTests/Tools/Container.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f36ce662d0145b4bbe607bb840f96b7 3 | timeCreated: 1450072453 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitTests/Tools/Shim.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed80a523820207f4fa5baf07e831f9d6 3 | timeCreated: 1449667803 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitTests/Tools/TestUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniRx.Tests 5 | { 6 | public static class TestUtil 7 | { 8 | public static T[] ToArrayWait(this IObservable source) 9 | { 10 | return source.ToArray().Wait(); 11 | } 12 | 13 | public static RecordObserver Record(this IObservable source) 14 | { 15 | var d = new SingleAssignmentDisposable(); 16 | var observer = new RecordObserver(d); 17 | d.Disposable = source.Subscribe(observer); 18 | 19 | return observer; 20 | } 21 | } 22 | 23 | public class RecordObserver : IObserver 24 | { 25 | readonly object gate = new object(); 26 | readonly IDisposable subscription; 27 | 28 | public List Values { get; set; } 29 | public List> Notifications { get; set; } 30 | 31 | public RecordObserver(IDisposable subscription) 32 | { 33 | this.subscription = subscription; 34 | this.Values = new List(); 35 | this.Notifications = new List>(); 36 | } 37 | 38 | public void DisposeSubscription() 39 | { 40 | subscription.Dispose(); 41 | } 42 | 43 | public void OnNext(T value) 44 | { 45 | lock (gate) 46 | { 47 | Values.Add(value); 48 | Notifications.Add(Notification.CreateOnNext(value)); 49 | } 50 | } 51 | 52 | public void OnError(Exception error) 53 | { 54 | lock (gate) 55 | { 56 | Notifications.Add(Notification.CreateOnError(error)); 57 | } 58 | } 59 | public void OnCompleted() 60 | { 61 | lock (gate) 62 | { 63 | Notifications.Add(Notification.CreateOnCompleted()); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Assets/UnitTests/Tools/TestUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fca1d45ad247b44ba49da01555ad587 3 | timeCreated: 1449671644 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitTests/UnitTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4810fcaadfbdbe44d96a8c89c66770b0 3 | timeCreated: 1450072450 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnitTests/UnitTests.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84b66fe9021e5924f97ebb52caca103e 3 | timeCreated: 1450072450 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityVS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43b8f63cdccab274ea9ddc419373a91e 3 | folderAsset: yes 4 | timeCreated: 1425283442 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll -------------------------------------------------------------------------------- /Assets/smcs.rsp: -------------------------------------------------------------------------------- 1 | -warnaserror+ -------------------------------------------------------------------------------- /Assets/smcs.rsp.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d4804597ef4b12498a3067c1619022c 3 | timeCreated: 1450159973 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Dlls/UniRx.Library.Unity/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UniRx.Library.Unity")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UniRx.Library.Unity")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("5.1.0.0")] 33 | [assembly: AssemblyFileVersion("5.1.0.0")] 34 | -------------------------------------------------------------------------------- /Dlls/UniRx.Library/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UniRx.Library")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UniRx.Library")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("5.1.0.0")] 33 | [assembly: AssemblyFileVersion("5.1.0.0")] 34 | 35 | [assembly: InternalsVisibleTo("UniRx.Unity")] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Yoshifumi Kawai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | m_SpeedOfSound: 347 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_DSPBufferSize: 0 12 | m_DisableAudio: 0 13 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_BounceThreshold: 2 9 | m_SleepVelocity: .150000006 10 | m_SleepAngularVelocity: .140000001 11 | m_MaxAngularVelocity: 7 12 | m_MinPenetrationForPenalty: .00999999978 13 | m_SolverIterationCount: 6 14 | m_RaycastsHitTriggers: 1 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 0 9 | path: Assets/Scenes/Clean.unity 10 | - enabled: 1 11 | path: Assets/Scenes/UnitAssertion.unity 12 | - enabled: 1 13 | path: Assets/Scenes/TestSandbox.unity 14 | - enabled: 0 15 | path: Assets/Scenes/LoadLevelTest.unity 16 | - enabled: 0 17 | path: Assets/Scenes/LoadLevelTestAdditive.unity 18 | - enabled: 0 19 | path: Assets/Scenes/LoadLevelTestNew.unity 20 | - enabled: 0 21 | path: Assets/Scenes/NextSandBox.unity 22 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Hidden Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 1 12 | m_SpritePackerMode: 0 13 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_LegacyDeferred: 14 | m_Mode: 1 15 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 16 | m_AlwaysIncludedShaders: 17 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 18 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 19 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 20 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 21 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 22 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 23 | m_PreloadedShaders: [] 24 | m_ShaderSettings: 25 | useScreenSpaceShadows: 1 26 | m_BuildTargetShaderSettings: [] 27 | m_LightmapStripping: 0 28 | m_FogStripping: 0 29 | m_LightmapKeepPlain: 1 30 | m_LightmapKeepDirCombined: 1 31 | m_LightmapKeepDirSeparate: 1 32 | m_LightmapKeepDynamicPlain: 1 33 | m_LightmapKeepDynamicDirCombined: 1 34 | m_LightmapKeepDynamicDirSeparate: 1 35 | m_FogKeepLinear: 1 36 | m_FogKeepExp: 1 37 | m_FogKeepExp2: 1 38 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_VelocityIterations: 8 9 | m_PositionIterations: 3 10 | m_VelocityThreshold: 1 11 | m_MaxLinearCorrection: .200000003 12 | m_MaxAngularCorrection: 8 13 | m_MaxTranslationSpeed: 100 14 | m_MaxRotationSpeed: 360 15 | m_BaumgarteScale: .200000003 16 | m_BaumgarteTimeOfImpactScale: .75 17 | m_TimeToSleep: .5 18 | m_LinearSleepTolerance: .00999999978 19 | m_AngularSleepTolerance: 2 20 | m_RaycastsHitTriggers: 1 21 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 22 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.3.0f4 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | tags: 6 | - 7 | Builtin Layer 0: Default 8 | Builtin Layer 1: TransparentFX 9 | Builtin Layer 2: Ignore Raycast 10 | Builtin Layer 3: 11 | Builtin Layer 4: Water 12 | Builtin Layer 5: UI 13 | Builtin Layer 6: 14 | Builtin Layer 7: 15 | User Layer 8: 16 | User Layer 9: 17 | User Layer 10: 18 | User Layer 11: 19 | User Layer 12: 20 | User Layer 13: 21 | User Layer 14: 22 | User Layer 15: 23 | User Layer 16: 24 | User Layer 17: 25 | User Layer 18: 26 | User Layer 19: 27 | User Layer 20: 28 | User Layer 21: 29 | User Layer 22: 30 | User Layer 23: 31 | User Layer 24: 32 | User Layer 25: 33 | User Layer 26: 34 | User Layer 27: 35 | User Layer 28: 36 | User Layer 29: 37 | User Layer 30: 38 | User Layer 31: 39 | m_SortingLayers: 40 | - name: Default 41 | userID: 0 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!292 &1 4 | UnityAdsSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_InitializeOnStartup: 1 8 | m_TestMode: 0 9 | m_EnabledPlatforms: 4294967295 10 | m_IosGameId: 11 | m_AndroidGameId: 12 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | UnityPurchasingSettings: 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | UnityAnalyticsSettings: 10 | m_Enabled: 0 11 | m_InitializeOnStartup: 1 12 | m_TestMode: 0 13 | m_TestEventUrl: 14 | m_TestConfigUrl: 15 | -------------------------------------------------------------------------------- /StoreDocument/AnalyzerReference.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/AnalyzerReference.jpg -------------------------------------------------------------------------------- /StoreDocument/MVP_Pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/MVP_Pattern.png -------------------------------------------------------------------------------- /StoreDocument/MVRP_Loop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/MVRP_Loop.png -------------------------------------------------------------------------------- /StoreDocument/OriginalIcon_511x511.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/OriginalIcon_511x511.png -------------------------------------------------------------------------------- /StoreDocument/RxPropInspector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/RxPropInspector.png -------------------------------------------------------------------------------- /StoreDocument/VSAnalyzer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/VSAnalyzer.jpg -------------------------------------------------------------------------------- /StoreDocument/big_precise.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/big_precise.jpg -------------------------------------------------------------------------------- /StoreDocument/big_precise.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/big_precise.psd -------------------------------------------------------------------------------- /StoreDocument/icon_precise.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/icon_precise.jpg -------------------------------------------------------------------------------- /StoreDocument/icon_precise.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/icon_precise.psd -------------------------------------------------------------------------------- /StoreDocument/presenterbase_steps.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/presenterbase_steps.gif -------------------------------------------------------------------------------- /StoreDocument/small_precise.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/small_precise.jpg -------------------------------------------------------------------------------- /StoreDocument/small_precise.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/small_precise.psd -------------------------------------------------------------------------------- /StoreDocument/ss1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/ss1.jpg -------------------------------------------------------------------------------- /StoreDocument/ss2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/ss2.jpg -------------------------------------------------------------------------------- /StoreDocument/ss3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rampage1212/Unity-UniRx/9d2af3b9b21838f29c9220b1c396fdbeb76c782d/StoreDocument/ss3.jpg -------------------------------------------------------------------------------- /Tests/UniRx.Console/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Tests/UniRx.Console/Playground.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading; 7 | 8 | namespace UniRx 9 | { 10 | public class Playground 11 | { 12 | public void Run() 13 | { 14 | GCCheck(); 15 | 16 | } 17 | 18 | void GCCheck() 19 | { 20 | var t = Tuple.Create(1, 1); 21 | var dict = new Dictionary, int>(); 22 | //var d = EqualityComparer>.Default; 23 | //Console.WriteLine(d.GetType().Name); 24 | dict[Tuple.Create(1, 1)] = 1; 25 | for (int i = 0; i < 100000000; i++) 26 | { 27 | //dict.ContainsKey(Tuple.Create(1, 1)); 28 | new object(); 29 | //d.Equals(t, Tuple.Create(1, 1)); 30 | } 31 | 32 | Console.WriteLine("0:" + GC.CollectionCount(0)); 33 | Console.WriteLine("1:" + GC.CollectionCount(1)); 34 | Console.WriteLine("2:" + GC.CollectionCount(2)); 35 | } 36 | 37 | static IObservable Hoge(Subject subject) 38 | { 39 | return Observable.Create(observer => 40 | { 41 | observer.OnNext(1000); 42 | return subject.Subscribe(observer); 43 | }); 44 | } 45 | 46 | static void ShowStackTrace() 47 | { 48 | Console.WriteLine("----------------"); 49 | Console.WriteLine(new StackTrace().ToString()); 50 | } 51 | } 52 | 53 | public static class OEx 54 | { 55 | public static void Is(this T t, T t2) 56 | { 57 | Console.WriteLine("T:" + t + " T2:" + t2); 58 | } 59 | } 60 | 61 | class MyEvent 62 | { 63 | public Action action = null; 64 | 65 | public void Fire(int x) 66 | { 67 | action.Invoke(x); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Tests/UniRx.Console/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 6 | // アセンブリに関連付けられている情報を変更するには、 7 | // これらの属性値を変更してください。 8 | [assembly: AssemblyTitle("UniRx.Console")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UniRx.Console")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから 18 | // 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、 19 | // その型の ComVisible 属性を true に設定してください。 20 | [assembly: ComVisible(false)] 21 | 22 | // 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です 23 | [assembly: Guid("b661e150-c548-42ee-8925-2f732c5ade53")] 24 | 25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を 33 | // 既定値にすることができます: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/AggregateTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace UniRx.Tests.Operators 5 | { 6 | [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass] 7 | public class AggregateTest 8 | { 9 | [TestMethod] 10 | public void Scan() 11 | { 12 | var range = Observable.Range(1, 5); 13 | 14 | range.Scan((x, y) => x + y).ToArrayWait().IsCollection(1, 3, 6, 10, 15); 15 | range.Scan(100, (x, y) => x + y).ToArrayWait().IsCollection(101, 103, 106, 110, 115); 16 | 17 | Observable.Empty().Scan((x, y) => x + y).ToArrayWait().IsCollection(); 18 | Observable.Empty().Scan(100, (x, y) => x + y).ToArrayWait().IsCollection(); 19 | } 20 | 21 | [TestMethod] 22 | public void Aggregate() 23 | { 24 | AssertEx.Throws(() => Observable.Empty().Aggregate((x, y) => x + y).Wait()); 25 | Observable.Range(1, 5).Aggregate((x, y) => x + y).Wait().Is(15); 26 | 27 | Observable.Empty().Aggregate(100, (x, y) => x + y).Wait().Is(100); 28 | Observable.Range(1, 5).Aggregate(100, (x, y) => x + y).Wait().Is(115); 29 | 30 | Observable.Empty().Aggregate(100, (x, y) => x + y, x => x + x).Wait().Is(200); 31 | Observable.Range(1, 5).Aggregate(100, (x, y) => x + y, x => x + x).Wait().Is(230); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/ContinueWithTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | 7 | namespace UniRx.Tests.Operators 8 | { 9 | [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass] 10 | public class ContinueWithTest 11 | { 12 | [TestMethod] 13 | public void ContinueWith() 14 | { 15 | var subject = new Subject(); 16 | 17 | var record = subject.ContinueWith(x => Observable.Return(x)).Record(); 18 | 19 | subject.OnNext(10); 20 | record.Values.Count.Is(0); 21 | 22 | subject.OnNext(100); 23 | record.Values.Count.Is(0); 24 | 25 | subject.OnCompleted(); 26 | record.Values[0].Is(100); 27 | record.Notifications.Last().Kind.Is(NotificationKind.OnCompleted); 28 | } 29 | 30 | [TestMethod] 31 | public void ContinueWith2() 32 | { 33 | var subject = new Subject(); 34 | 35 | var record = subject.ContinueWith(x => Observable.Return(x).Delay(TimeSpan.FromMilliseconds(100))).Record(); 36 | 37 | subject.OnNext(10); 38 | record.Values.Count.Is(0); 39 | 40 | subject.OnNext(100); 41 | record.Values.Count.Is(0); 42 | 43 | subject.OnCompleted(); 44 | Thread.Sleep(TimeSpan.FromMilliseconds(200)); 45 | record.Values[0].Is(100); 46 | record.Notifications.Last().Kind.Is(NotificationKind.OnCompleted); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/ConversionTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace UniRx.Tests.Operators 7 | { 8 | [TestClass] 9 | public class ConversionTest 10 | { 11 | [TestMethod] 12 | public void AsObservable() 13 | { 14 | Observable.Range(1, 10).AsObservable().ToArrayWait().IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 15 | } 16 | 17 | [TestMethod] 18 | public void AsUnitObservable() 19 | { 20 | Observable.Range(1, 3).AsUnitObservable().ToArrayWait().IsCollection(Unit.Default, Unit.Default, Unit.Default); 21 | } 22 | 23 | [TestMethod] 24 | public void ToObservable() 25 | { 26 | Enumerable.Range(1, 3).ToObservable(Scheduler.CurrentThread).ToArrayWait().IsCollection(1, 2, 3); 27 | Enumerable.Range(1, 3).ToObservable(Scheduler.ThreadPool).ToArrayWait().IsCollection(1, 2, 3); 28 | Enumerable.Range(1, 3).ToObservable(Scheduler.Immediate).ToArrayWait().IsCollection(1, 2, 3); 29 | } 30 | 31 | [TestMethod] 32 | public void Cast() 33 | { 34 | Observable.Range(1, 3).Cast().ToArrayWait().IsCollection(1, 2, 3); 35 | } 36 | 37 | [TestMethod] 38 | public void OfType() 39 | { 40 | var subject = new Subject(); 41 | 42 | var list = new List(); 43 | subject.OfType(default(int)).Subscribe(x => list.Add(x)); 44 | 45 | subject.OnNext(1); 46 | subject.OnNext(2); 47 | subject.OnNext("hogehoge"); 48 | subject.OnNext(3); 49 | 50 | list.IsCollection(1, 2, 3); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 6 | // アセンブリに関連付けられている情報を変更するには、 7 | // これらの属性値を変更してください。 8 | [assembly: AssemblyTitle("UniRx.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UniRx.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから 18 | // 参照できなくなります。このアセンブリ内で COM から型にアクセスする必要がある場合は、 19 | // その型の ComVisible 属性を true に設定してください。 20 | [assembly: ComVisible(false)] 21 | 22 | // このプロジェクトが COM に公開される場合、次の GUID がタイプ ライブラリの ID になります。 23 | [assembly: Guid("6fcfdfde-9169-45a4-9739-260c68b0acd0")] 24 | 25 | // アセンブリのバージョン情報は、以下の 4 つの値で構成されています: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // すべての値を指定するか、以下のように '*' を使用してビルド番号とリビジョン番号を 33 | // 既定値にすることができます: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/RangeTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace UniRx.Tests.Operators 5 | { 6 | [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass] 7 | public class RangeTest 8 | { 9 | [TestMethod] 10 | public void Range() 11 | { 12 | AssertEx.Throws(() => Observable.Range(1, -1).ToArray().Wait()); 13 | 14 | Observable.Range(1, 0).ToArray().Wait().Length.Is(0); 15 | Observable.Range(1, 10).ToArray().Wait().IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/TakeTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace UniRx.Tests.Operators 5 | { 6 | [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass] 7 | public class TakeTest 8 | { 9 | [TestMethod] 10 | public void TakeCount() 11 | { 12 | var range = Observable.Range(1, 10); 13 | 14 | AssertEx.Throws(() => range.Take(-1)); 15 | 16 | range.Take(0).ToArray().Wait().Length.Is(0); 17 | 18 | range.Take(3).ToArrayWait().IsCollection(1, 2, 3); 19 | range.Take(15).ToArrayWait().IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/ToTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | 7 | namespace UniRx.Tests.Operators 8 | { 9 | [TestClass] 10 | public class ToTest 11 | { 12 | 13 | [TestMethod] 14 | public void ToArray() 15 | { 16 | Observable.Empty().ToArray().Wait().IsCollection(); 17 | Observable.Return(10).ToArray().Wait().IsCollection(10); 18 | Observable.Range(1, 10).ToArray().Wait().IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 19 | } 20 | 21 | [TestMethod] 22 | public void ToList() 23 | { 24 | Observable.Empty().ToList().Wait().IsCollection(); 25 | Observable.Return(10).ToList().Wait().IsCollection(10); 26 | Observable.Range(1, 10).ToList().Wait().IsCollection(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/Tools/Init.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace UniRx.Tests 8 | { 9 | [TestClass] 10 | public class Init 11 | { 12 | [AssemblyInitialize] 13 | public static void Initialize(TestContext ctx) 14 | { 15 | Scheduler.DefaultSchedulers.SetDotNetCompatible(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Tests/UniRx.Tests/Tools/TestUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace UniRx.Tests 5 | { 6 | public static class TestUtil 7 | { 8 | public static T[] ToArrayWait(this IObservable source) 9 | { 10 | return source.ToArray().Wait(); 11 | } 12 | 13 | public static RecordObserver Record(this IObservable source) 14 | { 15 | var d = new SingleAssignmentDisposable(); 16 | var observer = new RecordObserver(d); 17 | d.Disposable = source.Subscribe(observer); 18 | 19 | return observer; 20 | } 21 | } 22 | 23 | public class RecordObserver : IObserver 24 | { 25 | readonly object gate = new object(); 26 | readonly IDisposable subscription; 27 | 28 | public List Values { get; set; } 29 | public List> Notifications { get; set; } 30 | 31 | public RecordObserver(IDisposable subscription) 32 | { 33 | this.subscription = subscription; 34 | this.Values = new List(); 35 | this.Notifications = new List>(); 36 | } 37 | 38 | public void DisposeSubscription() 39 | { 40 | subscription.Dispose(); 41 | } 42 | 43 | public void OnNext(T value) 44 | { 45 | lock (gate) 46 | { 47 | Values.Add(value); 48 | Notifications.Add(Notification.CreateOnNext(value)); 49 | } 50 | } 51 | 52 | public void OnError(Exception error) 53 | { 54 | lock (gate) 55 | { 56 | Notifications.Add(Notification.CreateOnError(error)); 57 | } 58 | } 59 | public void OnCompleted() 60 | { 61 | lock (gate) 62 | { 63 | Notifications.Add(Notification.CreateOnCompleted()); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/WhenAllTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | 5 | namespace UniRx.Tests.Operators 6 | { 7 | [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass] 8 | public class WhenAllTest 9 | { 10 | [TestMethod] 11 | public void WhenAllEmpty() 12 | { 13 | var xs = Observable.WhenAll(new IObservable[0]).Wait(); 14 | xs.Length.Is(0); 15 | 16 | var xs2 = Observable.WhenAll(Enumerable.Empty>().Select(x => x)).Wait(); 17 | xs2.Length.Is(0); 18 | } 19 | 20 | [TestMethod] 21 | public void WhenAll() 22 | { 23 | var xs = Observable.WhenAll( 24 | Observable.Return(100), 25 | Observable.Timer(TimeSpan.FromSeconds(1)).Select(_ => 5), 26 | Observable.Range(1, 4)) 27 | .Wait(); 28 | 29 | xs.IsCollection(100, 5, 4); 30 | } 31 | 32 | [TestMethod] 33 | public void WhenAllEnumerable() 34 | { 35 | var xs = new[] { 36 | Observable.Return(100), 37 | Observable.Timer(TimeSpan.FromSeconds(1)).Select(_ => 5), 38 | Observable.Range(1, 4) 39 | }.Select(x => x).WhenAll().Wait(); 40 | 41 | xs.IsCollection(100, 5, 4); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Tests/UniRx.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | --------------------------------------------------------------------------------