Database Support
Refactored almost everything, but most importantly we now integrate with RethinkDB for game data.
This commit is contained in:
parent
5ffeb55214
commit
0b46d5ee39
839 changed files with 77349 additions and 112660 deletions
|
|
@ -1,82 +0,0 @@
|
|||
#if !(UNITY_METRO || UNITY_WP8)
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Examples
|
||||
{
|
||||
// sample script, attach your object.
|
||||
public class Sample01_ObservableWWW : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
// Basic: Download from google.
|
||||
{
|
||||
ObservableWWW.Get("http://google.co.jp/")
|
||||
.Subscribe(
|
||||
x => Debug.Log(x.Substring(0, 100)), // onSuccess
|
||||
ex => Debug.LogException(ex)); // onError
|
||||
}
|
||||
|
||||
// Linear Pattern with LINQ Query Expressions
|
||||
// download after google, start bing download
|
||||
{
|
||||
var query = from google in ObservableWWW.Get("http://google.com/")
|
||||
from bing in ObservableWWW.Get("http://bing.com/")
|
||||
select new { google, bing };
|
||||
|
||||
var cancel = query.Subscribe(x => Debug.Log(x.google.Substring(0, 100) + ":" + x.bing.Substring(0, 100)));
|
||||
|
||||
// Call Dispose is cancel downloading.
|
||||
cancel.Dispose();
|
||||
}
|
||||
|
||||
// Observable.WhenAll is for parallel asynchronous operation
|
||||
// (It's like Observable.Zip but specialized for single async operations like Task.WhenAll of .NET 4)
|
||||
{
|
||||
var parallel = Observable.WhenAll(
|
||||
ObservableWWW.Get("http://google.com/"),
|
||||
ObservableWWW.Get("http://bing.com/"),
|
||||
ObservableWWW.Get("http://unity3d.com/"));
|
||||
|
||||
parallel.Subscribe(xs =>
|
||||
{
|
||||
Debug.Log(xs[0].Substring(0, 100)); // google
|
||||
Debug.Log(xs[1].Substring(0, 100)); // bing
|
||||
Debug.Log(xs[2].Substring(0, 100)); // unity
|
||||
});
|
||||
}
|
||||
|
||||
// with Progress
|
||||
{
|
||||
// notifier for progress
|
||||
var progressNotifier = new ScheduledNotifier<float>();
|
||||
progressNotifier.Subscribe(x => Debug.Log(x)); // write www.progress
|
||||
|
||||
// pass notifier to WWW.Get/Post
|
||||
ObservableWWW.Get("http://google.com/", progress: progressNotifier).Subscribe();
|
||||
}
|
||||
|
||||
// with Error
|
||||
{
|
||||
// If WWW has .error, ObservableWWW throws WWWErrorException to onError pipeline.
|
||||
// WWWErrorException has RawErrorMessage, HasResponse, StatusCode, ResponseHeaders
|
||||
ObservableWWW.Get("http://www.google.com/404")
|
||||
.CatchIgnore((WWWErrorException ex) =>
|
||||
{
|
||||
Debug.Log(ex.RawErrorMessage);
|
||||
if (ex.HasResponse)
|
||||
{
|
||||
Debug.Log(ex.StatusCode);
|
||||
}
|
||||
foreach (var item in ex.ResponseHeaders)
|
||||
{
|
||||
Debug.Log(item.Key + ":" + item.Value);
|
||||
}
|
||||
})
|
||||
.Subscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bf3770fc51ac89f45987dbde37ae81bd
|
||||
timeCreated: 1455373901
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Examples
|
||||
{
|
||||
public class Sample05_ConvertFromCoroutine
|
||||
{
|
||||
// public method
|
||||
public static IObservable<string> GetWWW(string url)
|
||||
{
|
||||
// convert coroutine to IObservable
|
||||
return Observable.FromCoroutine<string>((observer, cancellationToken) => GetWWWCore(url, observer, cancellationToken));
|
||||
}
|
||||
|
||||
// IEnumerator with callback
|
||||
static IEnumerator GetWWWCore(string url, IObserver<string> observer, CancellationToken cancellationToken)
|
||||
{
|
||||
var www = new UnityEngine.WWW(url);
|
||||
while (!www.isDone && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (cancellationToken.IsCancellationRequested) yield break;
|
||||
|
||||
if (www.error != null)
|
||||
{
|
||||
observer.OnError(new Exception(www.error));
|
||||
}
|
||||
else
|
||||
{
|
||||
observer.OnNext(www.text);
|
||||
observer.OnCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 41f3df73f7da66b4980f6d9a86927796
|
||||
timeCreated: 1455373898
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniRx.Examples
|
||||
{
|
||||
public class Sample06_ConvertToCoroutine : MonoBehaviour
|
||||
{
|
||||
// convert IObservable to Coroutine
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(ComplexCoroutineTest());
|
||||
}
|
||||
|
||||
IEnumerator ComplexCoroutineTest()
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
var v = default(int);
|
||||
yield return Observable.Range(1, 10).StartAsCoroutine(x => v = x);
|
||||
|
||||
Debug.Log(v); // 10(callback is last value)
|
||||
yield return new WaitForSeconds(3);
|
||||
|
||||
yield return Observable.Return(100).StartAsCoroutine(x => v = x);
|
||||
|
||||
Debug.Log(v); // 100
|
||||
}
|
||||
|
||||
// Note:ToAwaitableEnumerator/StartAsCoroutine/LazyTask are obsolete way on Unity 5.3
|
||||
// You can use ToYieldInstruction.
|
||||
|
||||
#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
|
||||
|
||||
IEnumerator TestNewCustomYieldInstruction()
|
||||
{
|
||||
// wait Rx Observable.
|
||||
yield return Observable.Timer(TimeSpan.FromSeconds(1)).ToYieldInstruction();
|
||||
|
||||
// you can change the scheduler(this is ignore Time.scale)
|
||||
yield return Observable.Timer(TimeSpan.FromSeconds(1), Scheduler.MainThreadIgnoreTimeScale).ToYieldInstruction();
|
||||
|
||||
// get return value from ObservableYieldInstruction
|
||||
var o = ObservableWWW.Get("http://unity3d.com/").ToYieldInstruction(throwOnError: false);
|
||||
yield return o;
|
||||
|
||||
if (o.HasError) { Debug.Log(o.Error.ToString()); }
|
||||
if (o.HasResult) { Debug.Log(o.Result); }
|
||||
|
||||
// other sample(wait until transform.position.y >= 100)
|
||||
yield return this.ObserveEveryValueChanged(x => x.transform).FirstOrDefault(x => x.position.y >= 100).ToYieldInstruction();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5da8247fbc4a4c84e96a727b44903214
|
||||
timeCreated: 1455373899
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue