-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using UnityEngine; | ||
|
||
namespace R3.Triggers | ||
{ | ||
[DisallowMultipleComponent] | ||
public class ObservableAnimatorTrigger : ObservableTriggerBase | ||
{ | ||
Subject<int> onAnimatorIK; | ||
|
||
/// <summary>Callback for setting up animation IK (inverse kinematics).</summary> | ||
void OnAnimatorIK(int layerIndex) | ||
{ | ||
if (onAnimatorIK != null) onAnimatorIK.OnNext(layerIndex); | ||
} | ||
|
||
/// <summary>Callback for setting up animation IK (inverse kinematics).</summary> | ||
public Observable<int> OnAnimatorIKAsObservable() | ||
{ | ||
return onAnimatorIK ?? (onAnimatorIK = new Subject<int>()); | ||
} | ||
|
||
Subject<Unit> onAnimatorMove; | ||
|
||
/// <summary>Callback for processing animation movements for modifying root motion.</summary> | ||
void OnAnimatorMove() | ||
{ | ||
if (onAnimatorMove != null) onAnimatorMove.OnNext(Unit.Default); | ||
} | ||
|
||
/// <summary>Callback for processing animation movements for modifying root motion.</summary> | ||
public Observable<Unit> OnAnimatorMoveAsObservable() | ||
{ | ||
return onAnimatorMove ?? (onAnimatorMove = new Subject<Unit>()); | ||
} | ||
|
||
protected override void RaiseOnCompletedOnDestroy() | ||
{ | ||
if (onAnimatorIK != null) | ||
{ | ||
onAnimatorIK.OnCompleted(); | ||
} | ||
if (onAnimatorMove != null) | ||
{ | ||
onAnimatorMove.OnCompleted(); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#if R3_UGUI_SUPPORT | ||
|
||
using UnityEngine; | ||
using UnityEngine.EventSystems; | ||
|
||
namespace R3.Triggers | ||
{ | ||
[DisallowMultipleComponent] | ||
public class ObservableBeginDragTrigger : ObservableTriggerBase, IEventSystemHandler, IBeginDragHandler | ||
{ | ||
Subject<PointerEventData> onBeginDrag; | ||
|
||
void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) | ||
{ | ||
if (onBeginDrag != null) onBeginDrag.OnNext(eventData); | ||
} | ||
|
||
public Observable<PointerEventData> OnBeginDragAsObservable() | ||
{ | ||
return onBeginDrag ?? (onBeginDrag = new Subject<PointerEventData>()); | ||
} | ||
|
||
protected override void RaiseOnCompletedOnDestroy() | ||
{ | ||
if (onBeginDrag != null) | ||
{ | ||
onBeginDrag.OnCompleted(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#if R3_UGUI_SUPPORT | ||
|
||
using UnityEngine; | ||
using UnityEngine.EventSystems; | ||
|
||
namespace R3.Triggers | ||
{ | ||
[DisallowMultipleComponent] | ||
public class ObservableCancelTrigger : ObservableTriggerBase, IEventSystemHandler, ICancelHandler | ||
{ | ||
Subject<BaseEventData> onCancel; | ||
|
||
void ICancelHandler.OnCancel(BaseEventData eventData) | ||
{ | ||
if (onCancel != null) onCancel.OnNext(eventData); | ||
} | ||
|
||
public Observable<BaseEventData> OnCancelAsObservable() | ||
{ | ||
return onCancel ?? (onCancel = new Subject<BaseEventData>()); | ||
} | ||
|
||
protected override void RaiseOnCompletedOnDestroy() | ||
{ | ||
if (onCancel != null) | ||
{ | ||
onCancel.OnCompleted(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using UnityEngine; | ||
|
||
namespace R3.Triggers | ||
{ | ||
[DisallowMultipleComponent] | ||
public class ObservableCanvasGroupChangedTrigger : ObservableTriggerBase | ||
{ | ||
Subject<Unit> onCanvasGroupChanged; | ||
|
||
// Callback that is sent if the canvas group is changed | ||
void OnCanvasGroupChanged() | ||
{ | ||
if (onCanvasGroupChanged != null) onCanvasGroupChanged.OnNext(Unit.Default); | ||
} | ||
|
||
/// <summary>Callback that is sent if the canvas group is changed.</summary> | ||
public Observable<Unit> OnCanvasGroupChangedAsObservable() | ||
{ | ||
return onCanvasGroupChanged ?? (onCanvasGroupChanged = new Subject<Unit>()); | ||
} | ||
|
||
protected override void RaiseOnCompletedOnDestroy() | ||
{ | ||
if (onCanvasGroupChanged != null) | ||
{ | ||
onCanvasGroupChanged.OnCompleted(); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#if R3_PHYSICS2D_SUPPORT | ||
using UnityEngine; | ||
|
||
namespace R3.Triggers | ||
{ | ||
[DisallowMultipleComponent] | ||
public class ObservableCollision2DTrigger : ObservableTriggerBase | ||
{ | ||
Subject<Collision2D> onCollisionEnter2D; | ||
|
||
/// <summary>Sent when an incoming collider makes contact with this object's collider (2D physics only).</summary> | ||
void OnCollisionEnter2D(Collision2D coll) | ||
{ | ||
if (onCollisionEnter2D != null) onCollisionEnter2D.OnNext(coll); | ||
} | ||
|
||
/// <summary>Sent when an incoming collider makes contact with this object's collider (2D physics only).</summary> | ||
public Observable<Collision2D> OnCollisionEnter2DAsObservable() | ||
{ | ||
return onCollisionEnter2D ?? (onCollisionEnter2D = new Subject<Collision2D>()); | ||
} | ||
|
||
Subject<Collision2D> onCollisionExit2D; | ||
|
||
/// <summary>Sent when a collider on another object stops touching this object's collider (2D physics only).</summary> | ||
void OnCollisionExit2D(Collision2D coll) | ||
{ | ||
if (onCollisionExit2D != null) onCollisionExit2D.OnNext(coll); | ||
} | ||
|
||
/// <summary>Sent when a collider on another object stops touching this object's collider (2D physics only).</summary> | ||
public Observable<Collision2D> OnCollisionExit2DAsObservable() | ||
{ | ||
return onCollisionExit2D ?? (onCollisionExit2D = new Subject<Collision2D>()); | ||
} | ||
|
||
Subject<Collision2D> onCollisionStay2D; | ||
|
||
/// <summary>Sent each frame where a collider on another object is touching this object's collider (2D physics only).</summary> | ||
void OnCollisionStay2D(Collision2D coll) | ||
{ | ||
if (onCollisionStay2D != null) onCollisionStay2D.OnNext(coll); | ||
} | ||
|
||
/// <summary>Sent each frame where a collider on another object is touching this object's collider (2D physics only).</summary> | ||
public Observable<Collision2D> OnCollisionStay2DAsObservable() | ||
{ | ||
return onCollisionStay2D ?? (onCollisionStay2D = new Subject<Collision2D>()); | ||
} | ||
|
||
protected override void RaiseOnCompletedOnDestroy() | ||
{ | ||
if (onCollisionEnter2D != null) | ||
{ | ||
onCollisionEnter2D.OnCompleted(); | ||
} | ||
if (onCollisionExit2D != null) | ||
{ | ||
onCollisionExit2D.OnCompleted(); | ||
} | ||
if (onCollisionStay2D != null) | ||
{ | ||
onCollisionStay2D.OnCompleted(); | ||
} | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#if R3_PHYSICS_SUPPORT | ||
using UnityEngine; | ||
|
||
namespace R3.Triggers | ||
{ | ||
[DisallowMultipleComponent] | ||
public class ObservableCollisionTrigger : ObservableTriggerBase | ||
{ | ||
Subject<Collision> onCollisionEnter; | ||
|
||
/// <summary>OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.</summary> | ||
void OnCollisionEnter(Collision collision) | ||
{ | ||
if (onCollisionEnter != null) onCollisionEnter.OnNext(collision); | ||
} | ||
|
||
/// <summary>OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.</summary> | ||
public Observable<Collision> OnCollisionEnterAsObservable() | ||
{ | ||
return onCollisionEnter ?? (onCollisionEnter = new Subject<Collision>()); | ||
} | ||
|
||
Subject<Collision> onCollisionExit; | ||
|
||
/// <summary>OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.</summary> | ||
void OnCollisionExit(Collision collisionInfo) | ||
{ | ||
if (onCollisionExit != null) onCollisionExit.OnNext(collisionInfo); | ||
} | ||
|
||
/// <summary>OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.</summary> | ||
public Observable<Collision> OnCollisionExitAsObservable() | ||
{ | ||
return onCollisionExit ?? (onCollisionExit = new Subject<Collision>()); | ||
} | ||
|
||
Subject<Collision> onCollisionStay; | ||
|
||
/// <summary>OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.</summary> | ||
void OnCollisionStay(Collision collisionInfo) | ||
{ | ||
if (onCollisionStay != null) onCollisionStay.OnNext(collisionInfo); | ||
} | ||
|
||
/// <summary>OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.</summary> | ||
public Observable<Collision> OnCollisionStayAsObservable() | ||
{ | ||
return onCollisionStay ?? (onCollisionStay = new Subject<Collision>()); | ||
} | ||
|
||
protected override void RaiseOnCompletedOnDestroy() | ||
{ | ||
if (onCollisionEnter != null) | ||
{ | ||
onCollisionEnter.OnCompleted(); | ||
} | ||
if (onCollisionExit != null) | ||
{ | ||
onCollisionExit.OnCompleted(); | ||
} | ||
if (onCollisionStay != null) | ||
{ | ||
onCollisionStay.OnCompleted(); | ||
} | ||
} | ||
} | ||
} | ||
#endif |