// 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; using System.Collections.Generic; using System.Text; using UnityEngine.Events; namespace UniRx { public static partial class UnityEventExtensions { public static IObservable AsObservable(this UnityEngine.Events.UnityEvent unityEvent) { return Observable.FromEvent(h => new UnityAction(h), h => unityEvent.AddListener(h), h => unityEvent.RemoveListener(h)); } public static IObservable AsObservable(this UnityEngine.Events.UnityEvent unityEvent) { return Observable.FromEvent, T>(h => new UnityAction(h), h => unityEvent.AddListener(h), h => unityEvent.RemoveListener(h)); } public static IObservable> AsObservable(this UnityEngine.Events.UnityEvent unityEvent) { return Observable.FromEvent, Tuple>(h => { return new UnityAction((t0, t1) => { h(Tuple.Create(t0, t1)); }); }, h => unityEvent.AddListener(h), h => unityEvent.RemoveListener(h)); } public static IObservable> AsObservable(this UnityEngine.Events.UnityEvent unityEvent) { return Observable.FromEvent, Tuple>(h => { return new UnityAction((t0, t1, t2) => { h(Tuple.Create(t0, t1, t2)); }); }, h => unityEvent.AddListener(h), h => unityEvent.RemoveListener(h)); } public static IObservable> AsObservable(this UnityEngine.Events.UnityEvent unityEvent) { return Observable.FromEvent, Tuple>(h => { return new UnityAction((t0, t1, t2, t3) => { h(Tuple.Create(t0, t1, t2, t3)); }); }, h => unityEvent.AddListener(h), h => unityEvent.RemoveListener(h)); } } } #endif