UniRx 에셋 추가
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.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 IObservable<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 IObservable<Unit> OnAnimatorMoveAsObservable()
|
||||
{
|
||||
return onAnimatorMove ?? (onAnimatorMove = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onAnimatorIK != null)
|
||||
{
|
||||
onAnimatorIK.OnCompleted();
|
||||
}
|
||||
if (onAnimatorMove != null)
|
||||
{
|
||||
onAnimatorMove.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e03f9257cc6667f4082439aa77d6f01e
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableBeginDragTrigger : ObservableTriggerBase, IEventSystemHandler, IBeginDragHandler
|
||||
{
|
||||
Subject<PointerEventData> onBeginDrag;
|
||||
|
||||
void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
if (onBeginDrag != null) onBeginDrag.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnBeginDragAsObservable()
|
||||
{
|
||||
return onBeginDrag ?? (onBeginDrag = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onBeginDrag != null)
|
||||
{
|
||||
onBeginDrag.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a81a9b6bec6b4f4fba7e0047cd989f6
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableCancelTrigger : ObservableTriggerBase, IEventSystemHandler, ICancelHandler
|
||||
{
|
||||
Subject<BaseEventData> onCancel;
|
||||
|
||||
void ICancelHandler.OnCancel(BaseEventData eventData)
|
||||
{
|
||||
if (onCancel != null) onCancel.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnCancelAsObservable()
|
||||
{
|
||||
return onCancel ?? (onCancel = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onCancel != null)
|
||||
{
|
||||
onCancel.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c0a9070b7cc23746b2c0e2db3ec16cd
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// after uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.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 IObservable<Unit> OnCanvasGroupChangedAsObservable()
|
||||
{
|
||||
return onCanvasGroupChanged ?? (onCanvasGroupChanged = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onCanvasGroupChanged != null)
|
||||
{
|
||||
onCanvasGroupChanged.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54095d3e740f7714085d0568207cbfe0
|
||||
timeCreated: 1455373899
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.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 IObservable<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 IObservable<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 IObservable<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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1be7847b61f30f24daa5762db87a5b19
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.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 IObservable<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 IObservable<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 IObservable<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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10b917196cbfcf74898ce1686e205d04
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableDeselectTrigger : ObservableTriggerBase, IEventSystemHandler, IDeselectHandler
|
||||
{
|
||||
Subject<BaseEventData> onDeselect;
|
||||
|
||||
void IDeselectHandler.OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
if (onDeselect != null) onDeselect.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnDeselectAsObservable()
|
||||
{
|
||||
return onDeselect ?? (onDeselect = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onDeselect != null)
|
||||
{
|
||||
onDeselect.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fe6f69c4d869c04e8a1924aab1d3694
|
||||
timeCreated: 1455373900
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableDestroyTrigger : MonoBehaviour
|
||||
{
|
||||
bool calledDestroy = false;
|
||||
Subject<Unit> onDestroy;
|
||||
CompositeDisposable disposablesOnDestroy;
|
||||
|
||||
[Obsolete("Internal Use.")]
|
||||
internal bool IsMonitoredActivate { get; set; }
|
||||
|
||||
public bool IsActivated { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Check called OnDestroy.
|
||||
/// This property does not guarantees GameObject was destroyed,
|
||||
/// when gameObject is deactive, does not raise OnDestroy.
|
||||
/// </summary>
|
||||
public bool IsCalledOnDestroy { get { return calledDestroy; } }
|
||||
|
||||
void Awake()
|
||||
{
|
||||
IsActivated = true;
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
void OnDestroy()
|
||||
{
|
||||
if (!calledDestroy)
|
||||
{
|
||||
calledDestroy = true;
|
||||
if (disposablesOnDestroy != null) disposablesOnDestroy.Dispose();
|
||||
if (onDestroy != null) { onDestroy.OnNext(Unit.Default); onDestroy.OnCompleted(); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
public IObservable<Unit> OnDestroyAsObservable()
|
||||
{
|
||||
if (this == null) return Observable.Return(Unit.Default);
|
||||
if (calledDestroy) return Observable.Return(Unit.Default);
|
||||
return onDestroy ?? (onDestroy = new Subject<Unit>());
|
||||
}
|
||||
|
||||
/// <summary>Invoke OnDestroy, this method is used on internal.</summary>
|
||||
public void ForceRaiseOnDestroy()
|
||||
{
|
||||
OnDestroy();
|
||||
}
|
||||
|
||||
public void AddDisposableOnDestroy(IDisposable disposable)
|
||||
{
|
||||
if (calledDestroy)
|
||||
{
|
||||
disposable.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
if (disposablesOnDestroy == null) disposablesOnDestroy = new CompositeDisposable();
|
||||
disposablesOnDestroy.Add(disposable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb219b23cdf4b314f94a27bca3cc8012
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableDragTrigger : ObservableTriggerBase, IEventSystemHandler, IDragHandler
|
||||
{
|
||||
Subject<PointerEventData> onDrag;
|
||||
|
||||
void IDragHandler.OnDrag(PointerEventData eventData)
|
||||
{
|
||||
if (onDrag != null) onDrag.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnDragAsObservable()
|
||||
{
|
||||
return onDrag ?? (onDrag = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onDrag != null)
|
||||
{
|
||||
onDrag.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79db090dc9e4db245821e8b89b0e208e
|
||||
timeCreated: 1455373899
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableDropTrigger : ObservableTriggerBase, IEventSystemHandler, IDropHandler
|
||||
{
|
||||
Subject<PointerEventData> onDrop;
|
||||
|
||||
void IDropHandler.OnDrop(PointerEventData eventData)
|
||||
{
|
||||
if (onDrop != null) onDrop.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnDropAsObservable()
|
||||
{
|
||||
return onDrop ?? (onDrop = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onDrop != null)
|
||||
{
|
||||
onDrop.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2ffa8b5af3474446a310bb6aa0b180a
|
||||
timeCreated: 1455373902
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableEnableTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> onEnable;
|
||||
|
||||
/// <summary>This function is called when the object becomes enabled and active.</summary>
|
||||
void OnEnable()
|
||||
{
|
||||
if (onEnable != null) onEnable.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the object becomes enabled and active.</summary>
|
||||
public IObservable<Unit> OnEnableAsObservable()
|
||||
{
|
||||
return onEnable ?? (onEnable = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onDisable;
|
||||
|
||||
/// <summary>This function is called when the behaviour becomes disabled () or inactive.</summary>
|
||||
void OnDisable()
|
||||
{
|
||||
if (onDisable != null) onDisable.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the behaviour becomes disabled () or inactive.</summary>
|
||||
public IObservable<Unit> OnDisableAsObservable()
|
||||
{
|
||||
return onDisable ?? (onDisable = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onEnable != null)
|
||||
{
|
||||
onEnable.OnCompleted();
|
||||
}
|
||||
if (onDisable != null)
|
||||
{
|
||||
onDisable.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d9c7eb607af1fd4aa0e15f52cc0543b
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableEndDragTrigger : ObservableTriggerBase, IEventSystemHandler, IEndDragHandler
|
||||
{
|
||||
Subject<PointerEventData> onEndDrag;
|
||||
|
||||
void IEndDragHandler.OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
if (onEndDrag != null) onEndDrag.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnEndDragAsObservable()
|
||||
{
|
||||
return onEndDrag ?? (onEndDrag = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onEndDrag != null)
|
||||
{
|
||||
onEndDrag.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8ce8424f238d6842bd8b09c0cca1ac4
|
||||
timeCreated: 1455373900
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,359 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.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<BaseEventData> onDeselect;
|
||||
|
||||
void IDeselectHandler.OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
if (onDeselect != null) onDeselect.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnDeselectAsObservable()
|
||||
{
|
||||
return onDeselect ?? (onDeselect = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IMoveHandler
|
||||
|
||||
Subject<AxisEventData> onMove;
|
||||
|
||||
void IMoveHandler.OnMove(AxisEventData eventData)
|
||||
{
|
||||
if (onMove != null) onMove.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<AxisEventData> OnMoveAsObservable()
|
||||
{
|
||||
return onMove ?? (onMove = new Subject<AxisEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPointerDownHandler
|
||||
|
||||
Subject<PointerEventData> onPointerDown;
|
||||
|
||||
void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerDown != null) onPointerDown.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerDownAsObservable()
|
||||
{
|
||||
return onPointerDown ?? (onPointerDown = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPointerEnterHandler
|
||||
|
||||
Subject<PointerEventData> onPointerEnter;
|
||||
|
||||
void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerEnter != null) onPointerEnter.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerEnterAsObservable()
|
||||
{
|
||||
return onPointerEnter ?? (onPointerEnter = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPointerExitHandler
|
||||
|
||||
Subject<PointerEventData> onPointerExit;
|
||||
|
||||
void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerExit != null) onPointerExit.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerExitAsObservable()
|
||||
{
|
||||
return onPointerExit ?? (onPointerExit = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPointerUpHandler
|
||||
|
||||
Subject<PointerEventData> onPointerUp;
|
||||
|
||||
void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerUp != null) onPointerUp.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerUpAsObservable()
|
||||
{
|
||||
return onPointerUp ?? (onPointerUp = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISelectHandler
|
||||
|
||||
Subject<BaseEventData> onSelect;
|
||||
|
||||
void ISelectHandler.OnSelect(BaseEventData eventData)
|
||||
{
|
||||
if (onSelect != null) onSelect.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnSelectAsObservable()
|
||||
{
|
||||
return onSelect ?? (onSelect = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPointerClickHandler
|
||||
|
||||
Subject<PointerEventData> onPointerClick;
|
||||
|
||||
void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerClick != null) onPointerClick.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerClickAsObservable()
|
||||
{
|
||||
return onPointerClick ?? (onPointerClick = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISubmitHandler
|
||||
|
||||
Subject<BaseEventData> onSubmit;
|
||||
|
||||
void ISubmitHandler.OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
if (onSubmit != null) onSubmit.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnSubmitAsObservable()
|
||||
{
|
||||
return onSubmit ?? (onSubmit = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDragHandler
|
||||
|
||||
Subject<PointerEventData> onDrag;
|
||||
|
||||
void IDragHandler.OnDrag(PointerEventData eventData)
|
||||
{
|
||||
if (onDrag != null) onDrag.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnDragAsObservable()
|
||||
{
|
||||
return onDrag ?? (onDrag = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IBeginDragHandler
|
||||
|
||||
Subject<PointerEventData> onBeginDrag;
|
||||
|
||||
void IBeginDragHandler.OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
if (onBeginDrag != null) onBeginDrag.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnBeginDragAsObservable()
|
||||
{
|
||||
return onBeginDrag ?? (onBeginDrag = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEndDragHandler
|
||||
|
||||
Subject<PointerEventData> onEndDrag;
|
||||
|
||||
void IEndDragHandler.OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
if (onEndDrag != null) onEndDrag.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnEndDragAsObservable()
|
||||
{
|
||||
return onEndDrag ?? (onEndDrag = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDropHandler
|
||||
|
||||
Subject<PointerEventData> onDrop;
|
||||
|
||||
void IDropHandler.OnDrop(PointerEventData eventData)
|
||||
{
|
||||
if (onDrop != null) onDrop.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnDropAsObservable()
|
||||
{
|
||||
return onDrop ?? (onDrop = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IUpdateSelectedHandler
|
||||
|
||||
Subject<BaseEventData> onUpdateSelected;
|
||||
|
||||
void IUpdateSelectedHandler.OnUpdateSelected(BaseEventData eventData)
|
||||
{
|
||||
if (onUpdateSelected != null) onUpdateSelected.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnUpdateSelectedAsObservable()
|
||||
{
|
||||
return onUpdateSelected ?? (onUpdateSelected = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IInitializePotentialDragHandler
|
||||
|
||||
Subject<PointerEventData> onInitializePotentialDrag;
|
||||
|
||||
void IInitializePotentialDragHandler.OnInitializePotentialDrag(PointerEventData eventData)
|
||||
{
|
||||
if (onInitializePotentialDrag != null) onInitializePotentialDrag.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnInitializePotentialDragAsObservable()
|
||||
{
|
||||
return onInitializePotentialDrag ?? (onInitializePotentialDrag = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICancelHandler
|
||||
|
||||
Subject<BaseEventData> onCancel;
|
||||
|
||||
void ICancelHandler.OnCancel(BaseEventData eventData)
|
||||
{
|
||||
if (onCancel != null) onCancel.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnCancelAsObservable()
|
||||
{
|
||||
return onCancel ?? (onCancel = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IScrollHandler
|
||||
|
||||
Subject<PointerEventData> onScroll;
|
||||
|
||||
void IScrollHandler.OnScroll(PointerEventData eventData)
|
||||
{
|
||||
if (onScroll != null) onScroll.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnScrollAsObservable()
|
||||
{
|
||||
return onScroll ?? (onScroll = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
#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
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48e93426b16d5454c89e8d47ccded1c5
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableFixedUpdateTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> fixedUpdate;
|
||||
|
||||
/// <summary>This function is called every fixed framerate frame, if the MonoBehaviour is enabled.</summary>
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (fixedUpdate != null) fixedUpdate.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>This function is called every fixed framerate frame, if the MonoBehaviour is enabled.</summary>
|
||||
public IObservable<Unit> FixedUpdateAsObservable()
|
||||
{
|
||||
return fixedUpdate ?? (fixedUpdate = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (fixedUpdate != null)
|
||||
{
|
||||
fixedUpdate.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d525c42c11d945f4398061ed8f84e5f4
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableInitializePotentialDragTrigger : ObservableTriggerBase, IEventSystemHandler, IInitializePotentialDragHandler
|
||||
{
|
||||
Subject<PointerEventData> onInitializePotentialDrag;
|
||||
|
||||
void IInitializePotentialDragHandler.OnInitializePotentialDrag(PointerEventData eventData)
|
||||
{
|
||||
if (onInitializePotentialDrag != null) onInitializePotentialDrag.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnInitializePotentialDragAsObservable()
|
||||
{
|
||||
return onInitializePotentialDrag ?? (onInitializePotentialDrag = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onInitializePotentialDrag != null)
|
||||
{
|
||||
onInitializePotentialDrag.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f3148a9e1b8b21409f54d2b0c2c81de
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableJointTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<float> onJointBreak;
|
||||
|
||||
void OnJointBreak(float breakForce)
|
||||
{
|
||||
if (onJointBreak != null) onJointBreak.OnNext(breakForce);
|
||||
}
|
||||
|
||||
public IObservable<float> OnJointBreakAsObservable()
|
||||
{
|
||||
return onJointBreak ?? (onJointBreak = new Subject<float>());
|
||||
}
|
||||
|
||||
|
||||
Subject<Joint2D> onJointBreak2D;
|
||||
|
||||
void OnJointBreak2D(Joint2D brokenJoint)
|
||||
{
|
||||
if (onJointBreak2D != null) onJointBreak2D.OnNext(brokenJoint);
|
||||
}
|
||||
|
||||
public IObservable<Joint2D> OnJointBreak2DAsObservable()
|
||||
{
|
||||
return onJointBreak2D ?? (onJointBreak2D = new Subject<Joint2D>());
|
||||
}
|
||||
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onJointBreak != null)
|
||||
{
|
||||
onJointBreak.OnCompleted();
|
||||
}
|
||||
if (onJointBreak2D != null)
|
||||
{
|
||||
onJointBreak2D.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79b758631951cbc42b40ea87072e1ab3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableLateUpdateTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> lateUpdate;
|
||||
|
||||
/// <summary>LateUpdate is called every frame, if the Behaviour is enabled.</summary>
|
||||
void LateUpdate()
|
||||
{
|
||||
if (lateUpdate != null) lateUpdate.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>LateUpdate is called every frame, if the Behaviour is enabled.</summary>
|
||||
public IObservable<Unit> LateUpdateAsObservable()
|
||||
{
|
||||
return lateUpdate ?? (lateUpdate = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (lateUpdate != null)
|
||||
{
|
||||
lateUpdate.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 176ace24965d0c744bc61c8aad8b3fc7
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,143 @@
|
||||
#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableMouseTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> onMouseDown;
|
||||
|
||||
/// <summary>OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider.</summary>
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (onMouseDown != null) onMouseDown.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider.</summary>
|
||||
public IObservable<Unit> OnMouseDownAsObservable()
|
||||
{
|
||||
return onMouseDown ?? (onMouseDown = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onMouseDrag;
|
||||
|
||||
/// <summary>OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse.</summary>
|
||||
void OnMouseDrag()
|
||||
{
|
||||
if (onMouseDrag != null) onMouseDrag.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse.</summary>
|
||||
public IObservable<Unit> OnMouseDragAsObservable()
|
||||
{
|
||||
return onMouseDrag ?? (onMouseDrag = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onMouseEnter;
|
||||
|
||||
/// <summary>OnMouseEnter is called when the mouse entered the GUIElement or Collider.</summary>
|
||||
void OnMouseEnter()
|
||||
{
|
||||
if (onMouseEnter != null) onMouseEnter.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnMouseEnter is called when the mouse entered the GUIElement or Collider.</summary>
|
||||
public IObservable<Unit> OnMouseEnterAsObservable()
|
||||
{
|
||||
return onMouseEnter ?? (onMouseEnter = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onMouseExit;
|
||||
|
||||
/// <summary>OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider.</summary>
|
||||
void OnMouseExit()
|
||||
{
|
||||
if (onMouseExit != null) onMouseExit.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider.</summary>
|
||||
public IObservable<Unit> OnMouseExitAsObservable()
|
||||
{
|
||||
return onMouseExit ?? (onMouseExit = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onMouseOver;
|
||||
|
||||
/// <summary>OnMouseOver is called every frame while the mouse is over the GUIElement or Collider.</summary>
|
||||
void OnMouseOver()
|
||||
{
|
||||
if (onMouseOver != null) onMouseOver.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnMouseOver is called every frame while the mouse is over the GUIElement or Collider.</summary>
|
||||
public IObservable<Unit> OnMouseOverAsObservable()
|
||||
{
|
||||
return onMouseOver ?? (onMouseOver = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onMouseUp;
|
||||
|
||||
/// <summary>OnMouseUp is called when the user has released the mouse button.</summary>
|
||||
void OnMouseUp()
|
||||
{
|
||||
if (onMouseUp != null) onMouseUp.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnMouseUp is called when the user has released the mouse button.</summary>
|
||||
public IObservable<Unit> OnMouseUpAsObservable()
|
||||
{
|
||||
return onMouseUp ?? (onMouseUp = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onMouseUpAsButton;
|
||||
|
||||
/// <summary>OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed.</summary>
|
||||
void OnMouseUpAsButton()
|
||||
{
|
||||
if (onMouseUpAsButton != null) onMouseUpAsButton.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed.</summary>
|
||||
public IObservable<Unit> OnMouseUpAsButtonAsObservable()
|
||||
{
|
||||
return onMouseUpAsButton ?? (onMouseUpAsButton = new Subject<Unit>());
|
||||
}
|
||||
|
||||
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
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5f30958c5509bc4f9c14ea261a1567c
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableMoveTrigger : ObservableTriggerBase, IEventSystemHandler, IMoveHandler
|
||||
{
|
||||
Subject<AxisEventData> onMove;
|
||||
|
||||
void IMoveHandler.OnMove(AxisEventData eventData)
|
||||
{
|
||||
if (onMove != null) onMove.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<AxisEventData> OnMoveAsObservable()
|
||||
{
|
||||
return onMove ?? (onMove = new Subject<AxisEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onMove != null)
|
||||
{
|
||||
onMove.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e1feec0f10dcea4d9c779a81a0ee3dc
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableParticleTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<GameObject> onParticleCollision;
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
Subject<Unit> onParticleTrigger;
|
||||
#endif
|
||||
|
||||
/// <summary>OnParticleCollision is called when a particle hits a collider.</summary>
|
||||
void OnParticleCollision(GameObject other)
|
||||
{
|
||||
if (onParticleCollision != null) onParticleCollision.OnNext(other);
|
||||
}
|
||||
|
||||
/// <summary>OnParticleCollision is called when a particle hits a collider.</summary>
|
||||
public IObservable<GameObject> OnParticleCollisionAsObservable()
|
||||
{
|
||||
return onParticleCollision ?? (onParticleCollision = new Subject<GameObject>());
|
||||
}
|
||||
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
|
||||
/// <summary>OnParticleTrigger is called when any particles in a particle system meet the conditions in the trigger module.</summary>
|
||||
void OnParticleTrigger()
|
||||
{
|
||||
if (onParticleTrigger != null) onParticleTrigger.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnParticleTrigger is called when any particles in a particle system meet the conditions in the trigger module.</summary>
|
||||
public IObservable<Unit> OnParticleTriggerAsObservable()
|
||||
{
|
||||
return onParticleTrigger ?? (onParticleTrigger = new Subject<Unit>());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onParticleCollision != null)
|
||||
{
|
||||
onParticleCollision.OnCompleted();
|
||||
}
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
if (onParticleTrigger != null)
|
||||
{
|
||||
onParticleTrigger.OnCompleted();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e6a20494274d5045a1b36a770ea76b4
|
||||
timeCreated: 1468669952
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservablePointerClickTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerClickHandler
|
||||
{
|
||||
Subject<PointerEventData> onPointerClick;
|
||||
|
||||
void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerClick != null) onPointerClick.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerClickAsObservable()
|
||||
{
|
||||
return onPointerClick ?? (onPointerClick = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onPointerClick != null)
|
||||
{
|
||||
onPointerClick.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa69c313aba23f945b760e79c45083ad
|
||||
timeCreated: 1455373900
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservablePointerDownTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerDownHandler
|
||||
{
|
||||
Subject<PointerEventData> onPointerDown;
|
||||
|
||||
void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerDown != null) onPointerDown.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerDownAsObservable()
|
||||
{
|
||||
return onPointerDown ?? (onPointerDown = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onPointerDown != null)
|
||||
{
|
||||
onPointerDown.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7ae5b5965df2344d99ef7792521b937
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservablePointerEnterTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerEnterHandler
|
||||
{
|
||||
Subject<PointerEventData> onPointerEnter;
|
||||
|
||||
void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerEnter != null) onPointerEnter.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerEnterAsObservable()
|
||||
{
|
||||
return onPointerEnter ?? (onPointerEnter = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onPointerEnter != null)
|
||||
{
|
||||
onPointerEnter.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3468b3db8d419c745b12124f6432696b
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservablePointerExitTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerExitHandler
|
||||
{
|
||||
Subject<PointerEventData> onPointerExit;
|
||||
|
||||
void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerExit != null) onPointerExit.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerExitAsObservable()
|
||||
{
|
||||
return onPointerExit ?? (onPointerExit = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onPointerExit != null)
|
||||
{
|
||||
onPointerExit.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9643e74593988274bbed9adf40384e48
|
||||
timeCreated: 1455373900
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservablePointerUpTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerUpHandler
|
||||
{
|
||||
Subject<PointerEventData> onPointerUp;
|
||||
|
||||
void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
if (onPointerUp != null) onPointerUp.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnPointerUpAsObservable()
|
||||
{
|
||||
return onPointerUp ?? (onPointerUp = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onPointerUp != null)
|
||||
{
|
||||
onPointerUp.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41b0031b2e409894aacafa49d8583617
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
// after uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableRectTransformTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> onRectTransformDimensionsChange;
|
||||
|
||||
// Callback that is sent if an associated RectTransform has it's dimensions changed
|
||||
void OnRectTransformDimensionsChange()
|
||||
{
|
||||
if (onRectTransformDimensionsChange != null) onRectTransformDimensionsChange.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>Callback that is sent if an associated RectTransform has it's dimensions changed.</summary>
|
||||
public IObservable<Unit> OnRectTransformDimensionsChangeAsObservable()
|
||||
{
|
||||
return onRectTransformDimensionsChange ?? (onRectTransformDimensionsChange = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onRectTransformRemoved;
|
||||
|
||||
// Callback that is sent if an associated RectTransform is removed
|
||||
void OnRectTransformRemoved()
|
||||
{
|
||||
if (onRectTransformRemoved != null) onRectTransformRemoved.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>Callback that is sent if an associated RectTransform is removed.</summary>
|
||||
public IObservable<Unit> OnRectTransformRemovedAsObservable()
|
||||
{
|
||||
return onRectTransformRemoved ?? (onRectTransformRemoved = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onRectTransformDimensionsChange != null)
|
||||
{
|
||||
onRectTransformDimensionsChange.OnCompleted();
|
||||
}
|
||||
if (onRectTransformRemoved != null)
|
||||
{
|
||||
onRectTransformRemoved.OnCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20b97bcdd98f27346851c3a690ec7faf
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableScrollTrigger : ObservableTriggerBase, IEventSystemHandler, IScrollHandler
|
||||
{
|
||||
Subject<PointerEventData> onScroll;
|
||||
|
||||
void IScrollHandler.OnScroll(PointerEventData eventData)
|
||||
{
|
||||
if (onScroll != null) onScroll.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<PointerEventData> OnScrollAsObservable()
|
||||
{
|
||||
return onScroll ?? (onScroll = new Subject<PointerEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onScroll != null)
|
||||
{
|
||||
onScroll.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2231ec04e488f7443ae7acf609ac5f00
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableSelectTrigger : ObservableTriggerBase, IEventSystemHandler, ISelectHandler
|
||||
{
|
||||
Subject<BaseEventData> onSelect;
|
||||
|
||||
void ISelectHandler.OnSelect(BaseEventData eventData)
|
||||
{
|
||||
if (onSelect != null) onSelect.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnSelectAsObservable()
|
||||
{
|
||||
return onSelect ?? (onSelect = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onSelect != null)
|
||||
{
|
||||
onSelect.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e4cb287d3ab8274885ed05748f26329
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,143 @@
|
||||
// over Unity5 added StateMachineBehaviour
|
||||
#if !(UNITY_4_7 || UNITY_4_6 || UNITY_4_5 || UNITY_4_4 || UNITY_4_3 || UNITY_4_2 || UNITY_4_1 || UNITY_4_0_1 || UNITY_4_0 || UNITY_3_5 || UNITY_3_4 || UNITY_3_3 || UNITY_3_2 || UNITY_3_1 || UNITY_3_0_0 || UNITY_3_0 || UNITY_2_6_1 || UNITY_2_6)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableStateMachineTrigger : StateMachineBehaviour
|
||||
{
|
||||
public class OnStateInfo
|
||||
{
|
||||
public Animator Animator { get; private set; }
|
||||
public AnimatorStateInfo StateInfo { get; private set; }
|
||||
public int LayerIndex { get; private set; }
|
||||
|
||||
public OnStateInfo(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
Animator = animator;
|
||||
StateInfo = stateInfo;
|
||||
LayerIndex = layerIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public class OnStateMachineInfo
|
||||
{
|
||||
public Animator Animator { get; private set; }
|
||||
public int StateMachinePathHash { get; private set; }
|
||||
|
||||
public OnStateMachineInfo(Animator animator, int stateMachinePathHash)
|
||||
{
|
||||
Animator = animator;
|
||||
StateMachinePathHash = stateMachinePathHash;
|
||||
}
|
||||
}
|
||||
|
||||
// OnStateExit
|
||||
|
||||
Subject<OnStateInfo> onStateExit;
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (onStateExit != null) onStateExit.OnNext(new OnStateInfo(animator, stateInfo, layerIndex));
|
||||
}
|
||||
|
||||
public IObservable<OnStateInfo> OnStateExitAsObservable()
|
||||
{
|
||||
return onStateExit ?? (onStateExit = new Subject<OnStateInfo>());
|
||||
}
|
||||
|
||||
// OnStateEnter
|
||||
|
||||
Subject<OnStateInfo> onStateEnter;
|
||||
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (onStateEnter != null) onStateEnter.OnNext(new OnStateInfo(animator, stateInfo, layerIndex));
|
||||
}
|
||||
|
||||
public IObservable<OnStateInfo> OnStateEnterAsObservable()
|
||||
{
|
||||
return onStateEnter ?? (onStateEnter = new Subject<OnStateInfo>());
|
||||
}
|
||||
|
||||
// OnStateIK
|
||||
|
||||
Subject<OnStateInfo> onStateIK;
|
||||
|
||||
public override void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if(onStateIK !=null) onStateIK.OnNext(new OnStateInfo(animator, stateInfo, layerIndex));
|
||||
}
|
||||
|
||||
public IObservable<OnStateInfo> OnStateIKAsObservable()
|
||||
{
|
||||
return onStateIK ?? (onStateIK = new Subject<OnStateInfo>());
|
||||
}
|
||||
|
||||
// Does not implments OnStateMove.
|
||||
// ObservableStateMachine Trigger makes stop animating.
|
||||
// By defining OnAnimatorMove, you are signifying that you want to intercept the movement of the root object and apply it yourself.
|
||||
// http://fogbugz.unity3d.com/default.asp?700990_9jqaim4ev33i8e9h
|
||||
|
||||
//// OnStateMove
|
||||
|
||||
//Subject<OnStateInfo> onStateMove;
|
||||
|
||||
//public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
//{
|
||||
// if (onStateMove != null) onStateMove.OnNext(new OnStateInfo(animator, stateInfo, layerIndex));
|
||||
//}
|
||||
|
||||
//public IObservable<OnStateInfo> OnStateMoveAsObservable()
|
||||
//{
|
||||
// return onStateMove ?? (onStateMove = new Subject<OnStateInfo>());
|
||||
//}
|
||||
|
||||
// OnStateUpdate
|
||||
|
||||
Subject<OnStateInfo> onStateUpdate;
|
||||
|
||||
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
if (onStateUpdate != null) onStateUpdate.OnNext(new OnStateInfo(animator, stateInfo, layerIndex));
|
||||
}
|
||||
|
||||
public IObservable<OnStateInfo> OnStateUpdateAsObservable()
|
||||
{
|
||||
return onStateUpdate ?? (onStateUpdate = new Subject<OnStateInfo>());
|
||||
}
|
||||
|
||||
// OnStateMachineEnter
|
||||
|
||||
Subject<OnStateMachineInfo> onStateMachineEnter;
|
||||
|
||||
public override void OnStateMachineEnter(Animator animator, int stateMachinePathHash)
|
||||
{
|
||||
if (onStateMachineEnter != null) onStateMachineEnter.OnNext(new OnStateMachineInfo(animator, stateMachinePathHash));
|
||||
}
|
||||
|
||||
public IObservable<OnStateMachineInfo> OnStateMachineEnterAsObservable()
|
||||
{
|
||||
return onStateMachineEnter ?? (onStateMachineEnter = new Subject<OnStateMachineInfo>());
|
||||
}
|
||||
|
||||
// OnStateMachineExit
|
||||
|
||||
Subject<OnStateMachineInfo> onStateMachineExit;
|
||||
|
||||
public override void OnStateMachineExit(Animator animator, int stateMachinePathHash)
|
||||
{
|
||||
if (onStateMachineExit != null) onStateMachineExit.OnNext(new OnStateMachineInfo(animator, stateMachinePathHash));
|
||||
}
|
||||
|
||||
public IObservable<OnStateMachineInfo> OnStateMachineExitAsObservable()
|
||||
{
|
||||
return onStateMachineExit ?? (onStateMachineExit = new Subject<OnStateMachineInfo>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e29959e46c7ea7409560769cde085ae
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableSubmitTrigger : ObservableTriggerBase, IEventSystemHandler, ISubmitHandler
|
||||
{
|
||||
Subject<BaseEventData> onSubmit;
|
||||
|
||||
void ISubmitHandler.OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
if (onSubmit != null) onSubmit.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnSubmitAsObservable()
|
||||
{
|
||||
return onSubmit ?? (onSubmit = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onSubmit != null)
|
||||
{
|
||||
onSubmit.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 655296fedabd6004ab699ab9749e369c
|
||||
timeCreated: 1455373899
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
// after uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableTransformChangedTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> onBeforeTransformParentChanged;
|
||||
|
||||
// Callback sent to the graphic before a Transform parent change occurs
|
||||
void OnBeforeTransformParentChanged()
|
||||
{
|
||||
if (onBeforeTransformParentChanged != null) onBeforeTransformParentChanged.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>Callback sent to the graphic before a Transform parent change occurs.</summary>
|
||||
public IObservable<Unit> OnBeforeTransformParentChangedAsObservable()
|
||||
{
|
||||
return onBeforeTransformParentChanged ?? (onBeforeTransformParentChanged = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> 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);
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the parent property of the transform of the GameObject has changed.</summary>
|
||||
public IObservable<Unit> OnTransformParentChangedAsObservable()
|
||||
{
|
||||
return onTransformParentChanged ?? (onTransformParentChanged = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> 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);
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the list of children of the transform of the GameObject has changed.</summary>
|
||||
public IObservable<Unit> OnTransformChildrenChangedAsObservable()
|
||||
{
|
||||
return onTransformChildrenChanged ?? (onTransformChildrenChanged = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onBeforeTransformParentChanged != null)
|
||||
{
|
||||
onBeforeTransformParentChanged.OnCompleted();
|
||||
}
|
||||
if (onTransformParentChanged != null)
|
||||
{
|
||||
onTransformParentChanged.OnCompleted();
|
||||
}
|
||||
if (onTransformChildrenChanged != null)
|
||||
{
|
||||
onTransformChildrenChanged.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 835e244a602942c4c84a09c9bdedf229
|
||||
timeCreated: 1455373899
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableTrigger2DTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Collider2D> onTriggerEnter2D;
|
||||
|
||||
/// <summary>Sent when another object enters a trigger collider attached to this object (2D physics only).</summary>
|
||||
void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (onTriggerEnter2D != null) onTriggerEnter2D.OnNext(other);
|
||||
}
|
||||
|
||||
/// <summary>Sent when another object enters a trigger collider attached to this object (2D physics only).</summary>
|
||||
public IObservable<Collider2D> OnTriggerEnter2DAsObservable()
|
||||
{
|
||||
return onTriggerEnter2D ?? (onTriggerEnter2D = new Subject<Collider2D>());
|
||||
}
|
||||
|
||||
Subject<Collider2D> onTriggerExit2D;
|
||||
|
||||
/// <summary>Sent when another object leaves a trigger collider attached to this object (2D physics only).</summary>
|
||||
void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (onTriggerExit2D != null) onTriggerExit2D.OnNext(other);
|
||||
}
|
||||
|
||||
/// <summary>Sent when another object leaves a trigger collider attached to this object (2D physics only).</summary>
|
||||
public IObservable<Collider2D> OnTriggerExit2DAsObservable()
|
||||
{
|
||||
return onTriggerExit2D ?? (onTriggerExit2D = new Subject<Collider2D>());
|
||||
}
|
||||
|
||||
Subject<Collider2D> onTriggerStay2D;
|
||||
|
||||
/// <summary>Sent each frame where another object is within a trigger collider attached to this object (2D physics only).</summary>
|
||||
void OnTriggerStay2D(Collider2D other)
|
||||
{
|
||||
if (onTriggerStay2D != null) onTriggerStay2D.OnNext(other);
|
||||
}
|
||||
|
||||
/// <summary>Sent each frame where another object is within a trigger collider attached to this object (2D physics only).</summary>
|
||||
public IObservable<Collider2D> OnTriggerStay2DAsObservable()
|
||||
{
|
||||
return onTriggerStay2D ?? (onTriggerStay2D = new Subject<Collider2D>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onTriggerEnter2D != null)
|
||||
{
|
||||
onTriggerEnter2D.OnCompleted();
|
||||
}
|
||||
if (onTriggerExit2D != null)
|
||||
{
|
||||
onTriggerExit2D.OnCompleted();
|
||||
}
|
||||
if (onTriggerStay2D != null)
|
||||
{
|
||||
onTriggerStay2D.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1aad3129752ef804999a880a7b2d72ef
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
public abstract class ObservableTriggerBase : MonoBehaviour
|
||||
{
|
||||
bool calledAwake = false;
|
||||
Subject<Unit> awake;
|
||||
|
||||
/// <summary>Awake is called when the script instance is being loaded.</summary>
|
||||
void Awake()
|
||||
{
|
||||
calledAwake = true;
|
||||
if (awake != null) { awake.OnNext(Unit.Default); awake.OnCompleted(); }
|
||||
}
|
||||
|
||||
/// <summary>Awake is called when the script instance is being loaded.</summary>
|
||||
public IObservable<Unit> AwakeAsObservable()
|
||||
{
|
||||
if (calledAwake) return Observable.Return(Unit.Default);
|
||||
return awake ?? (awake = new Subject<Unit>());
|
||||
}
|
||||
|
||||
bool calledStart = false;
|
||||
Subject<Unit> start;
|
||||
|
||||
/// <summary>Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.</summary>
|
||||
void Start()
|
||||
{
|
||||
calledStart = true;
|
||||
if (start != null) { start.OnNext(Unit.Default); start.OnCompleted(); }
|
||||
}
|
||||
|
||||
/// <summary>Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.</summary>
|
||||
public IObservable<Unit> StartAsObservable()
|
||||
{
|
||||
if (calledStart) return Observable.Return(Unit.Default);
|
||||
return start ?? (start = new Subject<Unit>());
|
||||
}
|
||||
|
||||
|
||||
bool calledDestroy = false;
|
||||
Subject<Unit> onDestroy;
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
void OnDestroy()
|
||||
{
|
||||
calledDestroy = true;
|
||||
if (onDestroy != null) { onDestroy.OnNext(Unit.Default); onDestroy.OnCompleted(); }
|
||||
|
||||
RaiseOnCompletedOnDestroy();
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
public IObservable<Unit> OnDestroyAsObservable()
|
||||
{
|
||||
if (this == null) return Observable.Return(Unit.Default);
|
||||
if (calledDestroy) return Observable.Return(Unit.Default);
|
||||
return onDestroy ?? (onDestroy = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected abstract void RaiseOnCompletedOnDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 850bc951297608e4fb0722795c21ed16
|
||||
timeCreated: 1455373900
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,461 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
using UnityEngine.EventSystems;
|
||||
#endif
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
// for Component
|
||||
public static partial class ObservableTriggerExtensions
|
||||
{
|
||||
#region ObservableAnimatorTrigger
|
||||
|
||||
/// <summary>Callback for setting up animation IK (inverse kinematics).</summary>
|
||||
public static IObservable<int> OnAnimatorIKAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<int>();
|
||||
return GetOrAddComponent<ObservableAnimatorTrigger>(component.gameObject).OnAnimatorIKAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>Callback for processing animation movements for modifying root motion.</summary>
|
||||
public static IObservable<Unit> OnAnimatorMoveAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableAnimatorTrigger>(component.gameObject).OnAnimatorMoveAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableCollision2DTrigger
|
||||
|
||||
/// <summary>Sent when an incoming collider makes contact with this object's collider (2D physics only).</summary>
|
||||
public static IObservable<Collision2D> OnCollisionEnter2DAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collision2D>();
|
||||
return GetOrAddComponent<ObservableCollision2DTrigger>(component.gameObject).OnCollisionEnter2DAsObservable();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Sent when a collider on another object stops touching this object's collider (2D physics only).</summary>
|
||||
public static IObservable<Collision2D> OnCollisionExit2DAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collision2D>();
|
||||
return GetOrAddComponent<ObservableCollision2DTrigger>(component.gameObject).OnCollisionExit2DAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>Sent each frame where a collider on another object is touching this object's collider (2D physics only).</summary>
|
||||
public static IObservable<Collision2D> OnCollisionStay2DAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collision2D>();
|
||||
return GetOrAddComponent<ObservableCollision2DTrigger>(component.gameObject).OnCollisionStay2DAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableCollisionTrigger
|
||||
|
||||
/// <summary>OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.</summary>
|
||||
public static IObservable<Collision> OnCollisionEnterAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collision>();
|
||||
return GetOrAddComponent<ObservableCollisionTrigger>(component.gameObject).OnCollisionEnterAsObservable();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.</summary>
|
||||
public static IObservable<Collision> OnCollisionExitAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collision>();
|
||||
return GetOrAddComponent<ObservableCollisionTrigger>(component.gameObject).OnCollisionExitAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.</summary>
|
||||
public static IObservable<Collision> OnCollisionStayAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collision>();
|
||||
return GetOrAddComponent<ObservableCollisionTrigger>(component.gameObject).OnCollisionStayAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableDestroyTrigger
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
public static IObservable<Unit> 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
|
||||
|
||||
/// <summary>This function is called when the object becomes enabled and active.</summary>
|
||||
public static IObservable<Unit> OnEnableAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableEnableTrigger>(component.gameObject).OnEnableAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the behaviour becomes disabled () or inactive.</summary>
|
||||
public static IObservable<Unit> OnDisableAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableEnableTrigger>(component.gameObject).OnDisableAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableFixedUpdateTrigger
|
||||
|
||||
/// <summary>This function is called every fixed framerate frame, if the MonoBehaviour is enabled.</summary>
|
||||
public static IObservable<Unit> FixedUpdateAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableFixedUpdateTrigger>(component.gameObject).FixedUpdateAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableLateUpdateTrigger
|
||||
|
||||
/// <summary>LateUpdate is called every frame, if the Behaviour is enabled.</summary>
|
||||
public static IObservable<Unit> LateUpdateAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableLateUpdateTrigger>(component.gameObject).LateUpdateAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO)
|
||||
|
||||
#region ObservableMouseTrigger
|
||||
|
||||
/// <summary>OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider.</summary>
|
||||
public static IObservable<Unit> OnMouseDownAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(component.gameObject).OnMouseDownAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse.</summary>
|
||||
public static IObservable<Unit> OnMouseDragAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(component.gameObject).OnMouseDragAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseEnter is called when the mouse entered the GUIElement or Collider.</summary>
|
||||
public static IObservable<Unit> OnMouseEnterAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(component.gameObject).OnMouseEnterAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider.</summary>
|
||||
public static IObservable<Unit> OnMouseExitAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(component.gameObject).OnMouseExitAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseOver is called every frame while the mouse is over the GUIElement or Collider.</summary>
|
||||
public static IObservable<Unit> OnMouseOverAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(component.gameObject).OnMouseOverAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseUp is called when the user has released the mouse button.</summary>
|
||||
public static IObservable<Unit> OnMouseUpAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(component.gameObject).OnMouseUpAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed.</summary>
|
||||
public static IObservable<Unit> OnMouseUpAsButtonAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(component.gameObject).OnMouseUpAsButtonAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endif
|
||||
|
||||
#region ObservableTrigger2DTrigger
|
||||
|
||||
/// <summary>Sent when another object enters a trigger collider attached to this object (2D physics only).</summary>
|
||||
public static IObservable<Collider2D> OnTriggerEnter2DAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collider2D>();
|
||||
return GetOrAddComponent<ObservableTrigger2DTrigger>(component.gameObject).OnTriggerEnter2DAsObservable();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Sent when another object leaves a trigger collider attached to this object (2D physics only).</summary>
|
||||
public static IObservable<Collider2D> OnTriggerExit2DAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collider2D>();
|
||||
return GetOrAddComponent<ObservableTrigger2DTrigger>(component.gameObject).OnTriggerExit2DAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>Sent each frame where another object is within a trigger collider attached to this object (2D physics only).</summary>
|
||||
public static IObservable<Collider2D> OnTriggerStay2DAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collider2D>();
|
||||
return GetOrAddComponent<ObservableTrigger2DTrigger>(component.gameObject).OnTriggerStay2DAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableTriggerTrigger
|
||||
|
||||
/// <summary>OnTriggerEnter is called when the Collider other enters the trigger.</summary>
|
||||
public static IObservable<Collider> OnTriggerEnterAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collider>();
|
||||
return GetOrAddComponent<ObservableTriggerTrigger>(component.gameObject).OnTriggerEnterAsObservable();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>OnTriggerExit is called when the Collider other has stopped touching the trigger.</summary>
|
||||
public static IObservable<Collider> OnTriggerExitAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collider>();
|
||||
return GetOrAddComponent<ObservableTriggerTrigger>(component.gameObject).OnTriggerExitAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnTriggerStay is called once per frame for every Collider other that is touching the trigger.</summary>
|
||||
public static IObservable<Collider> OnTriggerStayAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Collider>();
|
||||
return GetOrAddComponent<ObservableTriggerTrigger>(component.gameObject).OnTriggerStayAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableUpdateTrigger
|
||||
|
||||
/// <summary>Update is called every frame, if the MonoBehaviour is enabled.</summary>
|
||||
public static IObservable<Unit> UpdateAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableUpdateTrigger>(component.gameObject).UpdateAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableVisibleTrigger
|
||||
|
||||
/// <summary>OnBecameInvisible is called when the renderer is no longer visible by any camera.</summary>
|
||||
public static IObservable<Unit> OnBecameInvisibleAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableVisibleTrigger>(component.gameObject).OnBecameInvisibleAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnBecameVisible is called when the renderer became visible by any camera.</summary>
|
||||
public static IObservable<Unit> OnBecameVisibleAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableVisibleTrigger>(component.gameObject).OnBecameVisibleAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
#region ObservableTransformChangedTrigger
|
||||
|
||||
/// <summary>Callback sent to the graphic before a Transform parent change occurs.</summary>
|
||||
public static IObservable<Unit> OnBeforeTransformParentChangedAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableTransformChangedTrigger>(component.gameObject).OnBeforeTransformParentChangedAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the parent property of the transform of the GameObject has changed.</summary>
|
||||
public static IObservable<Unit> OnTransformParentChangedAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableTransformChangedTrigger>(component.gameObject).OnTransformParentChangedAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the list of children of the transform of the GameObject has changed.</summary>
|
||||
public static IObservable<Unit> OnTransformChildrenChangedAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableTransformChangedTrigger>(component.gameObject).OnTransformChildrenChangedAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableCanvasGroupChangedTrigger
|
||||
|
||||
/// <summary>Callback that is sent if the canvas group is changed.</summary>
|
||||
public static IObservable<Unit> OnCanvasGroupChangedAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableCanvasGroupChangedTrigger>(component.gameObject).OnCanvasGroupChangedAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableRectTransformTrigger
|
||||
|
||||
/// <summary>Callback that is sent if an associated RectTransform has it's dimensions changed.</summary>
|
||||
public static IObservable<Unit> OnRectTransformDimensionsChangeAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableRectTransformTrigger>(component.gameObject).OnRectTransformDimensionsChangeAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>Callback that is sent if an associated RectTransform is removed.</summary>
|
||||
public static IObservable<Unit> OnRectTransformRemovedAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableRectTransformTrigger>(component.gameObject).OnRectTransformRemovedAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// uGUI
|
||||
|
||||
#region ObservableEventTrigger classes
|
||||
|
||||
public static IObservable<BaseEventData> OnDeselectAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<BaseEventData>();
|
||||
return GetOrAddComponent<ObservableDeselectTrigger>(component.gameObject).OnDeselectAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<AxisEventData> OnMoveAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<AxisEventData>();
|
||||
return GetOrAddComponent<ObservableMoveTrigger>(component.gameObject).OnMoveAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnPointerDownAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservablePointerDownTrigger>(component.gameObject).OnPointerDownAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnPointerEnterAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservablePointerEnterTrigger>(component.gameObject).OnPointerEnterAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnPointerExitAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservablePointerExitTrigger>(component.gameObject).OnPointerExitAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnPointerUpAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservablePointerUpTrigger>(component.gameObject).OnPointerUpAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<BaseEventData> OnSelectAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<BaseEventData>();
|
||||
return GetOrAddComponent<ObservableSelectTrigger>(component.gameObject).OnSelectAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnPointerClickAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservablePointerClickTrigger>(component.gameObject).OnPointerClickAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<BaseEventData> OnSubmitAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<BaseEventData>();
|
||||
return GetOrAddComponent<ObservableSubmitTrigger>(component.gameObject).OnSubmitAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnDragAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservableDragTrigger>(component.gameObject).OnDragAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnBeginDragAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservableBeginDragTrigger>(component.gameObject).OnBeginDragAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnEndDragAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservableEndDragTrigger>(component.gameObject).OnEndDragAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnDropAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservableDropTrigger>(component.gameObject).OnDropAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<BaseEventData> OnUpdateSelectedAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<BaseEventData>();
|
||||
return GetOrAddComponent<ObservableUpdateSelectedTrigger>(component.gameObject).OnUpdateSelectedAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnInitializePotentialDragAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservableInitializePotentialDragTrigger>(component.gameObject).OnInitializePotentialDragAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<BaseEventData> OnCancelAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<BaseEventData>();
|
||||
return GetOrAddComponent<ObservableCancelTrigger>(component.gameObject).OnCancelAsObservable();
|
||||
}
|
||||
|
||||
public static IObservable<PointerEventData> OnScrollAsObservable(this UIBehaviour component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<PointerEventData>();
|
||||
return GetOrAddComponent<ObservableScrollTrigger>(component.gameObject).OnScrollAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endif
|
||||
|
||||
#region ObservableParticleTrigger
|
||||
|
||||
/// <summary>OnParticleCollision is called when a particle hits a collider.</summary>
|
||||
public static IObservable<GameObject> OnParticleCollisionAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<GameObject>();
|
||||
return GetOrAddComponent<ObservableParticleTrigger>(component.gameObject).OnParticleCollisionAsObservable();
|
||||
}
|
||||
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
|
||||
/// <summary>OnParticleTrigger is called when any particles in a particle system meet the conditions in the trigger module.</summary>
|
||||
public static IObservable<Unit> OnParticleTriggerAsObservable(this Component component)
|
||||
{
|
||||
if (component == null || component.gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableParticleTrigger>(component.gameObject).OnParticleTriggerAsObservable();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d10150b3ca6f3924baae5bce4343f6c4
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,361 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
// for GameObject
|
||||
public static partial class ObservableTriggerExtensions
|
||||
{
|
||||
#region ObservableAnimatorTrigger
|
||||
|
||||
/// <summary>Callback for setting up animation IK (inverse kinematics).</summary>
|
||||
public static IObservable<int> OnAnimatorIKAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<int>();
|
||||
return GetOrAddComponent<ObservableAnimatorTrigger>(gameObject).OnAnimatorIKAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>Callback for processing animation movements for modifying root motion.</summary>
|
||||
public static IObservable<Unit> OnAnimatorMoveAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableAnimatorTrigger>(gameObject).OnAnimatorMoveAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableCollision2DTrigger
|
||||
|
||||
/// <summary>Sent when an incoming collider makes contact with this object's collider (2D physics only).</summary>
|
||||
public static IObservable<Collision2D> OnCollisionEnter2DAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collision2D>();
|
||||
return GetOrAddComponent<ObservableCollision2DTrigger>(gameObject).OnCollisionEnter2DAsObservable();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Sent when a collider on another object stops touching this object's collider (2D physics only).</summary>
|
||||
public static IObservable<Collision2D> OnCollisionExit2DAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collision2D>();
|
||||
return GetOrAddComponent<ObservableCollision2DTrigger>(gameObject).OnCollisionExit2DAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>Sent each frame where a collider on another object is touching this object's collider (2D physics only).</summary>
|
||||
public static IObservable<Collision2D> OnCollisionStay2DAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collision2D>();
|
||||
return GetOrAddComponent<ObservableCollision2DTrigger>(gameObject).OnCollisionStay2DAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableCollisionTrigger
|
||||
|
||||
/// <summary>OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.</summary>
|
||||
public static IObservable<Collision> OnCollisionEnterAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collision>();
|
||||
return GetOrAddComponent<ObservableCollisionTrigger>(gameObject).OnCollisionEnterAsObservable();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.</summary>
|
||||
public static IObservable<Collision> OnCollisionExitAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collision>();
|
||||
return GetOrAddComponent<ObservableCollisionTrigger>(gameObject).OnCollisionExitAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.</summary>
|
||||
public static IObservable<Collision> OnCollisionStayAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collision>();
|
||||
return GetOrAddComponent<ObservableCollisionTrigger>(gameObject).OnCollisionStayAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableDestroyTrigger
|
||||
|
||||
/// <summary>This function is called when the MonoBehaviour will be destroyed.</summary>
|
||||
public static IObservable<Unit> OnDestroyAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Return(Unit.Default); // send destroy message
|
||||
return GetOrAddComponent<ObservableDestroyTrigger>(gameObject).OnDestroyAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ObservableEnableTrigger
|
||||
|
||||
/// <summary>This function is called when the object becomes enabled and active.</summary>
|
||||
public static IObservable<Unit> OnEnableAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableEnableTrigger>(gameObject).OnEnableAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the behaviour becomes disabled () or inactive.</summary>
|
||||
public static IObservable<Unit> OnDisableAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableEnableTrigger>(gameObject).OnDisableAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableFixedUpdateTrigger
|
||||
|
||||
/// <summary>This function is called every fixed framerate frame, if the MonoBehaviour is enabled.</summary>
|
||||
public static IObservable<Unit> FixedUpdateAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableFixedUpdateTrigger>(gameObject).FixedUpdateAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableLateUpdateTrigger
|
||||
|
||||
/// <summary>LateUpdate is called every frame, if the Behaviour is enabled.</summary>
|
||||
public static IObservable<Unit> LateUpdateAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableLateUpdateTrigger>(gameObject).LateUpdateAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO)
|
||||
|
||||
#region ObservableMouseTrigger
|
||||
|
||||
/// <summary>OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider.</summary>
|
||||
public static IObservable<Unit> OnMouseDownAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(gameObject).OnMouseDownAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse.</summary>
|
||||
public static IObservable<Unit> OnMouseDragAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(gameObject).OnMouseDragAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseEnter is called when the mouse entered the GUIElement or Collider.</summary>
|
||||
public static IObservable<Unit> OnMouseEnterAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(gameObject).OnMouseEnterAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseExit is called when the mouse is not any longer over the GUIElement or Collider.</summary>
|
||||
public static IObservable<Unit> OnMouseExitAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(gameObject).OnMouseExitAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseOver is called every frame while the mouse is over the GUIElement or Collider.</summary>
|
||||
public static IObservable<Unit> OnMouseOverAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(gameObject).OnMouseOverAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseUp is called when the user has released the mouse button.</summary>
|
||||
public static IObservable<Unit> OnMouseUpAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(gameObject).OnMouseUpAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed.</summary>
|
||||
public static IObservable<Unit> OnMouseUpAsButtonAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableMouseTrigger>(gameObject).OnMouseUpAsButtonAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endif
|
||||
|
||||
#region ObservableTrigger2DTrigger
|
||||
|
||||
/// <summary>Sent when another object enters a trigger collider attached to this object (2D physics only).</summary>
|
||||
public static IObservable<Collider2D> OnTriggerEnter2DAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collider2D>();
|
||||
return GetOrAddComponent<ObservableTrigger2DTrigger>(gameObject).OnTriggerEnter2DAsObservable();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Sent when another object leaves a trigger collider attached to this object (2D physics only).</summary>
|
||||
public static IObservable<Collider2D> OnTriggerExit2DAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collider2D>();
|
||||
return GetOrAddComponent<ObservableTrigger2DTrigger>(gameObject).OnTriggerExit2DAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>Sent each frame where another object is within a trigger collider attached to this object (2D physics only).</summary>
|
||||
public static IObservable<Collider2D> OnTriggerStay2DAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collider2D>();
|
||||
return GetOrAddComponent<ObservableTrigger2DTrigger>(gameObject).OnTriggerStay2DAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableTriggerTrigger
|
||||
|
||||
/// <summary>OnTriggerEnter is called when the Collider other enters the trigger.</summary>
|
||||
public static IObservable<Collider> OnTriggerEnterAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collider>();
|
||||
return GetOrAddComponent<ObservableTriggerTrigger>(gameObject).OnTriggerEnterAsObservable();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>OnTriggerExit is called when the Collider other has stopped touching the trigger.</summary>
|
||||
public static IObservable<Collider> OnTriggerExitAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collider>();
|
||||
return GetOrAddComponent<ObservableTriggerTrigger>(gameObject).OnTriggerExitAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnTriggerStay is called once per frame for every Collider other that is touching the trigger.</summary>
|
||||
public static IObservable<Collider> OnTriggerStayAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Collider>();
|
||||
return GetOrAddComponent<ObservableTriggerTrigger>(gameObject).OnTriggerStayAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableUpdateTrigger
|
||||
|
||||
/// <summary>Update is called every frame, if the MonoBehaviour is enabled.</summary>
|
||||
public static IObservable<Unit> UpdateAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableUpdateTrigger>(gameObject).UpdateAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableVisibleTrigger
|
||||
|
||||
/// <summary>OnBecameInvisible is called when the renderer is no longer visible by any camera.</summary>
|
||||
public static IObservable<Unit> OnBecameInvisibleAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableVisibleTrigger>(gameObject).OnBecameInvisibleAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>OnBecameVisible is called when the renderer became visible by any camera.</summary>
|
||||
public static IObservable<Unit> OnBecameVisibleAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableVisibleTrigger>(gameObject).OnBecameVisibleAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
#region ObservableTransformChangedTrigger
|
||||
|
||||
/// <summary>Callback sent to the graphic before a Transform parent change occurs.</summary>
|
||||
public static IObservable<Unit> OnBeforeTransformParentChangedAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableTransformChangedTrigger>(gameObject).OnBeforeTransformParentChangedAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the parent property of the transform of the GameObject has changed.</summary>
|
||||
public static IObservable<Unit> OnTransformParentChangedAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableTransformChangedTrigger>(gameObject).OnTransformParentChangedAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the list of children of the transform of the GameObject has changed.</summary>
|
||||
public static IObservable<Unit> OnTransformChildrenChangedAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableTransformChangedTrigger>(gameObject).OnTransformChildrenChangedAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableCanvasGroupChangedTrigger
|
||||
|
||||
/// <summary>Callback that is sent if the canvas group is changed.</summary>
|
||||
public static IObservable<Unit> OnCanvasGroupChangedAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableCanvasGroupChangedTrigger>(gameObject).OnCanvasGroupChangedAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ObservableRectTransformTrigger
|
||||
|
||||
/// <summary>Callback that is sent if an associated RectTransform has it's dimensions changed.</summary>
|
||||
public static IObservable<Unit> OnRectTransformDimensionsChangeAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableRectTransformTrigger>(gameObject).OnRectTransformDimensionsChangeAsObservable();
|
||||
}
|
||||
|
||||
/// <summary>Callback that is sent if an associated RectTransform is removed.</summary>
|
||||
public static IObservable<Unit> OnRectTransformRemovedAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableRectTransformTrigger>(gameObject).OnRectTransformRemovedAsObservable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#region ObservableParticleTrigger
|
||||
|
||||
/// <summary>OnParticleCollision is called when a particle hits a collider.</summary>
|
||||
public static IObservable<GameObject> OnParticleCollisionAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<GameObject>();
|
||||
return GetOrAddComponent<ObservableParticleTrigger>(gameObject).OnParticleCollisionAsObservable();
|
||||
}
|
||||
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
|
||||
/// <summary>OnParticleTrigger is called when any particles in a particle system meet the conditions in the trigger module.</summary>
|
||||
public static IObservable<Unit> OnParticleTriggerAsObservable(this GameObject gameObject)
|
||||
{
|
||||
if (gameObject == null) return Observable.Empty<Unit>();
|
||||
return GetOrAddComponent<ObservableParticleTrigger>(gameObject).OnParticleTriggerAsObservable();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
static T GetOrAddComponent<T>(GameObject gameObject)
|
||||
where T : Component
|
||||
{
|
||||
var component = gameObject.GetComponent<T>();
|
||||
if (component == null)
|
||||
{
|
||||
component = gameObject.AddComponent<T>();
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ee4df960144b9042874516111cf2d6c
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableTriggerTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Collider> onTriggerEnter;
|
||||
|
||||
/// <summary>OnTriggerEnter is called when the Collider other enters the trigger.</summary>
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (onTriggerEnter != null) onTriggerEnter.OnNext(other);
|
||||
}
|
||||
|
||||
/// <summary>OnTriggerEnter is called when the Collider other enters the trigger.</summary>
|
||||
public IObservable<Collider> OnTriggerEnterAsObservable()
|
||||
{
|
||||
return onTriggerEnter ?? (onTriggerEnter = new Subject<Collider>());
|
||||
}
|
||||
|
||||
Subject<Collider> onTriggerExit;
|
||||
|
||||
/// <summary>OnTriggerExit is called when the Collider other has stopped touching the trigger.</summary>
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (onTriggerExit != null) onTriggerExit.OnNext(other);
|
||||
}
|
||||
|
||||
/// <summary>OnTriggerExit is called when the Collider other has stopped touching the trigger.</summary>
|
||||
public IObservable<Collider> OnTriggerExitAsObservable()
|
||||
{
|
||||
return onTriggerExit ?? (onTriggerExit = new Subject<Collider>());
|
||||
}
|
||||
|
||||
Subject<Collider> onTriggerStay;
|
||||
|
||||
/// <summary>OnTriggerStay is called once per frame for every Collider other that is touching the trigger.</summary>
|
||||
void OnTriggerStay(Collider other)
|
||||
{
|
||||
if (onTriggerStay != null) onTriggerStay.OnNext(other);
|
||||
}
|
||||
|
||||
/// <summary>OnTriggerStay is called once per frame for every Collider other that is touching the trigger.</summary>
|
||||
public IObservable<Collider> OnTriggerStayAsObservable()
|
||||
{
|
||||
return onTriggerStay ?? (onTriggerStay = new Subject<Collider>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onTriggerEnter != null)
|
||||
{
|
||||
onTriggerEnter.OnCompleted();
|
||||
}
|
||||
if (onTriggerExit != null)
|
||||
{
|
||||
onTriggerExit.OnCompleted();
|
||||
}
|
||||
if (onTriggerStay != null)
|
||||
{
|
||||
onTriggerStay.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cadcfd987fed8a044b75709fc19ad0f7
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
// for uGUI(from 4.6)
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
|
||||
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableUpdateSelectedTrigger : ObservableTriggerBase, IEventSystemHandler, IUpdateSelectedHandler
|
||||
{
|
||||
Subject<BaseEventData> onUpdateSelected;
|
||||
|
||||
void IUpdateSelectedHandler.OnUpdateSelected(BaseEventData eventData)
|
||||
{
|
||||
if (onUpdateSelected != null) onUpdateSelected.OnNext(eventData);
|
||||
}
|
||||
|
||||
public IObservable<BaseEventData> OnUpdateSelectedAsObservable()
|
||||
{
|
||||
return onUpdateSelected ?? (onUpdateSelected = new Subject<BaseEventData>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onUpdateSelected != null)
|
||||
{
|
||||
onUpdateSelected.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d207a04db328fd4d970c1457530deb3
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableUpdateTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> update;
|
||||
|
||||
/// <summary>Update is called every frame, if the MonoBehaviour is enabled.</summary>
|
||||
void Update()
|
||||
{
|
||||
if (update != null) update.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>Update is called every frame, if the MonoBehaviour is enabled.</summary>
|
||||
public IObservable<Unit> UpdateAsObservable()
|
||||
{
|
||||
return update ?? (update = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (update != null)
|
||||
{
|
||||
update.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ceb5e5014f40d6948815a7be8b174ff2
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableVisibleTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> onBecameInvisible;
|
||||
|
||||
/// <summary>OnBecameInvisible is called when the renderer is no longer visible by any camera.</summary>
|
||||
void OnBecameInvisible()
|
||||
{
|
||||
if (onBecameInvisible != null) onBecameInvisible.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnBecameInvisible is called when the renderer is no longer visible by any camera.</summary>
|
||||
public IObservable<Unit> OnBecameInvisibleAsObservable()
|
||||
{
|
||||
return onBecameInvisible ?? (onBecameInvisible = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onBecameVisible;
|
||||
|
||||
/// <summary>OnBecameVisible is called when the renderer became visible by any camera.</summary>
|
||||
void OnBecameVisible()
|
||||
{
|
||||
if (onBecameVisible != null) onBecameVisible.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>OnBecameVisible is called when the renderer became visible by any camera.</summary>
|
||||
public IObservable<Unit> OnBecameVisibleAsObservable()
|
||||
{
|
||||
return onBecameVisible ?? (onBecameVisible = new Subject<Unit>());
|
||||
}
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onBecameInvisible != null)
|
||||
{
|
||||
onBecameInvisible.OnCompleted();
|
||||
}
|
||||
if (onBecameVisible != null)
|
||||
{
|
||||
onBecameVisible.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03515121745b2d74c8782ce92eb2a1a0
|
||||
timeCreated: 1455373897
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user