public static IObservable <UnityWebRequest> PostAndGetWebRequest(string url, WWWForm content, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <UnityWebRequest>((observer, cancellation) => Fetch(UnityWebRequest.Post(url, content), (headers ?? new Hash()), observer, progress, cancellation))); }
public static IObservable <string> Post(string url, byte[] postData, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <string>((observer, cancellation) => FetchText(new WWW(url, postData), observer, progress, cancellation))); }
public static IObservable <byte[]> PostAndGetBytes(string url, WWWForm content, Hash headers, IProgress <float> progress = null) { var contentHeaders = content.headers; return(ObservableUnity.FromCoroutine <byte[]>((observer, cancellation) => FetchBytes(new WWW(url, content.data, MergeHash(contentHeaders, headers)), observer, progress, cancellation))); }
public static IObservable <string> Post(string url, WWWForm content, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <string>((observer, cancellation) => FetchText(UnityWebRequest.Post(url, content), observer, progress, cancellation))); }
public static IObservable <AssetBundle> LoadFromCacheOrDownload(string url, Hash128 hash128, uint crc, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <AssetBundle>((observer, cancellation) => FetchAssetBundle(WWW.LoadFromCacheOrDownload(url, hash128, crc), observer, progress, cancellation))); }
/// <summary> /// If you needs return value, use AsAsyncOperationObservable instead. /// </summary> public static IObservable <AsyncOperation> AsObservable(this AsyncOperation asyncOperation, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <AsyncOperation>((observer, cancellation) => AsObservableCore(asyncOperation, observer, progress, cancellation))); }
// over Unity5 supports Hash128 #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) public static IObservable <AssetBundle> LoadFromCacheOrDownload(string url, Hash128 hash128, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <AssetBundle>((observer, cancellation) => FetchAssetBundle(UnityWebRequestAssetBundle.GetAssetBundle(url, hash128, 0), observer, progress, cancellation))); }
public static IObservable <string> Post(string url, string postData, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <string>((observer, cancellation) => FetchText(UnityWebRequest.Post(url, postData), (headers ?? new Hash()), observer, progress, cancellation))); }
public static IObservable <string> Post(string url, List <IMultipartFormSection> multipartFormSections, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <string>((observer, cancellation) => FetchText(UnityWebRequest.Post(url, multipartFormSections), (headers ?? new Hash()), observer, progress, cancellation))); }
public static IObservable <Texture> GetTexture(string url, bool nonReadable, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <Texture>((observer, cancellation) => FetchTexture(UnityWebRequest.GetTexture(url, nonReadable), (headers ?? new Hash()), observer, progress, cancellation))); }
public static IObservable <AssetBundle> GetAssetBundle(string url, Hash128 hash128, uint crc, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <AssetBundle>((observer, cancellation) => FetchAssetBundle(UnityWebRequest.GetAssetBundle(url, hash128, crc), (headers ?? new Hash()), observer, progress, cancellation))); }
public static IObservable <byte[]> GetAndGetBytes(string url, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <byte[]>((observer, cancellation) => FetchBytes(UnityWebRequest.Get(url), (headers ?? new Hash()), observer, progress, cancellation))); }
public static IObservable <UnityWebRequest> HeadAndGetWebRequest(string url) { return(ObservableUnity.FromCoroutine <UnityWebRequest>((observer, cancellation) => Fetch(UnityWebRequest.Head(url), new Hash(), observer, null, cancellation))); }
public static IObservable <UnityWebRequest> PutAndGetWebRequest(string url, byte[] bodyData, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <UnityWebRequest>((observer, cancellation) => Fetch(UnityWebRequest.Put(url, bodyData), (headers ?? new Hash()), observer, progress, cancellation))); }
public static IObservable <UnityWebRequest> PostRequest(string _url, Dictionary <string, string> _postData, IDictionary <string, string> _headers, IProgress <float> _progress = null) { return(ObservableUnity.FromCoroutine <UnityWebRequest>((_observer, _cancellation) => FetchRequest(UnityWebRequest.Post(_url, _postData), _headers, _observer, _progress, _cancellation))); }
public static IObservable <string> ToObservable(this UnityWebRequest request, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <string>((observer, cancellation) => FetchText(request, null, observer, progress, cancellation))); }
public static IObservable <string> PostAndGetBytes(string url, string json) { return(ObservableUnity.FromCoroutine <string>((observer, cancellation) => FetchText(UnityWebRequest.Put(url, json), observer, null, cancellation))); }
public static IObservable <UnityWebRequest> PostRequest(string url, string postData, IDictionary <string, string> headers, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <UnityWebRequest>((observer, cancellation) => Fetch(UnityWebRequest.Post(url, postData), headers, observer, progress, cancellation))); }
// T: where T : AsyncOperation is ambigious with IObservable<T>.AsObservable public static IObservable <T> AsAsyncOperationObservable <T>(this T asyncOperation, IProgress <float> progress = null) where T : AsyncOperation { return(ObservableUnity.FromCoroutine <T>((observer, cancellation) => AsObservableCore(asyncOperation, observer, progress, cancellation))); }
PostAndGetBytes(string url, byte[] postData, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <byte[]>((observer, cancellation) => FetchBytes(new WWW(url, postData), observer, progress, cancellation))); }
public static IObservable <UnityWebRequest> GetWWW(string url, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <UnityWebRequest>((observer, cancellation) => Fetch(UnityWebRequest.Get(url), observer, progress, cancellation))); }
public static IObservable <AudioClip> GetAudioClipAsObservable(string _url, AudioType _audioType) { return(ObservableUnity.FromCoroutine <AudioClip>((_observer, _cancellation) => FetchAudioRequest(UnityWebRequestMultimedia.GetAudioClip(_url, _audioType), _observer))); }
/// <summary> /// Publish target property when value is changed. If source is destroyed/destructed, publish OnCompleted. /// </summary> /// <param name="fastDestroyCheck">If true and target is UnityObject, use destroyed check by additional component. It is faster check for lifecycle but needs initial cost.</param> public static IObservable <TProperty> ObserveEveryValueChanged <TSource, TProperty>(this TSource source, Func <TSource, TProperty> propertySelector, FrameCountType frameCountType, IEqualityComparer <TProperty> comparer, bool fastDestroyCheck) where TSource : class { if (source == null) { return(Observable.Empty <TProperty>()); } if (comparer == null) { comparer = UnityEqualityComparer.GetDefault <TProperty>(); } var unityObject = source as UnityEngine.Object; var isUnityObject = source is UnityEngine.Object; if (isUnityObject && unityObject == null) { return(Observable.Empty <TProperty>()); } // MicroCoroutine does not publish value immediately, so publish value on subscribe. if (isUnityObject) { return(ObservableUnity.FromMicroCoroutine <TProperty>((observer, cancellationToken) => { if (unityObject != null) { var firstValue = default(TProperty); try { firstValue = propertySelector((TSource)(object)unityObject); } catch (Exception ex) { observer.OnError(ex); return EmptyEnumerator(); } observer.OnNext(firstValue); return PublishUnityObjectValueChanged(unityObject, firstValue, propertySelector, comparer, observer, cancellationToken, fastDestroyCheck); } else { observer.OnCompleted(); return EmptyEnumerator(); } }, frameCountType)); } else { var reference = new WeakReference(source); source = null; return(ObservableUnity.FromMicroCoroutine <TProperty>((observer, cancellationToken) => { var target = reference.Target; if (target != null) { var firstValue = default(TProperty); try { firstValue = propertySelector((TSource)target); } catch (Exception ex) { observer.OnError(ex); return EmptyEnumerator(); } finally { target = null; } observer.OnNext(firstValue); return PublishPocoValueChanged(reference, firstValue, propertySelector, comparer, observer, cancellationToken); } else { observer.OnCompleted(); return EmptyEnumerator(); } }, frameCountType)); } }
public static IObservable <byte[]> ToBytesObservable(this UnityWebRequest _request, IProgress <float> _progress = null) { return(ObservableUnity.FromCoroutine <byte[]>((_observer, _cancellation) => Fetch(_request, null, _observer, _progress, _cancellation))); }
public static IObservable <WWW> GetWWW(string url, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <WWW>((observer, cancellation) => Fetch(new WWW(url, null, (headers ?? new Hash())), observer, progress, cancellation))); }
public static IObservable <byte[]> GetAndGetBytes(string _url, IDictionary <string, string> _headers = null, IProgress <float> _progress = null) { return(ObservableUnity.FromCoroutine <byte[]>((_observer, _cancellation) => FetchBytes(UnityWebRequest.Get(_url), _headers, _observer, _progress, _cancellation))); }
public static IObservable <byte[]> PostAndGetBytes(string url, WWWForm content, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <byte[]>((observer, cancellation) => FetchBytes(new WWW(url, content), observer, progress, cancellation))); }
public static IObservable <byte[]> PostAndGetBytes(string _url, Dictionary <string, string> _postData, IProgress <float> _progress = null) { return(ObservableUnity.FromCoroutine <byte[]>((_observer, _cancellation) => FetchBytes(UnityWebRequest.Post(_url, _postData), null, _observer, _progress, _cancellation))); }
public static IObservable <WWW> PostWWW(string url, byte[] postData, Hash headers, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <WWW>((observer, cancellation) => Fetch(new WWW(url, postData, headers), observer, progress, cancellation))); }
public static IObservable <byte[]> PostAndGetBytes(string url, List <IMultipartFormSection> multipartFormSections, byte[] boundary, Hash headers = null, IProgress <float> progress = null) { return(ObservableUnity.FromCoroutine <byte[]>((observer, cancellation) => FetchBytes(UnityWebRequest.Post(url, multipartFormSections, boundary), (headers ?? new Hash()), observer, progress, cancellation))); }