From 1475fa2eadf2cecc35464b6a9e053ed6d596b911 Mon Sep 17 00:00:00 2001 From: neuecc Date: Tue, 13 Feb 2024 18:29:53 +0900 Subject: [PATCH] Add Triggers --- README.md | 8 +- .../Assets/R3.Unity/Runtime/R3.Unity.asmdef | 15 + .../Assets/R3.Unity/Runtime/Triggers.meta | 8 + .../Triggers/ObservableAnimatorTrigger.cs | 48 ++ .../ObservableAnimatorTrigger.cs.meta | 11 + .../Triggers/ObservableBeginDragTrigger.cs | 33 ++ .../ObservableBeginDragTrigger.cs.meta | 11 + .../Triggers/ObservableCancelTrigger.cs | 33 ++ .../Triggers/ObservableCancelTrigger.cs.meta | 11 + .../ObservableCanvasGroupChangedTrigger.cs | 30 ++ ...bservableCanvasGroupChangedTrigger.cs.meta | 11 + .../Triggers/ObservableCollision2DTrigger.cs | 68 +++ .../ObservableCollision2DTrigger.cs.meta | 11 + .../Triggers/ObservableCollisionTrigger.cs | 68 +++ .../ObservableCollisionTrigger.cs.meta | 11 + .../Triggers/ObservableDeselectTrigger.cs | 33 ++ .../ObservableDeselectTrigger.cs.meta | 11 + .../Triggers/ObservableDestroyTrigger.cs | 30 ++ .../Triggers/ObservableDestroyTrigger.cs.meta | 11 + .../Runtime/Triggers/ObservableDragTrigger.cs | 33 ++ .../Triggers/ObservableDragTrigger.cs.meta | 11 + .../Runtime/Triggers/ObservableDropTrigger.cs | 31 ++ .../Triggers/ObservableDropTrigger.cs.meta | 11 + .../Triggers/ObservableEnableTrigger.cs | 49 ++ .../Triggers/ObservableEnableTrigger.cs.meta | 11 + .../Triggers/ObservableEndDragTrigger.cs | 31 ++ .../Triggers/ObservableEndDragTrigger.cs.meta | 11 + .../Triggers/ObservableEventTrigger.cs | 355 ++++++++++++++ .../Triggers/ObservableEventTrigger.cs.meta | 11 + .../Triggers/ObservableFixedUpdateTrigger.cs | 31 ++ .../ObservableFixedUpdateTrigger.cs.meta | 11 + ...bservableInitializePotentialDragTrigger.cs | 31 ++ ...ableInitializePotentialDragTrigger.cs.meta | 11 + .../Triggers/ObservableJointTrigger.cs | 49 ++ .../Triggers/ObservableJointTrigger.cs.meta | 11 + .../Triggers/ObservableLateUpdateTrigger.cs | 30 ++ .../ObservableLateUpdateTrigger.cs.meta | 11 + .../Triggers/ObservableMouseTrigger.cs | 143 ++++++ .../Triggers/ObservableMouseTrigger.cs.meta | 11 + .../Runtime/Triggers/ObservableMoveTrigger.cs | 31 ++ .../Triggers/ObservableMoveTrigger.cs.meta | 11 + .../Triggers/ObservableParticleTrigger.cs | 48 ++ .../ObservableParticleTrigger.cs.meta | 11 + .../Triggers/ObservablePointerClickTrigger.cs | 31 ++ .../ObservablePointerClickTrigger.cs.meta | 11 + .../Triggers/ObservablePointerDownTrigger.cs | 31 ++ .../ObservablePointerDownTrigger.cs.meta | 11 + .../Triggers/ObservablePointerEnterTrigger.cs | 31 ++ .../ObservablePointerEnterTrigger.cs.meta | 11 + .../Triggers/ObservablePointerExitTrigger.cs | 31 ++ .../ObservablePointerExitTrigger.cs.meta | 11 + .../Triggers/ObservablePointerUpTrigger.cs | 31 ++ .../ObservablePointerUpTrigger.cs.meta | 11 + .../ObservableRectTransformTrigger.cs | 49 ++ .../ObservableRectTransformTrigger.cs.meta | 11 + .../Triggers/ObservableScrollTrigger.cs | 32 ++ .../Triggers/ObservableScrollTrigger.cs.meta | 11 + .../Triggers/ObservableSelectTrigger.cs | 31 ++ .../Triggers/ObservableSelectTrigger.cs.meta | 11 + .../Triggers/ObservableSubmitTrigger.cs | 31 ++ .../Triggers/ObservableSubmitTrigger.cs.meta | 11 + .../ObservableTransformChangedTrigger.cs | 66 +++ .../ObservableTransformChangedTrigger.cs.meta | 11 + .../Triggers/ObservableTrigger2DTrigger.cs | 68 +++ .../ObservableTrigger2DTrigger.cs.meta | 11 + .../Runtime/Triggers/ObservableTriggerBase.cs | 65 +++ .../Triggers/ObservableTriggerBase.cs.meta | 11 + .../ObservableTriggerExtensions.Component.cs | 459 ++++++++++++++++++ ...ervableTriggerExtensions.Component.cs.meta | 11 + .../Triggers/ObservableTriggerExtensions.cs | 356 ++++++++++++++ .../ObservableTriggerExtensions.cs.meta | 11 + .../Triggers/ObservableTriggerTrigger.cs | 68 +++ .../Triggers/ObservableTriggerTrigger.cs.meta | 11 + .../ObservableUpdateSelectedTrigger.cs | 31 ++ .../ObservableUpdateSelectedTrigger.cs.meta | 11 + .../Triggers/ObservableUpdateTrigger.cs | 30 ++ .../Triggers/ObservableUpdateTrigger.cs.meta | 11 + .../Triggers/ObservableVisibleTrigger.cs | 48 ++ .../Triggers/ObservableVisibleTrigger.cs.meta | 11 + src/R3.Unity/Packages/manifest.json | 31 +- src/R3.Unity/Packages/packages-lock.json | 219 +-------- 81 files changed, 3146 insertions(+), 247 deletions(-) create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableAnimatorTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableAnimatorTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableBeginDragTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableBeginDragTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCancelTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCancelTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCanvasGroupChangedTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCanvasGroupChangedTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollision2DTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollision2DTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollisionTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollisionTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDeselectTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDeselectTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDestroyTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDestroyTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDragTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDragTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDropTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDropTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEnableTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEnableTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEndDragTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEndDragTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEventTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEventTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableFixedUpdateTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableFixedUpdateTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableInitializePotentialDragTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableInitializePotentialDragTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableJointTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableJointTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableLateUpdateTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableLateUpdateTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMouseTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMouseTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMoveTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMoveTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableParticleTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableParticleTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerClickTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerClickTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerDownTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerDownTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerEnterTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerEnterTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerExitTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerExitTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerUpTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerUpTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableRectTransformTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableRectTransformTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableScrollTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableScrollTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSelectTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSelectTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSubmitTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSubmitTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTransformChangedTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTransformChangedTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTrigger2DTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTrigger2DTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerBase.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerBase.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.Component.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.Component.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateSelectedTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateSelectedTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateTrigger.cs.meta create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableVisibleTrigger.cs create mode 100644 src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableVisibleTrigger.cs.meta diff --git a/README.md b/README.md index bb145784..fcfe07ca 100644 --- a/README.md +++ b/README.md @@ -1008,7 +1008,7 @@ You open tracker window in `Window -> Observable Tracker`. It enables watch `Obs Observable Tracker is intended for debugging use only as enabling tracking and capturing stacktraces is useful but has a heavy performance impact. Recommended usage is to enable both tracking and stacktraces to find subscription leaks and to disable them both when done. -### `SerializableReactiveProperty` +#### `SerializableReactiveProperty` `ReactiveProperty` can not use on `[SerializeField]`. However you can use `SerializableReactiveProperty` instead. @@ -1040,6 +1040,12 @@ public class NewBehaviourScript : MonoBehaviour ![image](https://github.com/Cysharp/R3/assets/46207/31be9378-846e-4635-8cc6-0b6e3954e918) +#### Triggers + +R3 can handle [MonoBehaviour messages](https://docs.unity3d.com/ScriptReference/MonoBehaviour.html) with R3.Triggers: + +These can also be handled more easily by directly subscribing to observables returned by extension methods on Component/GameObject. These methods inject ObservableTrigger automaticaly. + ### Godot Godot support is for Godot 4.x. diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/R3.Unity.asmdef b/src/R3.Unity/Assets/R3.Unity/Runtime/R3.Unity.asmdef index 9628f149..b34072a9 100644 --- a/src/R3.Unity/Assets/R3.Unity/Runtime/R3.Unity.asmdef +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/R3.Unity.asmdef @@ -18,6 +18,21 @@ "name": "com.unity.ugui", "expression": "", "define": "R3_UGUI_SUPPORT" + }, + { + "name": "com.unity.modules.physics", + "expression": "", + "define": "R3_PHYSICS_SUPPORT" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "", + "define": "R3_PHYSICS2D_SUPPORT" + }, + { + "name": "com.unity.modules.particlesystem", + "expression": "", + "define": "R3_PARTICLESYSTEM_SUPPORT" } ], "noEngineReferences": false diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers.meta new file mode 100644 index 00000000..00b6cbb7 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7df3531eb9850634ba82d4a934cc5778 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableAnimatorTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableAnimatorTrigger.cs new file mode 100644 index 00000000..48d51bd1 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableAnimatorTrigger.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableAnimatorTrigger : ObservableTriggerBase + { + Subject onAnimatorIK; + + /// Callback for setting up animation IK (inverse kinematics). + void OnAnimatorIK(int layerIndex) + { + if (onAnimatorIK != null) onAnimatorIK.OnNext(layerIndex); + } + + /// Callback for setting up animation IK (inverse kinematics). + public Observable OnAnimatorIKAsObservable() + { + return onAnimatorIK ?? (onAnimatorIK = new Subject()); + } + + Subject onAnimatorMove; + + /// Callback for processing animation movements for modifying root motion. + void OnAnimatorMove() + { + if (onAnimatorMove != null) onAnimatorMove.OnNext(Unit.Default); + } + + /// Callback for processing animation movements for modifying root motion. + public Observable OnAnimatorMoveAsObservable() + { + return onAnimatorMove ?? (onAnimatorMove = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onAnimatorIK != null) + { + onAnimatorIK.OnCompleted(); + } + if (onAnimatorMove != null) + { + onAnimatorMove.OnCompleted(); + } + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableAnimatorTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableAnimatorTrigger.cs.meta new file mode 100644 index 00000000..99c99aaa --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableAnimatorTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 81dd5f99d5230db489d57add90f34cd0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableBeginDragTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableBeginDragTrigger.cs new file mode 100644 index 00000000..3c22878a --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableBeginDragTrigger.cs @@ -0,0 +1,33 @@ +#if R3_UGUI_SUPPORT + +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableBeginDragTrigger : ObservableTriggerBase, IEventSystemHandler, IBeginDragHandler + { + Subject onBeginDrag; + + void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) + { + if (onBeginDrag != null) onBeginDrag.OnNext(eventData); + } + + public Observable OnBeginDragAsObservable() + { + return onBeginDrag ?? (onBeginDrag = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onBeginDrag != null) + { + onBeginDrag.OnCompleted(); + } + } + } +} + +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableBeginDragTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableBeginDragTrigger.cs.meta new file mode 100644 index 00000000..e0168f3b --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableBeginDragTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ebd6c5e9d53abcc4abf64976e85b2555 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCancelTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCancelTrigger.cs new file mode 100644 index 00000000..831aaee3 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCancelTrigger.cs @@ -0,0 +1,33 @@ +#if R3_UGUI_SUPPORT + +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableCancelTrigger : ObservableTriggerBase, IEventSystemHandler, ICancelHandler + { + Subject onCancel; + + void ICancelHandler.OnCancel(BaseEventData eventData) + { + if (onCancel != null) onCancel.OnNext(eventData); + } + + public Observable OnCancelAsObservable() + { + return onCancel ?? (onCancel = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onCancel != null) + { + onCancel.OnCompleted(); + } + } + } +} + +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCancelTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCancelTrigger.cs.meta new file mode 100644 index 00000000..8e4a7a8a --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCancelTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 950b53eba1853b846bb6c13e5902076f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCanvasGroupChangedTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCanvasGroupChangedTrigger.cs new file mode 100644 index 00000000..a9f75e4c --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCanvasGroupChangedTrigger.cs @@ -0,0 +1,30 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableCanvasGroupChangedTrigger : ObservableTriggerBase + { + Subject onCanvasGroupChanged; + + // Callback that is sent if the canvas group is changed + void OnCanvasGroupChanged() + { + if (onCanvasGroupChanged != null) onCanvasGroupChanged.OnNext(Unit.Default); + } + + /// Callback that is sent if the canvas group is changed. + public Observable OnCanvasGroupChangedAsObservable() + { + return onCanvasGroupChanged ?? (onCanvasGroupChanged = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onCanvasGroupChanged != null) + { + onCanvasGroupChanged.OnCompleted(); + } + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCanvasGroupChangedTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCanvasGroupChangedTrigger.cs.meta new file mode 100644 index 00000000..8aa92e77 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCanvasGroupChangedTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2cf8e5c580158c545aa0f7f78e4994ea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollision2DTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollision2DTrigger.cs new file mode 100644 index 00000000..c7ba8d68 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollision2DTrigger.cs @@ -0,0 +1,68 @@ +#if R3_PHYSICS2D_SUPPORT +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableCollision2DTrigger : ObservableTriggerBase + { + Subject onCollisionEnter2D; + + /// Sent when an incoming collider makes contact with this object's collider (2D physics only). + void OnCollisionEnter2D(Collision2D coll) + { + if (onCollisionEnter2D != null) onCollisionEnter2D.OnNext(coll); + } + + /// Sent when an incoming collider makes contact with this object's collider (2D physics only). + public Observable OnCollisionEnter2DAsObservable() + { + return onCollisionEnter2D ?? (onCollisionEnter2D = new Subject()); + } + + Subject onCollisionExit2D; + + /// Sent when a collider on another object stops touching this object's collider (2D physics only). + void OnCollisionExit2D(Collision2D coll) + { + if (onCollisionExit2D != null) onCollisionExit2D.OnNext(coll); + } + + /// Sent when a collider on another object stops touching this object's collider (2D physics only). + public Observable OnCollisionExit2DAsObservable() + { + return onCollisionExit2D ?? (onCollisionExit2D = new Subject()); + } + + Subject onCollisionStay2D; + + /// Sent each frame where a collider on another object is touching this object's collider (2D physics only). + void OnCollisionStay2D(Collision2D coll) + { + if (onCollisionStay2D != null) onCollisionStay2D.OnNext(coll); + } + + /// Sent each frame where a collider on another object is touching this object's collider (2D physics only). + public Observable OnCollisionStay2DAsObservable() + { + return onCollisionStay2D ?? (onCollisionStay2D = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onCollisionEnter2D != null) + { + onCollisionEnter2D.OnCompleted(); + } + if (onCollisionExit2D != null) + { + onCollisionExit2D.OnCompleted(); + } + if (onCollisionStay2D != null) + { + onCollisionStay2D.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollision2DTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollision2DTrigger.cs.meta new file mode 100644 index 00000000..05048b66 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollision2DTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f76e4ba761142284794dfadc21507388 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollisionTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollisionTrigger.cs new file mode 100644 index 00000000..936dfe54 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollisionTrigger.cs @@ -0,0 +1,68 @@ +#if R3_PHYSICS_SUPPORT +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableCollisionTrigger : ObservableTriggerBase + { + Subject onCollisionEnter; + + /// OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider. + void OnCollisionEnter(Collision collision) + { + if (onCollisionEnter != null) onCollisionEnter.OnNext(collision); + } + + /// OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider. + public Observable OnCollisionEnterAsObservable() + { + return onCollisionEnter ?? (onCollisionEnter = new Subject()); + } + + Subject onCollisionExit; + + /// OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider. + void OnCollisionExit(Collision collisionInfo) + { + if (onCollisionExit != null) onCollisionExit.OnNext(collisionInfo); + } + + /// OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider. + public Observable OnCollisionExitAsObservable() + { + return onCollisionExit ?? (onCollisionExit = new Subject()); + } + + Subject onCollisionStay; + + /// OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider. + void OnCollisionStay(Collision collisionInfo) + { + if (onCollisionStay != null) onCollisionStay.OnNext(collisionInfo); + } + + /// OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider. + public Observable OnCollisionStayAsObservable() + { + return onCollisionStay ?? (onCollisionStay = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onCollisionEnter != null) + { + onCollisionEnter.OnCompleted(); + } + if (onCollisionExit != null) + { + onCollisionExit.OnCompleted(); + } + if (onCollisionStay != null) + { + onCollisionStay.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollisionTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollisionTrigger.cs.meta new file mode 100644 index 00000000..31b85c2a --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableCollisionTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 54409f3471be0f04882f19ee62dc7d62 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDeselectTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDeselectTrigger.cs new file mode 100644 index 00000000..d3ee8188 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDeselectTrigger.cs @@ -0,0 +1,33 @@ +#if R3_UGUI_SUPPORT + +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableDeselectTrigger : ObservableTriggerBase, IEventSystemHandler, IDeselectHandler + { + Subject onDeselect; + + void IDeselectHandler.OnDeselect(BaseEventData eventData) + { + if (onDeselect != null) onDeselect.OnNext(eventData); + } + + public Observable OnDeselectAsObservable() + { + return onDeselect ?? (onDeselect = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onDeselect != null) + { + onDeselect.OnCompleted(); + } + } + } +} + +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDeselectTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDeselectTrigger.cs.meta new file mode 100644 index 00000000..788999a4 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDeselectTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4a8c94a0b474ee9448bba2108b330bf2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDestroyTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDestroyTrigger.cs new file mode 100644 index 00000000..63ff04ad --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDestroyTrigger.cs @@ -0,0 +1,30 @@ +using System; +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableDestroyTrigger : MonoBehaviour + { + bool calledDestroy = false; + Subject onDestroy; + + /// This function is called when the MonoBehaviour will be destroyed. + void OnDestroy() + { + if (!calledDestroy) + { + calledDestroy = true; + if (onDestroy != null) { onDestroy.OnNext(Unit.Default); onDestroy.OnCompleted(); } + } + } + + /// This function is called when the MonoBehaviour will be destroyed. + public Observable OnDestroyAsObservable() + { + if (this == null) return Observable.Return(Unit.Default); + if (calledDestroy) return Observable.Return(Unit.Default); + return onDestroy ?? (onDestroy = new Subject()); + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDestroyTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDestroyTrigger.cs.meta new file mode 100644 index 00000000..b9651553 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDestroyTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 49e9c678e8ad14d4094fc444a5148949 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDragTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDragTrigger.cs new file mode 100644 index 00000000..e3bb92c0 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDragTrigger.cs @@ -0,0 +1,33 @@ +#if R3_UGUI_SUPPORT + +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableDragTrigger : ObservableTriggerBase, IEventSystemHandler, IDragHandler + { + Subject onDrag; + + void IDragHandler.OnDrag(PointerEventData eventData) + { + if (onDrag != null) onDrag.OnNext(eventData); + } + + public Observable OnDragAsObservable() + { + return onDrag ?? (onDrag = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onDrag != null) + { + onDrag.OnCompleted(); + } + } + } +} + +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDragTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDragTrigger.cs.meta new file mode 100644 index 00000000..a064f3b0 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDragTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 69162816271ebc84e8c0bc4f61960014 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDropTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDropTrigger.cs new file mode 100644 index 00000000..128e10b8 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDropTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableDropTrigger : ObservableTriggerBase, IEventSystemHandler, IDropHandler + { + Subject onDrop; + + void IDropHandler.OnDrop(PointerEventData eventData) + { + if (onDrop != null) onDrop.OnNext(eventData); + } + + public Observable OnDropAsObservable() + { + return onDrop ?? (onDrop = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onDrop != null) + { + onDrop.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDropTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDropTrigger.cs.meta new file mode 100644 index 00000000..31f1a5c2 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableDropTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 175863aed172cdf47a35bdce36b9f67b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEnableTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEnableTrigger.cs new file mode 100644 index 00000000..8e366fa0 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEnableTrigger.cs @@ -0,0 +1,49 @@ + +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableEnableTrigger : ObservableTriggerBase + { + Subject onEnable; + + /// This function is called when the object becomes enabled and active. + void OnEnable() + { + if (onEnable != null) onEnable.OnNext(Unit.Default); + } + + /// This function is called when the object becomes enabled and active. + public Observable OnEnableAsObservable() + { + return onEnable ?? (onEnable = new Subject()); + } + + Subject onDisable; + + /// This function is called when the behaviour becomes disabled () or inactive. + void OnDisable() + { + if (onDisable != null) onDisable.OnNext(Unit.Default); + } + + /// This function is called when the behaviour becomes disabled () or inactive. + public Observable OnDisableAsObservable() + { + return onDisable ?? (onDisable = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onEnable != null) + { + onEnable.OnCompleted(); + } + if (onDisable != null) + { + onDisable.OnCompleted(); + } + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEnableTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEnableTrigger.cs.meta new file mode 100644 index 00000000..b380b9dd --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEnableTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 189db14a1f1ffb342ae2727ca6ee2967 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEndDragTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEndDragTrigger.cs new file mode 100644 index 00000000..0a5837d0 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEndDragTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableEndDragTrigger : ObservableTriggerBase, IEventSystemHandler, IEndDragHandler + { + Subject onEndDrag; + + void IEndDragHandler.OnEndDrag(PointerEventData eventData) + { + if (onEndDrag != null) onEndDrag.OnNext(eventData); + } + + public Observable OnEndDragAsObservable() + { + return onEndDrag ?? (onEndDrag = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onEndDrag != null) + { + onEndDrag.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEndDragTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEndDragTrigger.cs.meta new file mode 100644 index 00000000..0cf55256 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEndDragTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b8406da5e64ec9846a5c5f10a671fede +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEventTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEventTrigger.cs new file mode 100644 index 00000000..a8e77efb --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEventTrigger.cs @@ -0,0 +1,355 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableEventTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler, IBeginDragHandler, IInitializePotentialDragHandler, IDragHandler, IEndDragHandler, IDropHandler, IScrollHandler, IUpdateSelectedHandler, ISelectHandler, IDeselectHandler, IMoveHandler, ISubmitHandler, ICancelHandler + { + #region IDeselectHandler + + Subject onDeselect; + + void IDeselectHandler.OnDeselect(BaseEventData eventData) + { + if (onDeselect != null) onDeselect.OnNext(eventData); + } + + public Observable OnDeselectAsObservable() + { + return onDeselect ?? (onDeselect = new Subject()); + } + + #endregion + + #region IMoveHandler + + Subject onMove; + + void IMoveHandler.OnMove(AxisEventData eventData) + { + if (onMove != null) onMove.OnNext(eventData); + } + + public Observable OnMoveAsObservable() + { + return onMove ?? (onMove = new Subject()); + } + + #endregion + + #region IPointerDownHandler + + Subject onPointerDown; + + void IPointerDownHandler.OnPointerDown(PointerEventData eventData) + { + if (onPointerDown != null) onPointerDown.OnNext(eventData); + } + + public Observable OnPointerDownAsObservable() + { + return onPointerDown ?? (onPointerDown = new Subject()); + } + + #endregion + + #region IPointerEnterHandler + + Subject onPointerEnter; + + void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData) + { + if (onPointerEnter != null) onPointerEnter.OnNext(eventData); + } + + public Observable OnPointerEnterAsObservable() + { + return onPointerEnter ?? (onPointerEnter = new Subject()); + } + + #endregion + + #region IPointerExitHandler + + Subject onPointerExit; + + void IPointerExitHandler.OnPointerExit(PointerEventData eventData) + { + if (onPointerExit != null) onPointerExit.OnNext(eventData); + } + + public Observable OnPointerExitAsObservable() + { + return onPointerExit ?? (onPointerExit = new Subject()); + } + + #endregion + + #region IPointerUpHandler + + Subject onPointerUp; + + void IPointerUpHandler.OnPointerUp(PointerEventData eventData) + { + if (onPointerUp != null) onPointerUp.OnNext(eventData); + } + + public Observable OnPointerUpAsObservable() + { + return onPointerUp ?? (onPointerUp = new Subject()); + } + + #endregion + + #region ISelectHandler + + Subject onSelect; + + void ISelectHandler.OnSelect(BaseEventData eventData) + { + if (onSelect != null) onSelect.OnNext(eventData); + } + + public Observable OnSelectAsObservable() + { + return onSelect ?? (onSelect = new Subject()); + } + + #endregion + + #region IPointerClickHandler + + Subject onPointerClick; + + void IPointerClickHandler.OnPointerClick(PointerEventData eventData) + { + if (onPointerClick != null) onPointerClick.OnNext(eventData); + } + + public Observable OnPointerClickAsObservable() + { + return onPointerClick ?? (onPointerClick = new Subject()); + } + + #endregion + + #region ISubmitHandler + + Subject onSubmit; + + void ISubmitHandler.OnSubmit(BaseEventData eventData) + { + if (onSubmit != null) onSubmit.OnNext(eventData); + } + + public Observable OnSubmitAsObservable() + { + return onSubmit ?? (onSubmit = new Subject()); + } + + #endregion + + #region IDragHandler + + Subject onDrag; + + void IDragHandler.OnDrag(PointerEventData eventData) + { + if (onDrag != null) onDrag.OnNext(eventData); + } + + public Observable OnDragAsObservable() + { + return onDrag ?? (onDrag = new Subject()); + } + + #endregion + + #region IBeginDragHandler + + Subject onBeginDrag; + + void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) + { + if (onBeginDrag != null) onBeginDrag.OnNext(eventData); + } + + public Observable OnBeginDragAsObservable() + { + return onBeginDrag ?? (onBeginDrag = new Subject()); + } + + #endregion + + #region IEndDragHandler + + Subject onEndDrag; + + void IEndDragHandler.OnEndDrag(PointerEventData eventData) + { + if (onEndDrag != null) onEndDrag.OnNext(eventData); + } + + public Observable OnEndDragAsObservable() + { + return onEndDrag ?? (onEndDrag = new Subject()); + } + + #endregion + + #region IDropHandler + + Subject onDrop; + + void IDropHandler.OnDrop(PointerEventData eventData) + { + if (onDrop != null) onDrop.OnNext(eventData); + } + + public Observable OnDropAsObservable() + { + return onDrop ?? (onDrop = new Subject()); + } + + #endregion + + #region IUpdateSelectedHandler + + Subject onUpdateSelected; + + void IUpdateSelectedHandler.OnUpdateSelected(BaseEventData eventData) + { + if (onUpdateSelected != null) onUpdateSelected.OnNext(eventData); + } + + public Observable OnUpdateSelectedAsObservable() + { + return onUpdateSelected ?? (onUpdateSelected = new Subject()); + } + + #endregion + + #region IInitializePotentialDragHandler + + Subject onInitializePotentialDrag; + + void IInitializePotentialDragHandler.OnInitializePotentialDrag(PointerEventData eventData) + { + if (onInitializePotentialDrag != null) onInitializePotentialDrag.OnNext(eventData); + } + + public Observable OnInitializePotentialDragAsObservable() + { + return onInitializePotentialDrag ?? (onInitializePotentialDrag = new Subject()); + } + + #endregion + + #region ICancelHandler + + Subject onCancel; + + void ICancelHandler.OnCancel(BaseEventData eventData) + { + if (onCancel != null) onCancel.OnNext(eventData); + } + + public Observable OnCancelAsObservable() + { + return onCancel ?? (onCancel = new Subject()); + } + + #endregion + + #region IScrollHandler + + Subject onScroll; + + void IScrollHandler.OnScroll(PointerEventData eventData) + { + if (onScroll != null) onScroll.OnNext(eventData); + } + + public Observable OnScrollAsObservable() + { + return onScroll ?? (onScroll = new Subject()); + } + + #endregion + + protected override void RaiseOnCompletedOnDestroy() + { + if (onDeselect != null) + { + onDeselect.OnCompleted(); + } + if (onMove != null) + { + onMove.OnCompleted(); + } + if (onPointerDown != null) + { + onPointerDown.OnCompleted(); + } + if (onPointerEnter != null) + { + onPointerEnter.OnCompleted(); + } + if (onPointerExit != null) + { + onPointerExit.OnCompleted(); + } + if (onPointerUp != null) + { + onPointerUp.OnCompleted(); + } + if (onSelect != null) + { + onSelect.OnCompleted(); + } + if (onPointerClick != null) + { + onPointerClick.OnCompleted(); + } + if (onSubmit != null) + { + onSubmit.OnCompleted(); + } + if (onDrag != null) + { + onDrag.OnCompleted(); + } + if (onBeginDrag != null) + { + onBeginDrag.OnCompleted(); + } + if (onEndDrag != null) + { + onEndDrag.OnCompleted(); + } + if (onDrop != null) + { + onDrop.OnCompleted(); + } + if (onUpdateSelected != null) + { + onUpdateSelected.OnCompleted(); + } + if (onInitializePotentialDrag != null) + { + onInitializePotentialDrag.OnCompleted(); + } + if (onCancel != null) + { + onCancel.OnCompleted(); + } + if (onScroll != null) + { + onScroll.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEventTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEventTrigger.cs.meta new file mode 100644 index 00000000..c03769aa --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fd253e17d14ec9346b4e8ec0b1ecf277 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableFixedUpdateTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableFixedUpdateTrigger.cs new file mode 100644 index 00000000..2ad9266c --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableFixedUpdateTrigger.cs @@ -0,0 +1,31 @@ + +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableFixedUpdateTrigger : ObservableTriggerBase + { + Subject fixedUpdate; + + /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. + void FixedUpdate() + { + if (fixedUpdate != null) fixedUpdate.OnNext(Unit.Default); + } + + /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. + public Observable FixedUpdateAsObservable() + { + return fixedUpdate ?? (fixedUpdate = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (fixedUpdate != null) + { + fixedUpdate.OnCompleted(); + } + } + } +} \ No newline at end of file diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableFixedUpdateTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableFixedUpdateTrigger.cs.meta new file mode 100644 index 00000000..19b24303 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableFixedUpdateTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f715a0b3418541449c2f3656418724d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableInitializePotentialDragTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableInitializePotentialDragTrigger.cs new file mode 100644 index 00000000..e1937835 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableInitializePotentialDragTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableInitializePotentialDragTrigger : ObservableTriggerBase, IEventSystemHandler, IInitializePotentialDragHandler + { + Subject onInitializePotentialDrag; + + void IInitializePotentialDragHandler.OnInitializePotentialDrag(PointerEventData eventData) + { + if (onInitializePotentialDrag != null) onInitializePotentialDrag.OnNext(eventData); + } + + public Observable OnInitializePotentialDragAsObservable() + { + return onInitializePotentialDrag ?? (onInitializePotentialDrag = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onInitializePotentialDrag != null) + { + onInitializePotentialDrag.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableInitializePotentialDragTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableInitializePotentialDragTrigger.cs.meta new file mode 100644 index 00000000..76cee2e4 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableInitializePotentialDragTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d647a2133ece484ea93bdfa2c20e5f0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableJointTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableJointTrigger.cs new file mode 100644 index 00000000..b0a2bf57 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableJointTrigger.cs @@ -0,0 +1,49 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableJointTrigger : ObservableTriggerBase + { + Subject onJointBreak; + + void OnJointBreak(float breakForce) + { + if (onJointBreak != null) onJointBreak.OnNext(breakForce); + } + + public Observable OnJointBreakAsObservable() + { + return onJointBreak ?? (onJointBreak = new Subject()); + } + +#if R3_PHYSICS2D_SUPPORT + + Subject onJointBreak2D; + + void OnJointBreak2D(Joint2D brokenJoint) + { + if (onJointBreak2D != null) onJointBreak2D.OnNext(brokenJoint); + } + + public Observable OnJointBreak2DAsObservable() + { + return onJointBreak2D ?? (onJointBreak2D = new Subject()); + } +#endif + + protected override void RaiseOnCompletedOnDestroy() + { + if (onJointBreak != null) + { + onJointBreak.OnCompleted(); + } +#if R3_PHYSICS2D_SUPPORT + if (onJointBreak2D != null) + { + onJointBreak2D.OnCompleted(); + } +#endif + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableJointTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableJointTrigger.cs.meta new file mode 100644 index 00000000..74926971 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableJointTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a5c8ddee7e79db44e9c2b7f08ffd68a1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableLateUpdateTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableLateUpdateTrigger.cs new file mode 100644 index 00000000..b3e30c34 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableLateUpdateTrigger.cs @@ -0,0 +1,30 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableLateUpdateTrigger : ObservableTriggerBase + { + Subject lateUpdate; + + /// LateUpdate is called every frame, if the Behaviour is enabled. + void LateUpdate() + { + if (lateUpdate != null) lateUpdate.OnNext(Unit.Default); + } + + /// LateUpdate is called every frame, if the Behaviour is enabled. + public Observable LateUpdateAsObservable() + { + return lateUpdate ?? (lateUpdate = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (lateUpdate != null) + { + lateUpdate.OnCompleted(); + } + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableLateUpdateTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableLateUpdateTrigger.cs.meta new file mode 100644 index 00000000..b4e38e60 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableLateUpdateTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 543cbdc05bce2754a983163c8cb6bce2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMouseTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMouseTrigger.cs new file mode 100644 index 00000000..de61e9dc --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMouseTrigger.cs @@ -0,0 +1,143 @@ +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO) + + +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableMouseTrigger : ObservableTriggerBase + { + Subject onMouseDown; + + /// OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider. + void OnMouseDown() + { + if (onMouseDown != null) onMouseDown.OnNext(Unit.Default); + } + + /// OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider. + public Observable OnMouseDownAsObservable() + { + return onMouseDown ?? (onMouseDown = new Subject()); + } + + Subject onMouseDrag; + + /// OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse. + void OnMouseDrag() + { + if (onMouseDrag != null) onMouseDrag.OnNext(Unit.Default); + } + + /// OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse. + public Observable OnMouseDragAsObservable() + { + return onMouseDrag ?? (onMouseDrag = new Subject()); + } + + Subject onMouseEnter; + + /// OnMouseEnter is called when the mouse entered the GUIElement or Collider. + void OnMouseEnter() + { + if (onMouseEnter != null) onMouseEnter.OnNext(Unit.Default); + } + + /// OnMouseEnter is called when the mouse entered the GUIElement or Collider. + public Observable OnMouseEnterAsObservable() + { + return onMouseEnter ?? (onMouseEnter = new Subject()); + } + + Subject onMouseExit; + + /// OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider. + void OnMouseExit() + { + if (onMouseExit != null) onMouseExit.OnNext(Unit.Default); + } + + /// OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider. + public Observable OnMouseExitAsObservable() + { + return onMouseExit ?? (onMouseExit = new Subject()); + } + + Subject onMouseOver; + + /// OnMouseOver is called every frame while the mouse is over the GUIElement or Collider. + void OnMouseOver() + { + if (onMouseOver != null) onMouseOver.OnNext(Unit.Default); + } + + /// OnMouseOver is called every frame while the mouse is over the GUIElement or Collider. + public Observable OnMouseOverAsObservable() + { + return onMouseOver ?? (onMouseOver = new Subject()); + } + + Subject onMouseUp; + + /// OnMouseUp is called when the user has released the mouse button. + void OnMouseUp() + { + if (onMouseUp != null) onMouseUp.OnNext(Unit.Default); + } + + /// OnMouseUp is called when the user has released the mouse button. + public Observable OnMouseUpAsObservable() + { + return onMouseUp ?? (onMouseUp = new Subject()); + } + + Subject onMouseUpAsButton; + + /// OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed. + void OnMouseUpAsButton() + { + if (onMouseUpAsButton != null) onMouseUpAsButton.OnNext(Unit.Default); + } + + /// OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed. + public Observable OnMouseUpAsButtonAsObservable() + { + return onMouseUpAsButton ?? (onMouseUpAsButton = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onMouseDown != null) + { + onMouseDown.OnCompleted(); + } + if (onMouseDrag != null) + { + onMouseDrag.OnCompleted(); + } + if (onMouseEnter != null) + { + onMouseEnter.OnCompleted(); + } + if (onMouseExit != null) + { + onMouseExit.OnCompleted(); + } + if (onMouseOver != null) + { + onMouseOver.OnCompleted(); + } + if (onMouseUp != null) + { + onMouseUp.OnCompleted(); + } + if (onMouseUpAsButton != null) + { + onMouseUpAsButton.OnCompleted(); + } + } + } +} + +#endif \ No newline at end of file diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMouseTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMouseTrigger.cs.meta new file mode 100644 index 00000000..4c2cac51 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMouseTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 23ce65ebeb2510a4c8915bfe9a04fe6a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMoveTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMoveTrigger.cs new file mode 100644 index 00000000..d9c65831 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMoveTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableMoveTrigger : ObservableTriggerBase, IEventSystemHandler, IMoveHandler + { + Subject onMove; + + void IMoveHandler.OnMove(AxisEventData eventData) + { + if (onMove != null) onMove.OnNext(eventData); + } + + public Observable OnMoveAsObservable() + { + return onMove ?? (onMove = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onMove != null) + { + onMove.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMoveTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMoveTrigger.cs.meta new file mode 100644 index 00000000..1ca32a13 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableMoveTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 193e7dc691485664eaf8e7ba5db62e85 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableParticleTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableParticleTrigger.cs new file mode 100644 index 00000000..74758e4e --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableParticleTrigger.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableParticleTrigger : ObservableTriggerBase + { + Subject onParticleCollision; + Subject onParticleTrigger; + + /// OnParticleCollision is called when a particle hits a collider. + void OnParticleCollision(GameObject other) + { + if (onParticleCollision != null) onParticleCollision.OnNext(other); + } + + /// OnParticleCollision is called when a particle hits a collider. + public Observable OnParticleCollisionAsObservable() + { + return onParticleCollision ?? (onParticleCollision = new Subject()); + } + + /// OnParticleTrigger is called when any particles in a particle system meet the conditions in the trigger module. + void OnParticleTrigger() + { + if (onParticleTrigger != null) onParticleTrigger.OnNext(Unit.Default); + } + + /// OnParticleTrigger is called when any particles in a particle system meet the conditions in the trigger module. + public Observable OnParticleTriggerAsObservable() + { + return onParticleTrigger ?? (onParticleTrigger = new Subject()); + } + + + protected override void RaiseOnCompletedOnDestroy() + { + if (onParticleCollision != null) + { + onParticleCollision.OnCompleted(); + } + if (onParticleTrigger != null) + { + onParticleTrigger.OnCompleted(); + } + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableParticleTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableParticleTrigger.cs.meta new file mode 100644 index 00000000..55cd98b2 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableParticleTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ec0da8d9461ed534eb4eb0f6682eeb95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerClickTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerClickTrigger.cs new file mode 100644 index 00000000..07df57f2 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerClickTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservablePointerClickTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerClickHandler + { + Subject onPointerClick; + + void IPointerClickHandler.OnPointerClick(PointerEventData eventData) + { + if (onPointerClick != null) onPointerClick.OnNext(eventData); + } + + public Observable OnPointerClickAsObservable() + { + return onPointerClick ?? (onPointerClick = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onPointerClick != null) + { + onPointerClick.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerClickTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerClickTrigger.cs.meta new file mode 100644 index 00000000..80a451d4 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerClickTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4f029a96607ef284f9106063137864a4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerDownTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerDownTrigger.cs new file mode 100644 index 00000000..5291e60d --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerDownTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservablePointerDownTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerDownHandler + { + Subject onPointerDown; + + void IPointerDownHandler.OnPointerDown(PointerEventData eventData) + { + if (onPointerDown != null) onPointerDown.OnNext(eventData); + } + + public Observable OnPointerDownAsObservable() + { + return onPointerDown ?? (onPointerDown = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onPointerDown != null) + { + onPointerDown.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerDownTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerDownTrigger.cs.meta new file mode 100644 index 00000000..061b7128 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerDownTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f14ff3c2d53ce3642888a1bd7458019e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerEnterTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerEnterTrigger.cs new file mode 100644 index 00000000..25250fe1 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerEnterTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservablePointerEnterTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerEnterHandler + { + Subject onPointerEnter; + + void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData) + { + if (onPointerEnter != null) onPointerEnter.OnNext(eventData); + } + + public Observable OnPointerEnterAsObservable() + { + return onPointerEnter ?? (onPointerEnter = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onPointerEnter != null) + { + onPointerEnter.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerEnterTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerEnterTrigger.cs.meta new file mode 100644 index 00000000..239e9d7b --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerEnterTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a8db2cc52408f6d479081d183d573307 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerExitTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerExitTrigger.cs new file mode 100644 index 00000000..d7b4c9e4 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerExitTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservablePointerExitTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerExitHandler + { + Subject onPointerExit; + + void IPointerExitHandler.OnPointerExit(PointerEventData eventData) + { + if (onPointerExit != null) onPointerExit.OnNext(eventData); + } + + public Observable OnPointerExitAsObservable() + { + return onPointerExit ?? (onPointerExit = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onPointerExit != null) + { + onPointerExit.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerExitTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerExitTrigger.cs.meta new file mode 100644 index 00000000..b6c94825 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerExitTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 116eb1539f4db5d418ddbe24579b9900 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerUpTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerUpTrigger.cs new file mode 100644 index 00000000..7226f1f1 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerUpTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservablePointerUpTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerUpHandler + { + Subject onPointerUp; + + void IPointerUpHandler.OnPointerUp(PointerEventData eventData) + { + if (onPointerUp != null) onPointerUp.OnNext(eventData); + } + + public Observable OnPointerUpAsObservable() + { + return onPointerUp ?? (onPointerUp = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onPointerUp != null) + { + onPointerUp.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerUpTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerUpTrigger.cs.meta new file mode 100644 index 00000000..32c37a38 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservablePointerUpTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 61f4d59301482a0478779f375c014109 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableRectTransformTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableRectTransformTrigger.cs new file mode 100644 index 00000000..71aab3ca --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableRectTransformTrigger.cs @@ -0,0 +1,49 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableRectTransformTrigger : ObservableTriggerBase + { + Subject onRectTransformDimensionsChange; + + // Callback that is sent if an associated RectTransform has it's dimensions changed + void OnRectTransformDimensionsChange() + { + if (onRectTransformDimensionsChange != null) onRectTransformDimensionsChange.OnNext(Unit.Default); + } + + /// Callback that is sent if an associated RectTransform has it's dimensions changed. + public Observable OnRectTransformDimensionsChangeAsObservable() + { + return onRectTransformDimensionsChange ?? (onRectTransformDimensionsChange = new Subject()); + } + + Subject onRectTransformRemoved; + + // Callback that is sent if an associated RectTransform is removed + void OnRectTransformRemoved() + { + if (onRectTransformRemoved != null) onRectTransformRemoved.OnNext(Unit.Default); + } + + /// Callback that is sent if an associated RectTransform is removed. + public Observable OnRectTransformRemovedAsObservable() + { + return onRectTransformRemoved ?? (onRectTransformRemoved = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onRectTransformDimensionsChange != null) + { + onRectTransformDimensionsChange.OnCompleted(); + } + if (onRectTransformRemoved != null) + { + onRectTransformRemoved.OnCompleted(); + } + } + + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableRectTransformTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableRectTransformTrigger.cs.meta new file mode 100644 index 00000000..20d8286b --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableRectTransformTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3a5cd2cfdc3721d488903ad5923aec65 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableScrollTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableScrollTrigger.cs new file mode 100644 index 00000000..ef0a99a4 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableScrollTrigger.cs @@ -0,0 +1,32 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableScrollTrigger : ObservableTriggerBase, IEventSystemHandler, IScrollHandler + { + Subject onScroll; + + void IScrollHandler.OnScroll(PointerEventData eventData) + { + if (onScroll != null) onScroll.OnNext(eventData); + } + + public Observable OnScrollAsObservable() + { + return onScroll ?? (onScroll = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onScroll != null) + { + onScroll.OnCompleted(); + } + } + } +} + +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableScrollTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableScrollTrigger.cs.meta new file mode 100644 index 00000000..aef88bdb --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableScrollTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 58733523a0a576648890120abbb88fb6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSelectTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSelectTrigger.cs new file mode 100644 index 00000000..7c2e9de1 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSelectTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableSelectTrigger : ObservableTriggerBase, IEventSystemHandler, ISelectHandler + { + Subject onSelect; + + void ISelectHandler.OnSelect(BaseEventData eventData) + { + if (onSelect != null) onSelect.OnNext(eventData); + } + + public Observable OnSelectAsObservable() + { + return onSelect ?? (onSelect = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onSelect != null) + { + onSelect.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSelectTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSelectTrigger.cs.meta new file mode 100644 index 00000000..9016d2c7 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSelectTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c02572138f7328e43b9a3acbf76ba1fa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSubmitTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSubmitTrigger.cs new file mode 100644 index 00000000..21feed61 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSubmitTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableSubmitTrigger : ObservableTriggerBase, IEventSystemHandler, ISubmitHandler + { + Subject onSubmit; + + void ISubmitHandler.OnSubmit(BaseEventData eventData) + { + if (onSubmit != null) onSubmit.OnNext(eventData); + } + + public Observable OnSubmitAsObservable() + { + return onSubmit ?? (onSubmit = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onSubmit != null) + { + onSubmit.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSubmitTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSubmitTrigger.cs.meta new file mode 100644 index 00000000..f489adda --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableSubmitTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cc4ba804a9a2da46923df54e791963e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTransformChangedTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTransformChangedTrigger.cs new file mode 100644 index 00000000..6bab4c66 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTransformChangedTrigger.cs @@ -0,0 +1,66 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableTransformChangedTrigger : ObservableTriggerBase + { + Subject onBeforeTransformParentChanged; + + // Callback sent to the graphic before a Transform parent change occurs + void OnBeforeTransformParentChanged() + { + if (onBeforeTransformParentChanged != null) onBeforeTransformParentChanged.OnNext(Unit.Default); + } + + /// Callback sent to the graphic before a Transform parent change occurs. + public Observable OnBeforeTransformParentChangedAsObservable() + { + return onBeforeTransformParentChanged ?? (onBeforeTransformParentChanged = new Subject()); + } + + Subject onTransformParentChanged; + + // This function is called when the parent property of the transform of the GameObject has changed + void OnTransformParentChanged() + { + if (onTransformParentChanged != null) onTransformParentChanged.OnNext(Unit.Default); + } + + /// This function is called when the parent property of the transform of the GameObject has changed. + public Observable OnTransformParentChangedAsObservable() + { + return onTransformParentChanged ?? (onTransformParentChanged = new Subject()); + } + + Subject onTransformChildrenChanged; + + // This function is called when the list of children of the transform of the GameObject has changed + void OnTransformChildrenChanged() + { + if (onTransformChildrenChanged != null) onTransformChildrenChanged.OnNext(Unit.Default); + } + + /// This function is called when the list of children of the transform of the GameObject has changed. + public Observable OnTransformChildrenChangedAsObservable() + { + return onTransformChildrenChanged ?? (onTransformChildrenChanged = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onBeforeTransformParentChanged != null) + { + onBeforeTransformParentChanged.OnCompleted(); + } + if (onTransformParentChanged != null) + { + onTransformParentChanged.OnCompleted(); + } + if (onTransformChildrenChanged != null) + { + onTransformChildrenChanged.OnCompleted(); + } + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTransformChangedTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTransformChangedTrigger.cs.meta new file mode 100644 index 00000000..d91b25aa --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTransformChangedTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2fae811c386e49a498fd5adcec0782ff +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTrigger2DTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTrigger2DTrigger.cs new file mode 100644 index 00000000..ec6a3a63 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTrigger2DTrigger.cs @@ -0,0 +1,68 @@ +#if R3_PHYSICS2D_SUPPORT +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableTrigger2DTrigger : ObservableTriggerBase + { + Subject onTriggerEnter2D; + + /// Sent when another object enters a trigger collider attached to this object (2D physics only). + void OnTriggerEnter2D(Collider2D other) + { + if (onTriggerEnter2D != null) onTriggerEnter2D.OnNext(other); + } + + /// Sent when another object enters a trigger collider attached to this object (2D physics only). + public Observable OnTriggerEnter2DAsObservable() + { + return onTriggerEnter2D ?? (onTriggerEnter2D = new Subject()); + } + + Subject onTriggerExit2D; + + /// Sent when another object leaves a trigger collider attached to this object (2D physics only). + void OnTriggerExit2D(Collider2D other) + { + if (onTriggerExit2D != null) onTriggerExit2D.OnNext(other); + } + + /// Sent when another object leaves a trigger collider attached to this object (2D physics only). + public Observable OnTriggerExit2DAsObservable() + { + return onTriggerExit2D ?? (onTriggerExit2D = new Subject()); + } + + Subject onTriggerStay2D; + + /// Sent each frame where another object is within a trigger collider attached to this object (2D physics only). + void OnTriggerStay2D(Collider2D other) + { + if (onTriggerStay2D != null) onTriggerStay2D.OnNext(other); + } + + /// Sent each frame where another object is within a trigger collider attached to this object (2D physics only). + public Observable OnTriggerStay2DAsObservable() + { + return onTriggerStay2D ?? (onTriggerStay2D = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onTriggerEnter2D != null) + { + onTriggerEnter2D.OnCompleted(); + } + if (onTriggerExit2D != null) + { + onTriggerExit2D.OnCompleted(); + } + if (onTriggerStay2D != null) + { + onTriggerStay2D.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTrigger2DTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTrigger2DTrigger.cs.meta new file mode 100644 index 00000000..92315a71 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTrigger2DTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 07c75deb315dfb144954da7e85ab9ac8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerBase.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerBase.cs new file mode 100644 index 00000000..a149a752 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerBase.cs @@ -0,0 +1,65 @@ + +using UnityEngine; + +namespace R3.Triggers +{ + public abstract class ObservableTriggerBase : MonoBehaviour + { + //bool calledAwake = false; + //Subject awake; + + ///// Awake is called when the script instance is being loaded. + //void Awake() + //{ + // calledAwake = true; + // if (awake != null) { awake.OnNext(Unit.Default); awake.OnCompleted(); } + //} + + ///// Awake is called when the script instance is being loaded. + //public Observable AwakeAsObservable() + //{ + // if (calledAwake) return Observable.Return(Unit.Default); + // return awake ?? (awake = new Subject()); + //} + + //bool calledStart = false; + //Subject start; + + ///// Start is called on the frame when a script is enabled just before any of the Update methods is called the first time. + //void Start() + //{ + // calledStart = true; + // if (start != null) { start.OnNext(Unit.Default); start.OnCompleted(); } + //} + + ///// Start is called on the frame when a script is enabled just before any of the Update methods is called the first time. + //public Observable StartAsObservable() + //{ + // if (calledStart) return Observable.Return(Unit.Default); + // return start ?? (start = new Subject()); + //} + + + bool calledDestroy = false; + + /// This function is called when the MonoBehaviour will be destroyed. + void OnDestroy() + { + if (!calledDestroy) + { + calledDestroy = true; + RaiseOnCompletedOnDestroy(); + } + } + + ///// This function is called when the MonoBehaviour will be destroyed. + //public Observable OnDestroyAsObservable() + //{ + // if (this == null) return Observable.Return(Unit.Default); + // if (calledDestroy) return Observable.Return(Unit.Default); + // return onDestroy ?? (onDestroy = new Subject()); + //} + + protected abstract void RaiseOnCompletedOnDestroy(); + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerBase.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerBase.cs.meta new file mode 100644 index 00000000..2d2569ee --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a20b70ad048eedc438cdc22db5940016 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.Component.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.Component.cs new file mode 100644 index 00000000..b65cd9d9 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.Component.cs @@ -0,0 +1,459 @@ + +using UnityEngine; + +#if R3_UGUI_SUPPORT +using UnityEngine.EventSystems; +#endif + +namespace R3.Triggers +{ + // for Component + public static partial class ObservableTriggerExtensions + { + #region ObservableAnimatorTrigger + + /// Callback for setting up animation IK (inverse kinematics). + public static Observable OnAnimatorIKAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnAnimatorIKAsObservable(); + } + + /// Callback for processing animation movements for modifying root motion. + public static Observable OnAnimatorMoveAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnAnimatorMoveAsObservable(); + } + + #endregion + +#region ObservableCollision2DTrigger +#if R3_PHYSICS2D_SUPPORT + /// Sent when an incoming collider makes contact with this object's collider (2D physics only). + public static Observable OnCollisionEnter2DAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnCollisionEnter2DAsObservable(); + } + + + /// Sent when a collider on another object stops touching this object's collider (2D physics only). + public static Observable OnCollisionExit2DAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnCollisionExit2DAsObservable(); + } + + /// Sent each frame where a collider on another object is touching this object's collider (2D physics only). + public static Observable OnCollisionStay2DAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnCollisionStay2DAsObservable(); + } +#endif +#endregion + +#region ObservableCollisionTrigger +#if R3_PHYSICS2D_SUPPORT + + /// OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider. + public static Observable OnCollisionEnterAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnCollisionEnterAsObservable(); + } + + + /// OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider. + public static Observable OnCollisionExitAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnCollisionExitAsObservable(); + } + + /// OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider. + public static Observable OnCollisionStayAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnCollisionStayAsObservable(); + } +#endif +#endregion + + #region ObservableDestroyTrigger + + /// This function is called when the MonoBehaviour will be destroyed. + public static Observable OnDestroyAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Return(Unit.Default); // send destroy message + return GetOrAddComponent<___ObservableDestroyTrigger>(component.gameObject).OnDestroyAsObservable(); + } + + #endregion + + + #region ObservableEnableTrigger + + /// This function is called when the object becomes enabled and active. + public static Observable OnEnableAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnEnableAsObservable(); + } + + /// This function is called when the behaviour becomes disabled () or inactive. + public static Observable OnDisableAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnDisableAsObservable(); + } + + #endregion + + #region ObservableFixedUpdateTrigger + + /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. + public static Observable FixedUpdateAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).FixedUpdateAsObservable(); + } + + #endregion + + #region ObservableLateUpdateTrigger + + /// LateUpdate is called every frame, if the Behaviour is enabled. + public static Observable LateUpdateAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).LateUpdateAsObservable(); + } + + #endregion + +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO) + + #region ObservableMouseTrigger + + /// OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider. + public static Observable OnMouseDownAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnMouseDownAsObservable(); + } + + /// OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse. + public static Observable OnMouseDragAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnMouseDragAsObservable(); + } + + /// OnMouseEnter is called when the mouse entered the GUIElement or Collider. + public static Observable OnMouseEnterAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnMouseEnterAsObservable(); + } + + /// OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider. + public static Observable OnMouseExitAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnMouseExitAsObservable(); + } + + /// OnMouseOver is called every frame while the mouse is over the GUIElement or Collider. + public static Observable OnMouseOverAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnMouseOverAsObservable(); + } + + /// OnMouseUp is called when the user has released the mouse button. + public static Observable OnMouseUpAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnMouseUpAsObservable(); + } + + /// OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed. + public static Observable OnMouseUpAsButtonAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnMouseUpAsButtonAsObservable(); + } + + #endregion + +#endif + +#region ObservableTrigger2DTrigger +#if R3_PHYSICS2D_SUPPORT + /// Sent when another object enters a trigger collider attached to this object (2D physics only). + public static Observable OnTriggerEnter2DAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnTriggerEnter2DAsObservable(); + } + + + /// Sent when another object leaves a trigger collider attached to this object (2D physics only). + public static Observable OnTriggerExit2DAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnTriggerExit2DAsObservable(); + } + + /// Sent each frame where another object is within a trigger collider attached to this object (2D physics only). + public static Observable OnTriggerStay2DAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnTriggerStay2DAsObservable(); + } +#endif +#endregion + +#region ObservableTriggerTrigger +#if R3_PHYSICS_SUPPORT + + /// OnTriggerEnter is called when the Collider other enters the trigger. + public static Observable OnTriggerEnterAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnTriggerEnterAsObservable(); + } + + + /// OnTriggerExit is called when the Collider other has stopped touching the trigger. + public static Observable OnTriggerExitAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnTriggerExitAsObservable(); + } + + /// OnTriggerStay is called once per frame for every Collider other that is touching the trigger. + public static Observable OnTriggerStayAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnTriggerStayAsObservable(); + } +#endif +#endregion + + #region ObservableUpdateTrigger + + /// Update is called every frame, if the MonoBehaviour is enabled. + public static Observable UpdateAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).UpdateAsObservable(); + } + + #endregion + + #region ObservableVisibleTrigger + + /// OnBecameInvisible is called when the renderer is no longer visible by any camera. + public static Observable OnBecameInvisibleAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnBecameInvisibleAsObservable(); + } + + /// OnBecameVisible is called when the renderer became visible by any camera. + public static Observable OnBecameVisibleAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnBecameVisibleAsObservable(); + } + + #endregion + + #region ObservableTransformChangedTrigger + + /// Callback sent to the graphic before a Transform parent change occurs. + public static Observable OnBeforeTransformParentChangedAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnBeforeTransformParentChangedAsObservable(); + } + + /// This function is called when the parent property of the transform of the GameObject has changed. + public static Observable OnTransformParentChangedAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnTransformParentChangedAsObservable(); + } + + /// This function is called when the list of children of the transform of the GameObject has changed. + public static Observable OnTransformChildrenChangedAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnTransformChildrenChangedAsObservable(); + } + + #endregion + + #region ObservableCanvasGroupChangedTrigger + + /// Callback that is sent if the canvas group is changed. + public static Observable OnCanvasGroupChangedAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnCanvasGroupChangedAsObservable(); + } + + #endregion + + #region ObservableRectTransformTrigger + + /// Callback that is sent if an associated RectTransform has it's dimensions changed. + public static Observable OnRectTransformDimensionsChangeAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnRectTransformDimensionsChangeAsObservable(); + } + + /// Callback that is sent if an associated RectTransform is removed. + public static Observable OnRectTransformRemovedAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnRectTransformRemovedAsObservable(); + } + + #endregion + + // uGUI + + #region ObservableEventTrigger classes + + public static Observable OnDeselectAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnDeselectAsObservable(); + } + + public static Observable OnMoveAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnMoveAsObservable(); + } + + public static Observable OnPointerDownAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnPointerDownAsObservable(); + } + + public static Observable OnPointerEnterAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnPointerEnterAsObservable(); + } + + public static Observable OnPointerExitAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnPointerExitAsObservable(); + } + + public static Observable OnPointerUpAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnPointerUpAsObservable(); + } + + public static Observable OnSelectAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnSelectAsObservable(); + } + + public static Observable OnPointerClickAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnPointerClickAsObservable(); + } + + public static Observable OnSubmitAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnSubmitAsObservable(); + } + + public static Observable OnDragAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnDragAsObservable(); + } + + public static Observable OnBeginDragAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnBeginDragAsObservable(); + } + + public static Observable OnEndDragAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnEndDragAsObservable(); + } + + public static Observable OnDropAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnDropAsObservable(); + } + + public static Observable OnUpdateSelectedAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnUpdateSelectedAsObservable(); + } + + public static Observable OnInitializePotentialDragAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnInitializePotentialDragAsObservable(); + } + + public static Observable OnCancelAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnCancelAsObservable(); + } + + public static Observable OnScrollAsObservable(this UIBehaviour component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnScrollAsObservable(); + } + + #endregion + + #region ObservableParticleTrigger + + /// OnParticleCollision is called when a particle hits a collider. + public static Observable OnParticleCollisionAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnParticleCollisionAsObservable(); + } + +#if UNITY_5_4_OR_NEWER + + /// OnParticleTrigger is called when any particles in a particle system meet the conditions in the trigger module. + public static Observable OnParticleTriggerAsObservable(this Component component) + { + if (component == null || component.gameObject == null) return Observable.Empty(); + return GetOrAddComponent(component.gameObject).OnParticleTriggerAsObservable(); + } + +#endif + + #endregion + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.Component.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.Component.cs.meta new file mode 100644 index 00000000..942396ae --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.Component.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e550227cbaf90642ab579da06e24e44 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.cs new file mode 100644 index 00000000..ba464bf4 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.cs @@ -0,0 +1,356 @@ + +using UnityEngine; + +namespace R3.Triggers +{ + // for GameObject + public static partial class ObservableTriggerExtensions + { + #region ObservableAnimatorTrigger + + /// Callback for setting up animation IK (inverse kinematics). + public static Observable OnAnimatorIKAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnAnimatorIKAsObservable(); + } + + /// Callback for processing animation movements for modifying root motion. + public static Observable OnAnimatorMoveAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnAnimatorMoveAsObservable(); + } + + #endregion + + #region ObservableCollision2DTrigger +#if R3_PHYSICS2D_SUPPORT + + /// Sent when an incoming collider makes contact with this object's collider (2D physics only). + public static Observable OnCollisionEnter2DAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnCollisionEnter2DAsObservable(); + } + + + /// Sent when a collider on another object stops touching this object's collider (2D physics only). + public static Observable OnCollisionExit2DAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnCollisionExit2DAsObservable(); + } + + /// Sent each frame where a collider on another object is touching this object's collider (2D physics only). + public static Observable OnCollisionStay2DAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnCollisionStay2DAsObservable(); + } +#endif + #endregion + + #region ObservableCollisionTrigger +#if R3_PHYSICS_SUPPORT + + /// OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider. + public static Observable OnCollisionEnterAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnCollisionEnterAsObservable(); + } + + + /// OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider. + public static Observable OnCollisionExitAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnCollisionExitAsObservable(); + } + + /// OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider. + public static Observable OnCollisionStayAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnCollisionStayAsObservable(); + } +#endif + #endregion + + #region ObservableDestroyTrigger + + /// This function is called when the MonoBehaviour will be destroyed. + public static Observable OnDestroyAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Return(Unit.Default); // send destroy message + return GetOrAddComponent<___ObservableDestroyTrigger>(gameObject).OnDestroyAsObservable(); + } + + #endregion + + #region ObservableEnableTrigger + + /// This function is called when the object becomes enabled and active. + public static Observable OnEnableAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnEnableAsObservable(); + } + + /// This function is called when the behaviour becomes disabled () or inactive. + public static Observable OnDisableAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnDisableAsObservable(); + } + + #endregion + + #region ObservableFixedUpdateTrigger + + /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. + public static Observable FixedUpdateAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).FixedUpdateAsObservable(); + } + + #endregion + + #region ObservableLateUpdateTrigger + + /// LateUpdate is called every frame, if the Behaviour is enabled. + public static Observable LateUpdateAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).LateUpdateAsObservable(); + } + + #endregion + +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO) + + #region ObservableMouseTrigger + + /// OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider. + public static Observable OnMouseDownAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnMouseDownAsObservable(); + } + + /// OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse. + public static Observable OnMouseDragAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnMouseDragAsObservable(); + } + + /// OnMouseEnter is called when the mouse entered the GUIElement or Collider. + public static Observable OnMouseEnterAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnMouseEnterAsObservable(); + } + + /// OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider. + public static Observable OnMouseExitAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnMouseExitAsObservable(); + } + + /// OnMouseOver is called every frame while the mouse is over the GUIElement or Collider. + public static Observable OnMouseOverAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnMouseOverAsObservable(); + } + + /// OnMouseUp is called when the user has released the mouse button. + public static Observable OnMouseUpAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnMouseUpAsObservable(); + } + + /// OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed. + public static Observable OnMouseUpAsButtonAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnMouseUpAsButtonAsObservable(); + } + + #endregion + +#endif + + #region ObservableTrigger2DTrigger +#if R3_PHYSICS2D_SUPPORT + + /// Sent when another object enters a trigger collider attached to this object (2D physics only). + public static Observable OnTriggerEnter2DAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnTriggerEnter2DAsObservable(); + } + + + /// Sent when another object leaves a trigger collider attached to this object (2D physics only). + public static Observable OnTriggerExit2DAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnTriggerExit2DAsObservable(); + } + + /// Sent each frame where another object is within a trigger collider attached to this object (2D physics only). + public static Observable OnTriggerStay2DAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnTriggerStay2DAsObservable(); + } +#endif + #endregion + + #region ObservableTriggerTrigger +#if R3_PHYSICS_SUPPORT + + /// OnTriggerEnter is called when the Collider other enters the trigger. + public static Observable OnTriggerEnterAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnTriggerEnterAsObservable(); + } + + + /// OnTriggerExit is called when the Collider other has stopped touching the trigger. + public static Observable OnTriggerExitAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnTriggerExitAsObservable(); + } + + /// OnTriggerStay is called once per frame for every Collider other that is touching the trigger. + public static Observable OnTriggerStayAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnTriggerStayAsObservable(); + } +#endif + #endregion + + #region ObservableUpdateTrigger + + /// Update is called every frame, if the MonoBehaviour is enabled. + public static Observable UpdateAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).UpdateAsObservable(); + } + + #endregion + + #region ObservableVisibleTrigger + + /// OnBecameInvisible is called when the renderer is no longer visible by any camera. + public static Observable OnBecameInvisibleAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnBecameInvisibleAsObservable(); + } + + /// OnBecameVisible is called when the renderer became visible by any camera. + public static Observable OnBecameVisibleAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnBecameVisibleAsObservable(); + } + + #endregion + + #region ObservableTransformChangedTrigger + + /// Callback sent to the graphic before a Transform parent change occurs. + public static Observable OnBeforeTransformParentChangedAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnBeforeTransformParentChangedAsObservable(); + } + + /// This function is called when the parent property of the transform of the GameObject has changed. + public static Observable OnTransformParentChangedAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnTransformParentChangedAsObservable(); + } + + /// This function is called when the list of children of the transform of the GameObject has changed. + public static Observable OnTransformChildrenChangedAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnTransformChildrenChangedAsObservable(); + } + + #endregion + + #region ObservableCanvasGroupChangedTrigger + + /// Callback that is sent if the canvas group is changed. + public static Observable OnCanvasGroupChangedAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnCanvasGroupChangedAsObservable(); + } + + #endregion + + #region ObservableRectTransformTrigger + + /// Callback that is sent if an associated RectTransform has it's dimensions changed. + public static Observable OnRectTransformDimensionsChangeAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnRectTransformDimensionsChangeAsObservable(); + } + + /// Callback that is sent if an associated RectTransform is removed. + public static Observable OnRectTransformRemovedAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnRectTransformRemovedAsObservable(); + } + + #endregion + + #region ObservableParticleTrigger + + /// OnParticleCollision is called when a particle hits a collider. + public static Observable OnParticleCollisionAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnParticleCollisionAsObservable(); + } + + /// OnParticleTrigger is called when any particles in a particle system meet the conditions in the trigger module. + public static Observable OnParticleTriggerAsObservable(this GameObject gameObject) + { + if (gameObject == null) return Observable.Empty(); + return GetOrAddComponent(gameObject).OnParticleTriggerAsObservable(); + } + + #endregion + + static T GetOrAddComponent(GameObject gameObject) + where T : Component + { + var component = gameObject.GetComponent(); + if (component == null) + { + component = gameObject.AddComponent(); + } + + return component; + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.cs.meta new file mode 100644 index 00000000..941f1b0e --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 52641452e5a8194429bbdce2b14a5b35 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerTrigger.cs new file mode 100644 index 00000000..5005e64a --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerTrigger.cs @@ -0,0 +1,68 @@ +#if R3_PHYSICS_SUPPORT +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableTriggerTrigger : ObservableTriggerBase + { + Subject onTriggerEnter; + + /// OnTriggerEnter is called when the Collider other enters the trigger. + void OnTriggerEnter(Collider other) + { + if (onTriggerEnter != null) onTriggerEnter.OnNext(other); + } + + /// OnTriggerEnter is called when the Collider other enters the trigger. + public Observable OnTriggerEnterAsObservable() + { + return onTriggerEnter ?? (onTriggerEnter = new Subject()); + } + + Subject onTriggerExit; + + /// OnTriggerExit is called when the Collider other has stopped touching the trigger. + void OnTriggerExit(Collider other) + { + if (onTriggerExit != null) onTriggerExit.OnNext(other); + } + + /// OnTriggerExit is called when the Collider other has stopped touching the trigger. + public Observable OnTriggerExitAsObservable() + { + return onTriggerExit ?? (onTriggerExit = new Subject()); + } + + Subject onTriggerStay; + + /// OnTriggerStay is called once per frame for every Collider other that is touching the trigger. + void OnTriggerStay(Collider other) + { + if (onTriggerStay != null) onTriggerStay.OnNext(other); + } + + /// OnTriggerStay is called once per frame for every Collider other that is touching the trigger. + public Observable OnTriggerStayAsObservable() + { + return onTriggerStay ?? (onTriggerStay = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onTriggerEnter != null) + { + onTriggerEnter.OnCompleted(); + } + if (onTriggerExit != null) + { + onTriggerExit.OnCompleted(); + } + if (onTriggerStay != null) + { + onTriggerStay.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerTrigger.cs.meta new file mode 100644 index 00000000..cded19ee --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableTriggerTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bdba31c558827be4d9bf87dbcccb7493 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateSelectedTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateSelectedTrigger.cs new file mode 100644 index 00000000..d59a1e19 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateSelectedTrigger.cs @@ -0,0 +1,31 @@ +#if R3_UGUI_SUPPORT +using UnityEngine; +using UnityEngine.EventSystems; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableUpdateSelectedTrigger : ObservableTriggerBase, IEventSystemHandler, IUpdateSelectedHandler + { + Subject onUpdateSelected; + + void IUpdateSelectedHandler.OnUpdateSelected(BaseEventData eventData) + { + if (onUpdateSelected != null) onUpdateSelected.OnNext(eventData); + } + + public Observable OnUpdateSelectedAsObservable() + { + return onUpdateSelected ?? (onUpdateSelected = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onUpdateSelected != null) + { + onUpdateSelected.OnCompleted(); + } + } + } +} +#endif diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateSelectedTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateSelectedTrigger.cs.meta new file mode 100644 index 00000000..f3421720 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateSelectedTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 827ff21525ac7f94080bf71dd6866d4d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateTrigger.cs new file mode 100644 index 00000000..c3c7d43a --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateTrigger.cs @@ -0,0 +1,30 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableUpdateTrigger : ObservableTriggerBase + { + Subject update; + + /// Update is called every frame, if the MonoBehaviour is enabled. + void Update() + { + if (update != null) update?.OnNext(Unit.Default); + } + + /// Update is called every frame, if the MonoBehaviour is enabled. + public Observable UpdateAsObservable() + { + return update ?? (update = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (update != null) + { + update.OnCompleted(); + } + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateTrigger.cs.meta new file mode 100644 index 00000000..503f65cf --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableUpdateTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 23ecd6a0559dbc846821f4793dca5040 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableVisibleTrigger.cs b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableVisibleTrigger.cs new file mode 100644 index 00000000..53a79542 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableVisibleTrigger.cs @@ -0,0 +1,48 @@ +using UnityEngine; + +namespace R3.Triggers +{ + [DisallowMultipleComponent] + public class ObservableVisibleTrigger : ObservableTriggerBase + { + Subject onBecameInvisible; + + /// OnBecameInvisible is called when the renderer is no longer visible by any camera. + void OnBecameInvisible() + { + if (onBecameInvisible != null) onBecameInvisible.OnNext(Unit.Default); + } + + /// OnBecameInvisible is called when the renderer is no longer visible by any camera. + public Observable OnBecameInvisibleAsObservable() + { + return onBecameInvisible ?? (onBecameInvisible = new Subject()); + } + + Subject onBecameVisible; + + /// OnBecameVisible is called when the renderer became visible by any camera. + void OnBecameVisible() + { + if (onBecameVisible != null) onBecameVisible.OnNext(Unit.Default); + } + + /// OnBecameVisible is called when the renderer became visible by any camera. + public Observable OnBecameVisibleAsObservable() + { + return onBecameVisible ?? (onBecameVisible = new Subject()); + } + + protected override void RaiseOnCompletedOnDestroy() + { + if (onBecameInvisible != null) + { + onBecameInvisible.OnCompleted(); + } + if (onBecameVisible != null) + { + onBecameVisible.OnCompleted(); + } + } + } +} diff --git a/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableVisibleTrigger.cs.meta b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableVisibleTrigger.cs.meta new file mode 100644 index 00000000..6606d509 --- /dev/null +++ b/src/R3.Unity/Assets/R3.Unity/Runtime/Triggers/ObservableVisibleTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: da10a5f26bc0b074a9ee55c5080178ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/R3.Unity/Packages/manifest.json b/src/R3.Unity/Packages/manifest.json index a402b49e..8e1ce771 100644 --- a/src/R3.Unity/Packages/manifest.json +++ b/src/R3.Unity/Packages/manifest.json @@ -5,36 +5,7 @@ "com.github-glitchenzo.nugetforunity": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity", "com.unity.ide.visualstudio": "2.0.22", "com.unity.ugui": "1.0.0", - "com.unity.modules.ai": "1.0.0", - "com.unity.modules.androidjni": "1.0.0", - "com.unity.modules.animation": "1.0.0", - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.cloth": "1.0.0", - "com.unity.modules.director": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.particlesystem": "1.0.0", "com.unity.modules.physics": "1.0.0", - "com.unity.modules.physics2d": "1.0.0", - "com.unity.modules.screencapture": "1.0.0", - "com.unity.modules.terrain": "1.0.0", - "com.unity.modules.terrainphysics": "1.0.0", - "com.unity.modules.tilemap": "1.0.0", - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.uielements": "1.0.0", - "com.unity.modules.umbra": "1.0.0", - "com.unity.modules.unityanalytics": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequestassetbundle": "1.0.0", - "com.unity.modules.unitywebrequestaudio": "1.0.0", - "com.unity.modules.unitywebrequesttexture": "1.0.0", - "com.unity.modules.unitywebrequestwww": "1.0.0", - "com.unity.modules.vehicles": "1.0.0", - "com.unity.modules.video": "1.0.0", - "com.unity.modules.vr": "1.0.0", - "com.unity.modules.wind": "1.0.0", - "com.unity.modules.xr": "1.0.0" + "com.unity.modules.physics2d": "1.0.0" } } diff --git a/src/R3.Unity/Packages/packages-lock.json b/src/R3.Unity/Packages/packages-lock.json index dbd1231f..53a72ddd 100644 --- a/src/R3.Unity/Packages/packages-lock.json +++ b/src/R3.Unity/Packages/packages-lock.json @@ -56,74 +56,15 @@ "com.unity.modules.imgui": "1.0.0" } }, - "com.unity.modules.ai": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.androidjni": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.animation": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.assetbundle": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.audio": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.cloth": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0" - } - }, - "com.unity.modules.director": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.animation": "1.0.0" - } - }, - "com.unity.modules.imageconversion": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, "com.unity.modules.imgui": { "version": "1.0.0", - "depth": 0, + "depth": 1, "source": "builtin", "dependencies": {} }, "com.unity.modules.jsonserialize": { "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.particlesystem": { - "version": "1.0.0", - "depth": 0, + "depth": 2, "source": "builtin", "dependencies": {} }, @@ -139,165 +80,11 @@ "source": "builtin", "dependencies": {} }, - "com.unity.modules.screencapture": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.subsystems": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.modules.jsonserialize": "1.0.0" - } - }, - "com.unity.modules.terrain": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.terrainphysics": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.terrain": "1.0.0" - } - }, - "com.unity.modules.tilemap": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics2d": "1.0.0" - } - }, "com.unity.modules.ui": { "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.uielements": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - } - }, - "com.unity.modules.umbra": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.unityanalytics": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - } - }, - "com.unity.modules.unitywebrequest": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.unitywebrequestassetbundle": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0" - } - }, - "com.unity.modules.unitywebrequestaudio": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.audio": "1.0.0" - } - }, - "com.unity.modules.unitywebrequesttexture": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.unitywebrequestwww": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequestassetbundle": "1.0.0", - "com.unity.modules.unitywebrequestaudio": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.vehicles": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0" - } - }, - "com.unity.modules.video": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0" - } - }, - "com.unity.modules.vr": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.xr": "1.0.0" - } - }, - "com.unity.modules.wind": { - "version": "1.0.0", - "depth": 0, + "depth": 1, "source": "builtin", "dependencies": {} - }, - "com.unity.modules.xr": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.subsystems": "1.0.0" - } } } }