Files
M-Gameton-06/Gameton-06/Assets/Plugins/UniRx/Examples/Sample03_GameObjectAsObservable.cs
2025-06-02 00:27:36 +09:00

23 lines
739 B
C#

#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO)
using UnityEngine;
using UniRx.Triggers; // for enable gameObject.EventAsObservbale()
namespace UniRx.Examples
{
public class Sample03_GameObjectAsObservable : MonoBehaviour
{
void Start()
{
// All events can subscribe by ***AsObservable if enables UniRx.Triggers
this.OnMouseDownAsObservable()
.SelectMany(_ => this.gameObject.UpdateAsObservable())
.TakeUntil(this.gameObject.OnMouseUpAsObservable())
.Select(_ => Input.mousePosition)
.RepeatUntilDestroy(this)
.Subscribe(x => Debug.Log(x), ()=> Debug.Log("!!!" + "complete"));
}
}
}
#endif