架构大更
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
using System; // require keep for Windows Universal App
|
||||
using System;
|
||||
using UnityEngine;
|
||||
// require keep for Windows Universal App
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableEnableTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> onEnable;
|
||||
private Subject<Unit> onDisable;
|
||||
private Subject<Unit> onEnable;
|
||||
|
||||
/// <summary>This function is called when the object becomes enabled and active.</summary>
|
||||
void OnEnable()
|
||||
private void OnEnable()
|
||||
{
|
||||
if (onEnable != null) onEnable.OnNext(Unit.Default);
|
||||
}
|
||||
|
||||
/// <summary>This function is called when the behaviour becomes disabled () or inactive.</summary>
|
||||
private void OnDisable()
|
||||
{
|
||||
if (onDisable != null) onDisable.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()
|
||||
{
|
||||
@@ -36,14 +36,8 @@ namespace UniRx.Triggers
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onEnable != null)
|
||||
{
|
||||
onEnable.OnCompleted();
|
||||
}
|
||||
if (onDisable != null)
|
||||
{
|
||||
onDisable.OnCompleted();
|
||||
}
|
||||
if (onEnable != null) onEnable.OnCompleted();
|
||||
if (onDisable != null) onDisable.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,18 @@
|
||||
// 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 System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
// require keep for Windows Universal App
|
||||
|
||||
namespace UniRx.Triggers
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservablePointerDownTrigger : ObservableTriggerBase, IEventSystemHandler, IPointerDownHandler
|
||||
{
|
||||
Subject<PointerEventData> onPointerDown;
|
||||
private Subject<PointerEventData> onPointerDown;
|
||||
|
||||
void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
@@ -24,10 +26,7 @@ namespace UniRx.Triggers
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onPointerDown != null)
|
||||
{
|
||||
onPointerDown.OnCompleted();
|
||||
}
|
||||
if (onPointerDown != null) onPointerDown.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// 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;
|
||||
@@ -9,10 +10,12 @@ namespace UniRx.Triggers
|
||||
[DisallowMultipleComponent]
|
||||
public class ObservableRectTransformTrigger : ObservableTriggerBase
|
||||
{
|
||||
Subject<Unit> onRectTransformDimensionsChange;
|
||||
private Subject<Unit> onRectTransformDimensionsChange;
|
||||
|
||||
private Subject<Unit> onRectTransformRemoved;
|
||||
|
||||
// Callback that is sent if an associated RectTransform has it's dimensions changed
|
||||
void OnRectTransformDimensionsChange()
|
||||
private void OnRectTransformDimensionsChange()
|
||||
{
|
||||
if (onRectTransformDimensionsChange != null) onRectTransformDimensionsChange.OnNext(Unit.Default);
|
||||
}
|
||||
@@ -23,10 +26,8 @@ namespace UniRx.Triggers
|
||||
return onRectTransformDimensionsChange ?? (onRectTransformDimensionsChange = new Subject<Unit>());
|
||||
}
|
||||
|
||||
Subject<Unit> onRectTransformRemoved;
|
||||
|
||||
// Callback that is sent if an associated RectTransform is removed
|
||||
void OnRectTransformRemoved()
|
||||
private void OnRectTransformRemoved()
|
||||
{
|
||||
if (onRectTransformRemoved != null) onRectTransformRemoved.OnNext(Unit.Default);
|
||||
}
|
||||
@@ -39,16 +40,9 @@ namespace UniRx.Triggers
|
||||
|
||||
protected override void RaiseOnCompletedOnDestroy()
|
||||
{
|
||||
if (onRectTransformDimensionsChange != null)
|
||||
{
|
||||
onRectTransformDimensionsChange.OnCompleted();
|
||||
}
|
||||
if (onRectTransformRemoved != null)
|
||||
{
|
||||
onRectTransformRemoved.OnCompleted();
|
||||
}
|
||||
if (onRectTransformDimensionsChange != null) onRectTransformDimensionsChange.OnCompleted();
|
||||
if (onRectTransformRemoved != null) onRectTransformRemoved.OnCompleted();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user