diff --git a/Assets/Plugins/UniRx/Examples/Sample01_ObservableWWW.cs b/Assets/Plugins/UniRx/Examples/Sample01_ObservableWWW.cs deleted file mode 100644 index 0c629da..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample01_ObservableWWW.cs +++ /dev/null @@ -1,90 +0,0 @@ -#if !(UNITY_METRO || UNITY_WP8) - -#if UNITY_2018_3_OR_NEWER -#pragma warning disable CS0618 -#endif - -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(); - 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 - -#if UNITY_2018_3_OR_NEWER -#pragma warning restore CS0618 -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample01_ObservableWWW.cs.meta b/Assets/Plugins/UniRx/Examples/Sample01_ObservableWWW.cs.meta deleted file mode 100644 index bfc52d8..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample01_ObservableWWW.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bf3770fc51ac89f45987dbde37ae81bd -timeCreated: 1455373901 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample02_ObservableTriggers.cs b/Assets/Plugins/UniRx/Examples/Sample02_ObservableTriggers.cs deleted file mode 100644 index c054aed..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample02_ObservableTriggers.cs +++ /dev/null @@ -1,24 +0,0 @@ -using UnityEngine; -using UniRx.Triggers; // Triggers Namepsace -using System; - -namespace UniRx.Examples -{ - public class Sample02_ObservableTriggers : MonoBehaviour - { - void Start() - { - // Get the plain object - var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); - - // Add ObservableXxxTrigger for handle MonoBehaviour's event as Observable - cube.AddComponent() - .UpdateAsObservable() - .SampleFrame(30) - .Subscribe(x => Debug.Log("cube"), () => Debug.Log("destroy")); - - // destroy after 3 second:) - GameObject.Destroy(cube, 3f); - } - } -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample02_ObservableTriggers.cs.meta b/Assets/Plugins/UniRx/Examples/Sample02_ObservableTriggers.cs.meta deleted file mode 100644 index 1ca1c6a..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample02_ObservableTriggers.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: cb5e978d683e94f4d9c2c81be80f93a7 -timeCreated: 1455373901 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample03_GameObjectAsObservable.cs b/Assets/Plugins/UniRx/Examples/Sample03_GameObjectAsObservable.cs deleted file mode 100644 index 2c0d0e4..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample03_GameObjectAsObservable.cs +++ /dev/null @@ -1,23 +0,0 @@ -#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 \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample03_GameObjectAsObservable.cs.meta b/Assets/Plugins/UniRx/Examples/Sample03_GameObjectAsObservable.cs.meta deleted file mode 100644 index 9e027f8..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample03_GameObjectAsObservable.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 005e349e5ccdd2b47bddc813b81afe40 -timeCreated: 1455373897 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample04_ConvertFromUnityCallback.cs b/Assets/Plugins/UniRx/Examples/Sample04_ConvertFromUnityCallback.cs deleted file mode 100644 index 549d8c2..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample04_ConvertFromUnityCallback.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using UnityEngine; - -namespace UniRx.Examples -{ - public class Sample04_ConvertFromUnityCallback : MonoBehaviour - { - // This is about log but more reliable log sample => Sample11_Logger - - private class LogCallback - { - public string Condition; - public string StackTrace; - public UnityEngine.LogType LogType; - } - - static class LogHelper - { - // If static register callback, use Subject for event branching. - -#if (UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7) - static Subject subject; - - public static IObservable LogCallbackAsObservable() - { - if (subject == null) - { - subject = new Subject(); - - // Publish to Subject in callback - - - UnityEngine.Application.RegisterLogCallback((condition, stackTrace, type) => - { - subject.OnNext(new LogCallback { Condition = condition, StackTrace = stackTrace, LogType = type }); - }); - } - - return subject.AsObservable(); - } - -#else - // If standard evetns, you can use Observable.FromEvent. - - public static IObservable LogCallbackAsObservable() - { - return Observable.FromEvent( - h => (condition, stackTrace, type) => h(new LogCallback { Condition = condition, StackTrace = stackTrace, LogType = type }), - h => Application.logMessageReceived += h, h => Application.logMessageReceived -= h); - } -#endif - } - - void Awake() - { - // method is separatable and composable - LogHelper.LogCallbackAsObservable() - .Where(x => x.LogType == LogType.Warning) - .Subscribe(x => Debug.Log(x)); - - LogHelper.LogCallbackAsObservable() - .Where(x => x.LogType == LogType.Error) - .Subscribe(x => Debug.Log(x)); - } - } -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample04_ConvertFromUnityCallback.cs.meta b/Assets/Plugins/UniRx/Examples/Sample04_ConvertFromUnityCallback.cs.meta deleted file mode 100644 index 4c68f0a..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample04_ConvertFromUnityCallback.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 73e69fd4bbb724045a4e06050fbc5af3 -timeCreated: 1455373899 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample05_ConvertFromCoroutine.cs b/Assets/Plugins/UniRx/Examples/Sample05_ConvertFromCoroutine.cs deleted file mode 100644 index 8c5a37a..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample05_ConvertFromCoroutine.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections; -using System.Threading; -using UnityEngine; -#if UNITY_2018_3_OR_NEWER -#pragma warning disable CS0618 -#endif - -namespace UniRx.Examples -{ - public class Sample05_ConvertFromCoroutine - { - // public method - public static IObservable GetWWW(string url) - { - // convert coroutine to IObservable - return Observable.FromCoroutine((observer, cancellationToken) => GetWWWCore(url, observer, cancellationToken)); - } - - // IEnumerator with callback - static IEnumerator GetWWWCore(string url, IObserver 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(); - } - } - } -} -#if UNITY_2018_3_OR_NEWER -#pragma warning restore CS0618 -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample05_ConvertFromCoroutine.cs.meta b/Assets/Plugins/UniRx/Examples/Sample05_ConvertFromCoroutine.cs.meta deleted file mode 100644 index 1a8a8b4..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample05_ConvertFromCoroutine.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 41f3df73f7da66b4980f6d9a86927796 -timeCreated: 1455373898 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample06_ConvertToCoroutine.cs b/Assets/Plugins/UniRx/Examples/Sample06_ConvertToCoroutine.cs deleted file mode 100644 index e7ec1da..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample06_ConvertToCoroutine.cs +++ /dev/null @@ -1,62 +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) -#if UNITY_2018_3_OR_NEWER -#pragma warning disable CS0618 -#endif - - 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(); - } -#if UNITY_2018_3_OR_NEWER -#pragma warning restore CS0618 -#endif -#endif - - } -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample06_ConvertToCoroutine.cs.meta b/Assets/Plugins/UniRx/Examples/Sample06_ConvertToCoroutine.cs.meta deleted file mode 100644 index 30b592b..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample06_ConvertToCoroutine.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5da8247fbc4a4c84e96a727b44903214 -timeCreated: 1455373899 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample07_OrchestratIEnumerator.cs b/Assets/Plugins/UniRx/Examples/Sample07_OrchestratIEnumerator.cs deleted file mode 100644 index fa0fcdc..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample07_OrchestratIEnumerator.cs +++ /dev/null @@ -1,45 +0,0 @@ -#pragma warning disable 0168 -#pragma warning disable 0219 - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; - -namespace UniRx.Examples -{ - public class Sample07_OrchestratIEnumerator : MonoBehaviour - { - // two coroutines - IEnumerator AsyncA() - { - Debug.Log("a start"); - yield return new WaitForSeconds(3); - Debug.Log("a end"); - } - - IEnumerator AsyncB() - { - Debug.Log("b start"); - yield return new WaitForEndOfFrame(); - Debug.Log("b end"); - } - - void Start() - { - // after completed AsyncA, run AsyncB as continuous routine. - // UniRx expands SelectMany(IEnumerator) as SelectMany(IEnumerator.ToObservable()) - var cancel = Observable.FromCoroutine(AsyncA) - .SelectMany(AsyncB) - .Subscribe(); - - // If you want to stop Coroutine(as cancel), call subscription.Dispose() - // cancel.Dispose(); - } - } -} - -#pragma warning restore 0219 -#pragma warning restore 0168 \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample07_OrchestratIEnumerator.cs.meta b/Assets/Plugins/UniRx/Examples/Sample07_OrchestratIEnumerator.cs.meta deleted file mode 100644 index 9a1ae43..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample07_OrchestratIEnumerator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d437607dfffa8ff428bda3366354078d -timeCreated: 1455373901 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample08_DetectDoubleClick.cs b/Assets/Plugins/UniRx/Examples/Sample08_DetectDoubleClick.cs deleted file mode 100644 index 1c880ed..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample08_DetectDoubleClick.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; - -namespace UniRx.Examples -{ - public class Sample08_DetectDoubleClick : MonoBehaviour - { - void Start() - { - // Global event handling is very useful. - // UniRx can handle there events. - // Observable.EveryUpdate/EveryFixedUpdate/EveryEndOfFrame - // Observable.EveryApplicationFocus/EveryApplicationPause - // Observable.OnceApplicationQuit - - // This DoubleCLick Sample is from - // The introduction to Reactive Programming you've been missing - // https://gist.github.com/staltz/868e7e9bc2a7b8c1f754 - - var clickStream = Observable.EveryUpdate() - .Where(_ => Input.GetMouseButtonDown(0)); - - clickStream.Buffer(clickStream.Throttle(TimeSpan.FromMilliseconds(250))) - .Where(xs => xs.Count >= 2) - .Subscribe(xs => Debug.Log("DoubleClick Detected! Count:" + xs.Count)); - } - } -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample08_DetectDoubleClick.cs.meta b/Assets/Plugins/UniRx/Examples/Sample08_DetectDoubleClick.cs.meta deleted file mode 100644 index 5b9112f..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample08_DetectDoubleClick.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: eb801bbfb1ffcd64389e90c8f2435b79 -timeCreated: 1455373902 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample09_EventHandling.cs b/Assets/Plugins/UniRx/Examples/Sample09_EventHandling.cs deleted file mode 100644 index 8ccd1db..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample09_EventHandling.cs +++ /dev/null @@ -1,69 +0,0 @@ -#pragma warning disable 0067 - -using System; -using UnityEngine; - -namespace UniRx.Examples -{ - public class Sample09_EventHandling : MonoBehaviour - { - public class MyEventArgs : EventArgs - { - public int MyProperty { get; set; } - } - - public event EventHandler FooBar; - public event Action FooFoo; - - CompositeDisposable disposables = new CompositeDisposable(); - - // Subject is Rx's native event expression and recommend way for use Rx as event. - // Subject.OnNext as fire event, - // expose IObserver is subscibable for external source, it's no need convert. - Subject onBarBar = new Subject(); - public IObservable OnBarBar { get { return onBarBar; } } - - void Start() - { - // convert to IO as (sender, eventArgs) - Observable.FromEventPattern, MyEventArgs>( - h => h.Invoke, h => FooBar += h, h => FooBar -= h) - .Subscribe() - .AddTo(disposables); // IDisposable can add to collection easily by AddTo - - // convert to IO, many situation this is useful than FromEventPattern - Observable.FromEvent, MyEventArgs>( - h => (sender, e) => h(e), h => FooBar += h, h => FooBar -= h) - .Subscribe() - .AddTo(disposables); - - // You can convert Action like event. - Observable.FromEvent( - h => FooFoo += h, h => FooFoo -= h) - .Subscribe() - .AddTo(disposables); - - // AOT Safe EventHandling, use dummy capture, see:https://github.com/neuecc/UniRx/wiki/AOT-Exception-Patterns-and-Hacks - var capture = 0; - Observable.FromEventPattern, MyEventArgs>(h => - { - capture.GetHashCode(); // dummy for AOT - return new EventHandler(h); - }, h => FooBar += h, h => FooBar -= h) - .Subscribe() - .AddTo(disposables); - - // Subject as like event. - OnBarBar.Subscribe().AddTo(disposables); - onBarBar.OnNext(1); // fire event - } - - void OnDestroy() - { - // manage subscription lifecycle - disposables.Dispose(); - } - } -} - -#pragma warning restore 0067 \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample09_EventHandling.cs.meta b/Assets/Plugins/UniRx/Examples/Sample09_EventHandling.cs.meta deleted file mode 100644 index 73b2354..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample09_EventHandling.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 95140e49213aa6f49a470a81873b87c0 -timeCreated: 1455373900 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample10_MainThreadDispatcher.cs b/Assets/Plugins/UniRx/Examples/Sample10_MainThreadDispatcher.cs deleted file mode 100644 index b2cafef..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample10_MainThreadDispatcher.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections; -using UnityEngine; - -namespace UniRx.Examples -{ - public class Sample10_MainThreadDispatcher - { - public void Run() - { - // MainThreadDispatcher is heart of Rx and Unity integration - - // StartCoroutine can start coroutine besides MonoBehaviour. - MainThreadDispatcher.StartCoroutine(TestAsync()); - - // We have two way of run coroutine, FromCoroutine or StartCoroutine. - // StartCoroutine is Unity primitive way and it's awaitable by yield return. - // FromCoroutine is Rx, it's composable and cancellable by subscription's IDisposable. - // FromCoroutine's overload can have return value, see:Sample05_ConvertFromCoroutine - Observable.FromCoroutine(TestAsync).Subscribe(); - - // Add Action to MainThreadDispatcher. Action is saved queue, run on next update. - MainThreadDispatcher.Post(_ => Debug.Log("test"), null); - - // Timebased operations is run on MainThread(as default) - // All timebased operation(Interval, Timer, Delay, Buffer, etc...)is single thread, thread safe! - Observable.Interval(TimeSpan.FromSeconds(1)) - .Subscribe(x => Debug.Log(x)); - - // Observable.Start use ThreadPool Scheduler as default. - // ObserveOnMainThread return to mainthread - Observable.Start(() => Unit.Default) // asynchronous work - .ObserveOnMainThread() - .Subscribe(x => Debug.Log(x)); - } - - IEnumerator TestAsync() - { - Debug.Log("a"); - yield return new WaitForSeconds(1); - Debug.Log("b"); - yield return new WaitForSeconds(1); - Debug.Log("c"); - yield return new WaitForSeconds(1); - Debug.Log("d"); - } - } -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample10_MainThreadDispatcher.cs.meta b/Assets/Plugins/UniRx/Examples/Sample10_MainThreadDispatcher.cs.meta deleted file mode 100644 index 7335916..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample10_MainThreadDispatcher.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6a0b959735346af48b772254afc8afdd -timeCreated: 1455373899 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample11_Logger.cs b/Assets/Plugins/UniRx/Examples/Sample11_Logger.cs deleted file mode 100644 index 8de54d5..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample11_Logger.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections; -using UniRx.Diagnostics; -using UnityEngine; - -namespace UniRx.Examples -{ - public class Sample11_Logger - { - // UniRx.Diagnostics.Logger - // logger is threadsafe, define per class with name. - static readonly UniRx.Diagnostics.Logger logger = new UniRx.Diagnostics.Logger("Sample11"); - - // call once at applicationinit - public void ApplicationInitialize() - { - // Log as Stream, UniRx.Diagnostics.ObservableLogger.Listener is IObservable - // You can subscribe and output to any place. - ObservableLogger.Listener.LogToUnityDebug(); - - // for example, filter only Exception and upload to web. - // (make custom sink(IObserver) is better to use) - ObservableLogger.Listener - .Where(x => x.LogType == LogType.Exception) - .Subscribe(x => - { - // ObservableWWW.Post("", null).Subscribe(); - }); - } - - public void Run() - { - // Debug is write only DebugBuild. - logger.Debug("Debug Message"); - - // or other logging methods - logger.Log("Message"); - logger.Exception(new Exception("test exception")); - } - } -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample11_Logger.cs.meta b/Assets/Plugins/UniRx/Examples/Sample11_Logger.cs.meta deleted file mode 100644 index d5fa22b..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample11_Logger.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f5aa72c61e2548a4bac4d65f93c63bf1 -timeCreated: 1455373902 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample12Scene.unity b/Assets/Plugins/UniRx/Examples/Sample12Scene.unity deleted file mode 100644 index dd99029..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample12Scene.unity +++ /dev/null @@ -1,1535 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -SceneSettings: - m_ObjectHideFlags: 0 - m_PVSData: - m_PVSObjectsArray: [] - m_PVSPortalsArray: [] - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 6 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 3 - m_SkyboxMaterial: {fileID: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} ---- !u!157 &4 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 6 - m_GIWorkflowMode: 0 - m_LightmapsMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_TemporalCoherenceThreshold: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 0 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 3 - m_Resolution: 2 - m_BakeResolution: 40 - m_TextureWidth: 1024 - m_TextureHeight: 1024 - m_AOMaxDistance: 1 - m_Padding: 2 - m_CompAOExponent: 0 - m_LightmapParameters: {fileID: 0} - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherRayCount: 1024 - m_ReflectionCompression: 2 - m_LightingDataAsset: {fileID: 0} - m_RuntimeCPUUsage: 25 ---- !u!196 &5 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 2 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - accuratePlacement: 0 - minRegionArea: 2 - cellSize: 0.16666667 - manualCellSize: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &33721919 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 33721920} - - 223: {fileID: 33721924} - - 114: {fileID: 33721923} - - 114: {fileID: 33721922} - - 114: {fileID: 33721921} - m_Layer: 5 - m_Name: Canvas - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &33721920 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 33721919} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0, y: 0, z: 0} - m_Children: - - {fileID: 921642174} - - {fileID: 530746210} - - {fileID: 46704896} - - {fileID: 579875960} - - {fileID: 1891604357} - m_Father: {fileID: 0} - m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 0} ---- !u!114 &33721921 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 33721919} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 18e34490a83a27e44adf93dd4ffd1f22, type: 3} - m_Name: - m_EditorClassIdentifier: - MyButton: {fileID: 921642175} - MyToggle: {fileID: 530746211} - MyInput: {fileID: 46704897} - MyText: {fileID: 579875961} - MySlider: {fileID: 1891604358} - IntRxProp: - value: 0 ---- !u!114 &33721922 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 33721919} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &33721923 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 33721919} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_UiScaleMode: 0 - m_ReferencePixelsPerUnit: 100 - m_ScaleFactor: 1 - m_ReferenceResolution: {x: 800, y: 600} - m_ScreenMatchMode: 0 - m_MatchWidthOrHeight: 0 - m_PhysicalUnit: 3 - m_FallbackScreenDPI: 96 - m_DefaultSpriteDPI: 96 - m_DynamicPixelsPerUnit: 1 ---- !u!223 &33721924 -Canvas: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 33721919} - m_Enabled: 1 - serializedVersion: 2 - m_RenderMode: 0 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 0 - m_OverridePixelPerfect: 0 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!1 &46704895 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 46704896} - - 222: {fileID: 46704899} - - 114: {fileID: 46704898} - - 114: {fileID: 46704897} - m_Layer: 5 - m_Name: InputField - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &46704896 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 46704895} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 835857415} - - {fileID: 710358450} - m_Father: {fileID: 33721920} - m_RootOrder: 2 - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 277} - m_SizeDelta: {x: 160, y: 30} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &46704897 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 46704895} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 575553740, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 46704898} - m_TextComponent: {fileID: 710358451} - m_Placeholder: {fileID: 835857416} - m_ContentType: 0 - m_InputType: 0 - m_AsteriskChar: 42 - m_KeyboardType: 0 - m_LineType: 0 - m_HideMobileInput: 0 - m_CharacterValidation: 0 - m_CharacterLimit: 0 - m_OnEndEdit: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.InputField+SubmitEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.InputField+OnChangeEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null - m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_CustomCaretColor: 0 - m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} - m_Text: - m_CaretBlinkRate: 1.7 - m_CaretWidth: 1 - m_ReadOnly: 0 ---- !u!114 &46704898 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 46704895} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &46704899 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 46704895} ---- !u!1 &163238468 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 163238469} - - 222: {fileID: 163238471} - - 114: {fileID: 163238470} - m_Layer: 5 - m_Name: Checkmark - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &163238469 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 163238468} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 1018308463} - m_RootOrder: 0 - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 20, y: 20} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &163238470 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 163238468} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &163238471 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 163238468} ---- !u!1 &530746209 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 530746210} - - 114: {fileID: 530746211} - m_Layer: 5 - m_Name: Toggle - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &530746210 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 530746209} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 1018308463} - - {fileID: 1527674668} - m_Father: {fileID: 33721920} - m_RootOrder: 1 - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -160, y: 294} - m_SizeDelta: {x: 160, y: 20} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &530746211 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 530746209} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 1018308464} - toggleTransition: 1 - graphic: {fileID: 163238470} - m_Group: {fileID: 0} - onValueChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.Toggle+ToggleEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null - m_IsOn: 0 ---- !u!1 &579875959 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 579875960} - - 222: {fileID: 579875962} - - 114: {fileID: 579875961} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &579875960 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 579875959} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 33721920} - m_RootOrder: 3 - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 178} - m_SizeDelta: {x: 160, y: 30} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &579875961 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 579875959} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: New Text ---- !u!222 &579875962 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 579875959} ---- !u!1 &605953354 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 605953355} - m_Layer: 5 - m_Name: Handle Slide Area - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &605953355 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 605953354} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 1022847601} - m_Father: {fileID: 1891604357} - m_RootOrder: 2 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: -20, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &710358449 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 710358450} - - 222: {fileID: 710358452} - - 114: {fileID: 710358451} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &710358450 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 710358449} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 46704896} - m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &710358451 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 710358449} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 0 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: ---- !u!222 &710358452 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 710358449} ---- !u!1 &801653541 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 801653542} - - 222: {fileID: 801653544} - - 114: {fileID: 801653543} - m_Layer: 5 - m_Name: Background - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &801653542 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 801653541} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 1891604357} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0.25} - m_AnchorMax: {x: 1, y: 0.75} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &801653543 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 801653541} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &801653544 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 801653541} ---- !u!1 &835857414 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 835857415} - - 222: {fileID: 835857417} - - 114: {fileID: 835857416} - m_Layer: 5 - m_Name: Placeholder - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &835857415 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 835857414} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 46704896} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &835857416 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 835857414} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 2 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Enter text... ---- !u!222 &835857417 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 835857414} ---- !u!1 &921642173 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 921642174} - - 222: {fileID: 921642177} - - 114: {fileID: 921642176} - - 114: {fileID: 921642175} - m_Layer: 5 - m_Name: Button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &921642174 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 921642173} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 1781955689} - m_Father: {fileID: 33721920} - m_RootOrder: 0 - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -171, y: 218} - m_SizeDelta: {x: 160, y: 30} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &921642175 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 921642173} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 921642176} - m_OnClick: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null ---- !u!114 &921642176 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 921642173} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &921642177 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 921642173} ---- !u!1 &930565829 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 930565830} - - 222: {fileID: 930565832} - - 114: {fileID: 930565831} - m_Layer: 5 - m_Name: Fill - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &930565830 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 930565829} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 1807094062} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 10, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &930565831 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 930565829} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &930565832 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 930565829} ---- !u!1 &1018308462 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 1018308463} - - 222: {fileID: 1018308465} - - 114: {fileID: 1018308464} - m_Layer: 5 - m_Name: Background - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1018308463 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1018308462} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 163238469} - m_Father: {fileID: 530746210} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 10, y: -10} - m_SizeDelta: {x: 20, y: 20} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1018308464 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1018308462} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &1018308465 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1018308462} ---- !u!1 &1022847600 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 1022847601} - - 222: {fileID: 1022847603} - - 114: {fileID: 1022847602} - m_Layer: 5 - m_Name: Handle - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1022847601 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1022847600} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 605953355} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 20, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1022847602 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1022847600} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &1022847603 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1022847600} ---- !u!1 &1184379970 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 1184379974} - - 114: {fileID: 1184379973} - - 114: {fileID: 1184379972} - - 114: {fileID: 1184379971} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1184379971 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1184379970} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1997211142, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_ForceModuleActive: 0 ---- !u!114 &1184379972 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1184379970} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!114 &1184379973 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1184379970} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 5 ---- !u!4 &1184379974 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1184379970} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 2 ---- !u!1 &1527674667 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 1527674668} - - 222: {fileID: 1527674670} - - 114: {fileID: 1527674669} - m_Layer: 5 - m_Name: Label - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1527674668 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1527674667} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 530746210} - m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 9, y: -0.5} - m_SizeDelta: {x: -28, y: -3} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1527674669 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1527674667} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Toggle ---- !u!222 &1527674670 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1527674667} ---- !u!1 &1781955688 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 1781955689} - - 222: {fileID: 1781955691} - - 114: {fileID: 1781955690} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1781955689 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1781955688} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 921642174} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1781955690 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1781955688} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Button ---- !u!222 &1781955691 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1781955688} ---- !u!1 &1807094061 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 1807094062} - m_Layer: 5 - m_Name: Fill Area - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1807094062 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1807094061} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 930565830} - m_Father: {fileID: 1891604357} - m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 0.25} - m_AnchorMax: {x: 1, y: 0.75} - m_AnchoredPosition: {x: -5, y: 0} - m_SizeDelta: {x: -20, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &1838497716 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 1838497721} - - 20: {fileID: 1838497720} - - 92: {fileID: 1838497719} - - 124: {fileID: 1838497718} - - 81: {fileID: 1838497717} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &1838497717 -AudioListener: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1838497716} - m_Enabled: 1 ---- !u!124 &1838497718 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1838497716} - m_Enabled: 1 ---- !u!92 &1838497719 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1838497716} - m_Enabled: 1 ---- !u!20 &1838497720 -Camera: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1838497716} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 1 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 - m_StereoMirrorMode: 0 ---- !u!4 &1838497721 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1838497716} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 ---- !u!1 &1891604356 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 1891604357} - - 114: {fileID: 1891604358} - m_Layer: 5 - m_Name: Slider - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1891604357 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1891604356} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 801653542} - - {fileID: 1807094062} - - {fileID: 605953355} - m_Father: {fileID: 33721920} - m_RootOrder: 4 - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 102} - m_SizeDelta: {x: 160, y: 20} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1891604358 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1891604356} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -113659843, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 1022847602} - m_FillRect: {fileID: 930565830} - m_HandleRect: {fileID: 1022847601} - m_Direction: 0 - m_MinValue: 0 - m_MaxValue: 1 - m_WholeNumbers: 0 - m_Value: 1 - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.Slider+SliderEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null diff --git a/Assets/Plugins/UniRx/Examples/Sample12Scene.unity.meta b/Assets/Plugins/UniRx/Examples/Sample12Scene.unity.meta deleted file mode 100644 index 43d6aba..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample12Scene.unity.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4a4aea8df1ad11c47a1db84432dd30f8 -timeCreated: 1455373896 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample12_ReactiveProperty.cs b/Assets/Plugins/UniRx/Examples/Sample12_ReactiveProperty.cs deleted file mode 100644 index e1e7d56..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample12_ReactiveProperty.cs +++ /dev/null @@ -1,77 +0,0 @@ -// 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 UnityEngine; -using UnityEngine.UI; - -namespace UniRx.Examples -{ - public class Sample12_ReactiveProperty : MonoBehaviour - { - // Open Sample12Scene. Set from canvas - public Button MyButton; - public Toggle MyToggle; - public InputField MyInput; - public Text MyText; - public Slider MySlider; - - // You can monitor/modifie in inspector by SpecializedReactiveProperty - public IntReactiveProperty IntRxProp = new IntReactiveProperty(); - - Enemy enemy = new Enemy(1000); - - void Start() - { - // UnityEvent as Observable - // (shortcut, MyButton.OnClickAsObservable()) - MyButton.onClick.AsObservable().Subscribe(_ => enemy.CurrentHp.Value -= 99); - - // Toggle, Input etc as Observable(OnValueChangedAsObservable is helper for provide isOn value on subscribe) - // SubscribeToInteractable is UniRx.UI Extension Method, same as .interactable = x) - MyToggle.OnValueChangedAsObservable().SubscribeToInteractable(MyButton); - - // input shows delay after 1 second -#if !(UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2) - MyInput.OnValueChangedAsObservable() -#else - MyInput.OnValueChangeAsObservable() -#endif - .Where(x => x != null) - .Delay(TimeSpan.FromSeconds(1)) - .SubscribeToText(MyText); // SubscribeToText is UniRx.UI Extension Method - - // converting for human visibility - MySlider.OnValueChangedAsObservable() - .SubscribeToText(MyText, x => Math.Round(x, 2).ToString()); - - // from RxProp, CurrentHp changing(Button Click) is observable - enemy.CurrentHp.SubscribeToText(MyText); - enemy.IsDead.Where(isDead => isDead == true) - .Subscribe(_ => - { - MyToggle.interactable = MyButton.interactable = false; - }); - - // initial text:) - IntRxProp.SubscribeToText(MyText); - } - } - - // Reactive Notification Model - public class Enemy - { - public IReactiveProperty CurrentHp { get; private set; } - - public IReadOnlyReactiveProperty IsDead { get; private set; } - - public Enemy(int initialHp) - { - // Declarative Property - CurrentHp = new ReactiveProperty(initialHp); - IsDead = CurrentHp.Select(x => x <= 0).ToReactiveProperty(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample12_ReactiveProperty.cs.meta b/Assets/Plugins/UniRx/Examples/Sample12_ReactiveProperty.cs.meta deleted file mode 100644 index 66c4ceb..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample12_ReactiveProperty.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 18e34490a83a27e44adf93dd4ffd1f22 -timeCreated: 1455373897 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample13Scene.unity b/Assets/Plugins/UniRx/Examples/Sample13Scene.unity deleted file mode 100644 index 169248e..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample13Scene.unity +++ /dev/null @@ -1,1300 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -SceneSettings: - m_ObjectHideFlags: 0 - m_PVSData: - m_PVSObjectsArray: [] - m_PVSPortalsArray: [] - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 6 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 3 - m_SkyboxMaterial: {fileID: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} ---- !u!157 &4 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 6 - m_GIWorkflowMode: 0 - m_LightmapsMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_TemporalCoherenceThreshold: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 0 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 3 - m_Resolution: 2 - m_BakeResolution: 40 - m_TextureWidth: 1024 - m_TextureHeight: 1024 - m_AOMaxDistance: 1 - m_Padding: 2 - m_CompAOExponent: 0 - m_LightmapParameters: {fileID: 0} - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherRayCount: 1024 - m_ReflectionCompression: 2 - m_LightingDataAsset: {fileID: 0} - m_RuntimeCPUUsage: 25 ---- !u!196 &5 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 2 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - accuratePlacement: 0 - minRegionArea: 2 - cellSize: 0.16666667 - manualCellSize: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &48390799 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 48390800} - - 222: {fileID: 48390802} - - 114: {fileID: 48390801} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &48390800 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 48390799} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 2136645852} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &48390801 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 48390799} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Clear Checked ---- !u!222 &48390802 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 48390799} ---- !u!1 &80191139 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 80191140} - - 114: {fileID: 80191141} - m_Layer: 5 - m_Name: TodoList - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &80191140 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 80191139} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 625561981} - m_RootOrder: 2 - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0.000030517578, y: -864} - m_SizeDelta: {x: 0, y: 744} - m_Pivot: {x: 0.5, y: 0} ---- !u!114 &80191141 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 80191139} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1297475563, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Padding: - m_Left: 0 - m_Right: 0 - m_Top: 0 - m_Bottom: 0 - m_ChildAlignment: 0 - m_Spacing: 0 - m_ChildForceExpandWidth: 1 - m_ChildForceExpandHeight: 1 ---- !u!1 &300470760 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 300470761} - - 114: {fileID: 300470762} - m_Layer: 0 - m_Name: ToDoScene - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &300470761 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 300470760} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 895588078} - m_Father: {fileID: 0} - m_RootOrder: 1 ---- !u!114 &300470762 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 300470760} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 022ecfa555367154c8cf87d61465f7e2, type: 3} - m_Name: - m_EditorClassIdentifier: - Title: {fileID: 852345258} - ToDoInput: {fileID: 566049662} - AddButton: {fileID: 611575448} - ClearButton: {fileID: 2136645853} - TodoList: {fileID: 80191139} - SampleItemPrefab: {fileID: 182208, guid: 173222196f3e1f0448b383f260df7d44, type: 2} ---- !u!1 &448872075 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 448872079} - - 114: {fileID: 448872078} - - 114: {fileID: 448872077} - - 114: {fileID: 448872076} - - 114: {fileID: 448872080} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &448872076 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 448872075} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1997211142, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_ForceModuleActive: 0 ---- !u!114 &448872077 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 448872075} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!114 &448872078 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 448872075} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 5 ---- !u!4 &448872079 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 448872075} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 2 ---- !u!114 &448872080 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 448872075} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!1 &566049660 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 566049661} - - 222: {fileID: 566049664} - - 114: {fileID: 566049663} - - 114: {fileID: 566049662} - m_Layer: 5 - m_Name: ToDoInput - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &566049661 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 566049660} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 2102338788} - - {fileID: 1368145207} - m_Father: {fileID: 650625965} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &566049662 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 566049660} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 575553740, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 566049663} - m_TextComponent: {fileID: 1368145205} - m_Placeholder: {fileID: 2102338789} - m_ContentType: 0 - m_InputType: 0 - m_AsteriskChar: 42 - m_KeyboardType: 0 - m_LineType: 0 - m_HideMobileInput: 0 - m_CharacterValidation: 0 - m_CharacterLimit: 0 - m_OnEndEdit: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.InputField+SubmitEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.InputField+OnChangeEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null - m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_CustomCaretColor: 0 - m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} - m_Text: - m_CaretBlinkRate: 1.7 - m_CaretWidth: 1 - m_ReadOnly: 0 ---- !u!114 &566049663 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 566049660} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &566049664 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 566049660} ---- !u!1 &611575446 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 611575447} - - 222: {fileID: 611575450} - - 114: {fileID: 611575449} - - 114: {fileID: 611575448} - m_Layer: 5 - m_Name: AddButton - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &611575447 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 611575446} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 721405894} - m_Father: {fileID: 650625965} - m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &611575448 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 611575446} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 611575449} - m_OnClick: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null ---- !u!114 &611575449 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 611575446} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &611575450 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 611575446} ---- !u!1 &625561980 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 625561981} - - 222: {fileID: 625561983} - - 114: {fileID: 625561982} - m_Layer: 5 - m_Name: Panel - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &625561981 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 625561980} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 852345257} - - {fileID: 650625965} - - {fileID: 80191140} - m_Father: {fileID: 895588078} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &625561982 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 625561980} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 0.392} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &625561983 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 625561980} ---- !u!1 &650625964 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 650625965} - - 114: {fileID: 650625966} - m_Layer: 5 - m_Name: InputArea - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &650625965 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 650625964} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 566049661} - - {fileID: 611575447} - - {fileID: 2136645852} - m_Father: {fileID: 625561981} - m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 50} - m_Pivot: {x: 0.5, y: 0} ---- !u!114 &650625966 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 650625964} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -405508275, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Padding: - m_Left: 0 - m_Right: 0 - m_Top: 0 - m_Bottom: 0 - m_ChildAlignment: 0 - m_Spacing: 0 - m_ChildForceExpandWidth: 1 - m_ChildForceExpandHeight: 1 ---- !u!1 &721405893 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 721405894} - - 222: {fileID: 721405896} - - 114: {fileID: 721405895} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &721405894 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 721405893} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 611575447} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &721405895 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 721405893} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Add ---- !u!222 &721405896 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 721405893} ---- !u!1 &852345256 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 852345257} - - 222: {fileID: 852345259} - - 114: {fileID: 852345258} - m_Layer: 5 - m_Name: Title - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &852345257 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 852345256} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 625561981} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 120} - m_Pivot: {x: 0, y: 1} ---- !u!114 &852345258 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 852345256} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 0 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: TODO App:) ---- !u!222 &852345259 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 852345256} ---- !u!1 &895588077 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 895588078} - - 223: {fileID: 895588081} - - 114: {fileID: 895588080} - - 114: {fileID: 895588079} - m_Layer: 5 - m_Name: Canvas - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &895588078 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 895588077} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0, y: 0, z: 0} - m_Children: - - {fileID: 625561981} - m_Father: {fileID: 300470761} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 0} ---- !u!114 &895588079 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 895588077} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &895588080 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 895588077} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_UiScaleMode: 0 - m_ReferencePixelsPerUnit: 100 - m_ScaleFactor: 1 - m_ReferenceResolution: {x: 800, y: 600} - m_ScreenMatchMode: 0 - m_MatchWidthOrHeight: 0 - m_PhysicalUnit: 3 - m_FallbackScreenDPI: 96 - m_DefaultSpriteDPI: 96 - m_DynamicPixelsPerUnit: 1 ---- !u!223 &895588081 -Canvas: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 895588077} - m_Enabled: 1 - serializedVersion: 2 - m_RenderMode: 0 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 0 - m_OverridePixelPerfect: 0 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!1 &1368145204 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 1368145207} - - 222: {fileID: 1368145206} - - 114: {fileID: 1368145205} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1368145205 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1368145204} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 0 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: ---- !u!222 &1368145206 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1368145204} ---- !u!224 &1368145207 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1368145204} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 566049661} - m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &2074703090 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 2074703095} - - 20: {fileID: 2074703094} - - 92: {fileID: 2074703093} - - 124: {fileID: 2074703092} - - 81: {fileID: 2074703091} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &2074703091 -AudioListener: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2074703090} - m_Enabled: 1 ---- !u!124 &2074703092 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2074703090} - m_Enabled: 1 ---- !u!92 &2074703093 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2074703090} - m_Enabled: 1 ---- !u!20 &2074703094 -Camera: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2074703090} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 1 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 - m_StereoMirrorMode: 0 ---- !u!4 &2074703095 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2074703090} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 ---- !u!1 &2102338787 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 2102338788} - - 222: {fileID: 2102338790} - - 114: {fileID: 2102338789} - m_Layer: 5 - m_Name: Placeholder - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2102338788 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2102338787} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 566049661} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &2102338789 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2102338787} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 2 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: What needs to be done? ---- !u!222 &2102338790 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2102338787} ---- !u!1 &2136645851 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 224: {fileID: 2136645852} - - 222: {fileID: 2136645855} - - 114: {fileID: 2136645854} - - 114: {fileID: 2136645853} - m_Layer: 5 - m_Name: ClearButton - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2136645852 -RectTransform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2136645851} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 48390800} - m_Father: {fileID: 650625965} - m_RootOrder: 2 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &2136645853 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2136645851} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 2136645854} - m_OnClick: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null ---- !u!114 &2136645854 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2136645851} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &2136645855 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 2136645851} diff --git a/Assets/Plugins/UniRx/Examples/Sample13Scene.unity.meta b/Assets/Plugins/UniRx/Examples/Sample13Scene.unity.meta deleted file mode 100644 index 42dc203..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample13Scene.unity.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b879645f640b02b43a8e78e210c1da1f -timeCreated: 1455373896 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample13_ToDoApp.cs b/Assets/Plugins/UniRx/Examples/Sample13_ToDoApp.cs deleted file mode 100644 index 159e932..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample13_ToDoApp.cs +++ /dev/null @@ -1,68 +0,0 @@ -// 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.Linq; -using UnityEngine; -using UnityEngine.UI; -using System.Collections; -using UnityEngine.EventSystems; - -namespace UniRx.Examples -{ - public class Sample13_ToDoApp : MonoBehaviour - { - // Open Sample13Scene. Set from canvas - public Text Title; - public InputField ToDoInput; - public Button AddButton; - public Button ClearButton; - public GameObject TodoList; - - // prefab:) - public GameObject SampleItemPrefab; - - ReactiveCollection toDos = new ReactiveCollection(); - - void Start() - { - // merge Button click and push enter key on input field. - var submit = Observable.Merge( - AddButton.OnClickAsObservable().Select(_ => ToDoInput.text), - ToDoInput.OnEndEditAsObservable().Where(_ => Input.GetKeyDown(KeyCode.Return))); - - // add to reactive collection - submit.Where(x => x != "") - .Subscribe(x => - { - ToDoInput.text = ""; // clear input field - var item = Instantiate(SampleItemPrefab) as GameObject; - (item.GetComponentInChildren(typeof(Text)) as Text).text = x; - toDos.Add(item); - }); - - // Collection Change Handling - toDos.ObserveCountChanged().Subscribe(x => Title.text = "TODO App, ItemCount:" + x); - toDos.ObserveAdd().Subscribe(x => - { - x.Value.transform.SetParent(TodoList.transform, false); - }); - toDos.ObserveRemove().Subscribe(x => - { - GameObject.Destroy(x.Value); - }); - - // Clear - ClearButton.OnClickAsObservable() - .Subscribe(_ => - { - var removeTargets = toDos.Where(x => x.GetComponent().isOn).ToArray(); - foreach (var item in removeTargets) - { - toDos.Remove(item); - } - }); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Examples/Sample13_ToDoApp.cs.meta b/Assets/Plugins/UniRx/Examples/Sample13_ToDoApp.cs.meta deleted file mode 100644 index ca18a37..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample13_ToDoApp.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 022ecfa555367154c8cf87d61465f7e2 -timeCreated: 1455373897 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/Sample13_ToDoItem.prefab b/Assets/Plugins/UniRx/Examples/Sample13_ToDoItem.prefab deleted file mode 100644 index 1a976a1..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample13_ToDoItem.prefab +++ /dev/null @@ -1,284 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &152834 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 4 - m_Component: - - 224: {fileID: 22461494} - - 222: {fileID: 22298102} - - 114: {fileID: 11434412} - m_Layer: 5 - m_Name: Background - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &172388 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 4 - m_Component: - - 224: {fileID: 22491898} - - 222: {fileID: 22251748} - - 114: {fileID: 11438756} - m_Layer: 5 - m_Name: Label - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &174974 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 4 - m_Component: - - 224: {fileID: 22463654} - - 222: {fileID: 22278786} - - 114: {fileID: 11497312} - m_Layer: 5 - m_Name: Checkmark - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &182208 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 4 - m_Component: - - 224: {fileID: 22478562} - - 114: {fileID: 11479148} - m_Layer: 5 - m_Name: Sample13_ToDoItem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &11434412 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 152834} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!114 &11438756 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 172388} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: .196078435, g: .196078435, b: .196078435, a: 1} - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: 'TODOITEM - -' ---- !u!114 &11479148 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 182208} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1} - m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1} - m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814} - m_ColorMultiplier: 1 - m_FadeDuration: .100000001 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 11434412} - toggleTransition: 1 - graphic: {fileID: 11497312} - m_Group: {fileID: 0} - onValueChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.Toggle+ToggleEvent, UnityEngine.UI, Version=1.0.0.0, - Culture=neutral, PublicKeyToken=null - m_IsOn: 1 ---- !u!114 &11497312 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 174974} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 ---- !u!222 &22251748 -CanvasRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 172388} ---- !u!222 &22278786 -CanvasRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 174974} ---- !u!222 &22298102 -CanvasRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 152834} ---- !u!224 &22461494 -RectTransform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 152834} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 22463654} - m_Father: {fileID: 22478562} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 10, y: -10} - m_SizeDelta: {x: 20, y: 30} - m_Pivot: {x: .5, y: .5} ---- !u!224 &22463654 -RectTransform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 174974} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 22461494} - m_RootOrder: 0 - m_AnchorMin: {x: .5, y: .5} - m_AnchorMax: {x: .5, y: .5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 20, y: 30} - m_Pivot: {x: .5, y: .5} ---- !u!224 &22478562 -RectTransform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 182208} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 22461494} - - {fileID: 22491898} - m_Father: {fileID: 0} - m_RootOrder: 0 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: .5, y: .5} ---- !u!224 &22491898 -RectTransform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 172388} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 22478562} - m_RootOrder: 1 - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 9, y: -.5} - m_SizeDelta: {x: -28, y: -3} - m_Pivot: {x: .5, y: .5} ---- !u!1001 &100100000 -Prefab: - m_ObjectHideFlags: 1 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: [] - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 0} - m_RootGameObject: {fileID: 182208} - m_IsPrefabParent: 1 diff --git a/Assets/Plugins/UniRx/Examples/Sample13_ToDoItem.prefab.meta b/Assets/Plugins/UniRx/Examples/Sample13_ToDoItem.prefab.meta deleted file mode 100644 index cbe92f5..0000000 --- a/Assets/Plugins/UniRx/Examples/Sample13_ToDoItem.prefab.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 173222196f3e1f0448b383f260df7d44 -timeCreated: 1455373909 -licenseType: Pro -NativeFormatImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/UniRx.Examples.asmdef b/Assets/Plugins/UniRx/Examples/UniRx.Examples.asmdef deleted file mode 100644 index 6f5b9fd..0000000 --- a/Assets/Plugins/UniRx/Examples/UniRx.Examples.asmdef +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "UniRx.Examples", - "references": [ - "UniRx", - "UniRx.Async" - ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts.meta b/Assets/Plugins/UniRx/Scripts.meta index ce2a6dd..31d66f2 100644 --- a/Assets/Plugins/UniRx/Scripts.meta +++ b/Assets/Plugins/UniRx/Scripts.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: fa640d68fc4eb2042bbb273d3e3e0d09 +guid: eaf9ac9937118834c86197511fd5317f folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async.meta b/Assets/Plugins/UniRx/Scripts/Async.meta index bd70662..87d5782 100644 --- a/Assets/Plugins/UniRx/Scripts/Async.meta +++ b/Assets/Plugins/UniRx/Scripts/Async.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aa48969b4eb9be74589b999b5517b1d6 +guid: 471d36bf5d6b813439d3cdf18a24762c folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Plugins/UniRx/Scripts/Async/AsyncUnit.cs b/Assets/Plugins/UniRx/Scripts/Async/AsyncUnit.cs deleted file mode 100644 index 1a8f09d..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/AsyncUnit.cs +++ /dev/null @@ -1,28 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or - -using System; - -namespace UniRx.Async -{ - public struct AsyncUnit : IEquatable - { - public static readonly AsyncUnit Default = new AsyncUnit(); - - public override int GetHashCode() - { - return 0; - } - - public bool Equals(AsyncUnit other) - { - return true; - } - - public override string ToString() - { - return "()"; - } - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenEqualityComparer.cs b/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenEqualityComparer.cs deleted file mode 100644 index 72cdea2..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenEqualityComparer.cs +++ /dev/null @@ -1,25 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; - -namespace UniRx.Async -{ - public class CancellationTokenEqualityComparer : IEqualityComparer - { - public static readonly IEqualityComparer Default = new CancellationTokenEqualityComparer(); - - public bool Equals(CancellationToken x, CancellationToken y) - { - return x.Equals(y); - } - - public int GetHashCode(CancellationToken obj) - { - return obj.GetHashCode(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenExtensions.cs b/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenExtensions.cs deleted file mode 100644 index 8bfe4be..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenExtensions.cs +++ /dev/null @@ -1,76 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; - -namespace UniRx.Async -{ - public static class CancellationTokenExtensions - { - static readonly Action cancellationTokenCallback = Callback; - - public static (UniTask, CancellationTokenRegistration) ToUniTask(this CancellationToken cts) - { - if (cts.IsCancellationRequested) - { - return (UniTask.FromCanceled(cts), default(CancellationTokenRegistration)); - } - - var promise = new UniTaskCompletionSource(); - return (promise.Task, cts.RegisterWithoutCaptureExecutionContext(cancellationTokenCallback, promise)); - } - - static void Callback(object state) - { - var promise = (UniTaskCompletionSource)state; - promise.TrySetResult(AsyncUnit.Default); - } - - public static CancellationTokenRegistration RegisterWithoutCaptureExecutionContext(this CancellationToken cancellationToken, Action callback) - { - var restoreFlow = false; - if (!ExecutionContext.IsFlowSuppressed()) - { - ExecutionContext.SuppressFlow(); - restoreFlow = true; - } - - try - { - return cancellationToken.Register(callback, false); - } - finally - { - if (restoreFlow) - { - ExecutionContext.RestoreFlow(); - } - } - } - - public static CancellationTokenRegistration RegisterWithoutCaptureExecutionContext(this CancellationToken cancellationToken, Action callback, object state) - { - var restoreFlow = false; - if (!ExecutionContext.IsFlowSuppressed()) - { - ExecutionContext.SuppressFlow(); - restoreFlow = true; - } - - try - { - return cancellationToken.Register(callback, state, false); - } - finally - { - if (restoreFlow) - { - ExecutionContext.RestoreFlow(); - } - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenSourceExtensions.cs b/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenSourceExtensions.cs deleted file mode 100644 index 17618d7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenSourceExtensions.cs +++ /dev/null @@ -1,48 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Threading; -using UnityEngine; -using UniRx.Async.Triggers; -using System; - -namespace UniRx.Async -{ - public static class CancellationTokenSourceExtensions - { - public static void CancelAfterSlim(this CancellationTokenSource cts, int millisecondsDelay, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update) - { - var delay = UniTask.Delay(millisecondsDelay, ignoreTimeScale, delayTiming, cts.Token); - CancelAfterCore(cts, delay).Forget(); - } - - public static void CancelAfterSlim(this CancellationTokenSource cts, TimeSpan delayTimeSpan, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update) - { - var delay = UniTask.Delay(delayTimeSpan, ignoreTimeScale, delayTiming, cts.Token); - CancelAfterCore(cts, delay).Forget(); - } - - static async UniTaskVoid CancelAfterCore(CancellationTokenSource cts, UniTask delayTask) - { - var alreadyCanceled = await delayTask.SuppressCancellationThrow(); - if (!alreadyCanceled) - { - cts.Cancel(); - cts.Dispose(); - } - } - - public static void RegisterRaiseCancelOnDestroy(this CancellationTokenSource cts, Component component) - { - RegisterRaiseCancelOnDestroy(cts, component.gameObject); - } - - public static void RegisterRaiseCancelOnDestroy(this CancellationTokenSource cts, GameObject gameObject) - { - var trigger = gameObject.GetAsyncDestroyTrigger(); - trigger.AddCancellationTriggerOnDestory(cts); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices.meta b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices.meta index 92dc576..9f8958c 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices.meta +++ b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 522257e0538442a4b8de8de73b45a855 +guid: 4cddda24ae2fc764f803c153ed450761 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncMethodBuilderAttribute.cs b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncMethodBuilderAttribute.cs deleted file mode 100644 index b9658c9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncMethodBuilderAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -namespace System.Runtime.CompilerServices -{ - public sealed class AsyncMethodBuilderAttribute : Attribute - { - public Type BuilderType { get; } - - public AsyncMethodBuilderAttribute(Type builderType) - { - BuilderType = builderType; - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncMethodBuilderAttribute.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncMethodBuilderAttribute.cs.meta deleted file mode 100644 index 19961df..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncMethodBuilderAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 02ce354d37b10454e8376062f7cbe57a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskMethodBuilder.cs b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskMethodBuilder.cs deleted file mode 100644 index 586f859..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskMethodBuilder.cs +++ /dev/null @@ -1,274 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Security; - -namespace UniRx.Async.CompilerServices -{ - public struct AsyncUniTaskMethodBuilder - { - UniTaskCompletionSource promise; - Action moveNext; - - // 1. Static Create method. - [DebuggerHidden] - public static AsyncUniTaskMethodBuilder Create() - { - var builder = new AsyncUniTaskMethodBuilder(); - return builder; - } - - // 2. TaskLike Task property. - [DebuggerHidden] - public UniTask Task - { - get - { - if (promise != null) - { - return promise.Task; - } - - if (moveNext == null) - { - return UniTask.CompletedTask; - } - else - { - promise = new UniTaskCompletionSource(); - return promise.Task; - } - } - } - - // 3. SetException - [DebuggerHidden] - public void SetException(Exception exception) - { - if (promise == null) - { - promise = new UniTaskCompletionSource(); - } - if (exception is OperationCanceledException ex) - { - promise.TrySetCanceled(ex); - } - else - { - promise.TrySetException(exception); - } - } - - // 4. SetResult - [DebuggerHidden] - public void SetResult() - { - if (moveNext == null) - { - } - else - { - if (promise == null) - { - promise = new UniTaskCompletionSource(); - } - promise.TrySetResult(); - } - } - - // 5. AwaitOnCompleted - [DebuggerHidden] - public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : INotifyCompletion - where TStateMachine : IAsyncStateMachine - { - if (moveNext == null) - { - if (promise == null) - { - promise = new UniTaskCompletionSource(); // built future. - } - - var runner = new MoveNextRunner(); - moveNext = runner.Run; - runner.StateMachine = stateMachine; // set after create delegate. - } - - awaiter.OnCompleted(moveNext); - } - - // 6. AwaitUnsafeOnCompleted - [DebuggerHidden] - [SecuritySafeCritical] - public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : ICriticalNotifyCompletion - where TStateMachine : IAsyncStateMachine - { - if (moveNext == null) - { - if (promise == null) - { - promise = new UniTaskCompletionSource(); // built future. - } - - var runner = new MoveNextRunner(); - moveNext = runner.Run; - runner.StateMachine = stateMachine; // set after create delegate. - } - - awaiter.UnsafeOnCompleted(moveNext); - } - - // 7. Start - [DebuggerHidden] - public void Start(ref TStateMachine stateMachine) - where TStateMachine : IAsyncStateMachine - { - stateMachine.MoveNext(); - } - - // 8. SetStateMachine - [DebuggerHidden] - public void SetStateMachine(IAsyncStateMachine stateMachine) - { - } - } - - - public struct AsyncUniTaskMethodBuilder - { - T result; - UniTaskCompletionSource promise; - Action moveNext; - - // 1. Static Create method. - [DebuggerHidden] - public static AsyncUniTaskMethodBuilder Create() - { - var builder = new AsyncUniTaskMethodBuilder(); - return builder; - } - - // 2. TaskLike Task property. - [DebuggerHidden] - public UniTask Task - { - get - { - if (promise != null) - { - return new UniTask(promise); - } - - if (moveNext == null) - { - return new UniTask(result); - } - else - { - promise = new UniTaskCompletionSource(); - return new UniTask(promise); - } - } - } - - // 3. SetException - [DebuggerHidden] - public void SetException(Exception exception) - { - if (promise == null) - { - promise = new UniTaskCompletionSource(); - } - if (exception is OperationCanceledException ex) - { - promise.TrySetCanceled(ex); - } - else - { - promise.TrySetException(exception); - } - } - - // 4. SetResult - [DebuggerHidden] - public void SetResult(T result) - { - if (moveNext == null) - { - this.result = result; - } - else - { - if (promise == null) - { - promise = new UniTaskCompletionSource(); - } - promise.TrySetResult(result); - } - } - - // 5. AwaitOnCompleted - [DebuggerHidden] - public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : INotifyCompletion - where TStateMachine : IAsyncStateMachine - { - if (moveNext == null) - { - if (promise == null) - { - promise = new UniTaskCompletionSource(); // built future. - } - - var runner = new MoveNextRunner(); - moveNext = runner.Run; - runner.StateMachine = stateMachine; // set after create delegate. - } - - awaiter.OnCompleted(moveNext); - } - - // 6. AwaitUnsafeOnCompleted - [DebuggerHidden] - [SecuritySafeCritical] - public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : ICriticalNotifyCompletion - where TStateMachine : IAsyncStateMachine - { - if (moveNext == null) - { - if (promise == null) - { - promise = new UniTaskCompletionSource(); // built future. - } - - var runner = new MoveNextRunner(); - moveNext = runner.Run; - runner.StateMachine = stateMachine; // set after create delegate. - } - - awaiter.UnsafeOnCompleted(moveNext); - } - - // 7. Start - [DebuggerHidden] - public void Start(ref TStateMachine stateMachine) - where TStateMachine : IAsyncStateMachine - { - stateMachine.MoveNext(); - } - - // 8. SetStateMachine - [DebuggerHidden] - public void SetStateMachine(IAsyncStateMachine stateMachine) - { - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskMethodBuilder.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskMethodBuilder.cs.meta deleted file mode 100644 index ad43cfc..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskMethodBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 68d72a45afdec574ebc26e7de2c38330 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs deleted file mode 100644 index 2fcd55f..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs +++ /dev/null @@ -1,90 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Security; - -namespace UniRx.Async.CompilerServices -{ - public struct AsyncUniTaskVoidMethodBuilder - { - Action moveNext; - - // 1. Static Create method. - [DebuggerHidden] - public static AsyncUniTaskVoidMethodBuilder Create() - { - var builder = new AsyncUniTaskVoidMethodBuilder(); - return builder; - } - - // 2. TaskLike Task property(void) - public UniTaskVoid Task => default(UniTaskVoid); - - // 3. SetException - [DebuggerHidden] - public void SetException(Exception exception) - { - UniTaskScheduler.PublishUnobservedTaskException(exception); - } - - // 4. SetResult - [DebuggerHidden] - public void SetResult() - { - // do nothing - } - - // 5. AwaitOnCompleted - [DebuggerHidden] - public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : INotifyCompletion - where TStateMachine : IAsyncStateMachine - { - if (moveNext == null) - { - var runner = new MoveNextRunner(); - moveNext = runner.Run; - runner.StateMachine = stateMachine; // set after create delegate. - } - - awaiter.OnCompleted(moveNext); - } - - // 6. AwaitUnsafeOnCompleted - [DebuggerHidden] - [SecuritySafeCritical] - public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : ICriticalNotifyCompletion - where TStateMachine : IAsyncStateMachine - { - if (moveNext == null) - { - var runner = new MoveNextRunner(); - moveNext = runner.Run; - runner.StateMachine = stateMachine; // set after create delegate. - } - - awaiter.UnsafeOnCompleted(moveNext); - } - - // 7. Start - [DebuggerHidden] - public void Start(ref TStateMachine stateMachine) - where TStateMachine : IAsyncStateMachine - { - stateMachine.MoveNext(); - } - - // 8. SetStateMachine - [DebuggerHidden] - public void SetStateMachine(IAsyncStateMachine stateMachine) - { - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs.meta deleted file mode 100644 index 9bcc50e..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e891aaac17b933a47a9d7fa3b8e1226f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/MoveNextRunner.cs b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/MoveNextRunner.cs deleted file mode 100644 index ddf7a03..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/MoveNextRunner.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace UniRx.Async.CompilerServices -{ - internal class MoveNextRunner - where TStateMachine : IAsyncStateMachine - { - public TStateMachine StateMachine; - - [DebuggerHidden] - public void Run() - { - StateMachine.MoveNext(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/MoveNextRunner.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/MoveNextRunner.cs.meta deleted file mode 100644 index 2cb82e0..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/CompilerServices/MoveNextRunner.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 98649642833cabf44a9dc060ce4c84a1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/DiagnosticsExtensions.cs b/Assets/Plugins/UniRx/Scripts/Async/DiagnosticsExtensions.cs deleted file mode 100644 index 041b0c3..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/DiagnosticsExtensions.cs +++ /dev/null @@ -1,270 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Security; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace UniRx.Async -{ - public static class DiagnosticsExtensions - { - static bool displayFilenames = true; - - static readonly Regex typeBeautifyRegex = new Regex("`.+$", RegexOptions.Compiled); - - static readonly Dictionary builtInTypeNames = new Dictionary - { - { typeof(void), "void" }, - { typeof(bool), "bool" }, - { typeof(byte), "byte" }, - { typeof(char), "char" }, - { typeof(decimal), "decimal" }, - { typeof(double), "double" }, - { typeof(float), "float" }, - { typeof(int), "int" }, - { typeof(long), "long" }, - { typeof(object), "object" }, - { typeof(sbyte), "sbyte" }, - { typeof(short), "short" }, - { typeof(string), "string" }, - { typeof(uint), "uint" }, - { typeof(ulong), "ulong" }, - { typeof(ushort), "ushort" }, - { typeof(Task), "Task" }, - { typeof(UniTask), "UniTask" }, - { typeof(UniTaskVoid), "UniTaskVoid" } - }; - - public static string ToStringWithCleanupAsyncStackTrace(this Exception exception) - { - if (exception == null) return ""; - - String message = exception.Message; - String s; - - if (message == null || message.Length <= 0) - { - s = exception.GetType().ToString(); - } - else - { - s = exception.GetType().ToString() + ": " + message; - } - - if (exception.InnerException != null) - { - s = s + " ---> " + exception.InnerException.ToString() + Environment.NewLine + " Exception_EndOfInnerExceptionStack"; - } - - string stackTrace = new StackTrace(exception).CleanupAsyncStackTrace(); - if (stackTrace != null) - { - s += Environment.NewLine + stackTrace; - } - - return s; - } - - public static string CleanupAsyncStackTrace(this StackTrace stackTrace) - { - if (stackTrace == null) return ""; - - var sb = new StringBuilder(); - for (int i = 0; i < stackTrace.FrameCount; i++) - { - var sf = stackTrace.GetFrame(i); - - var mb = sf.GetMethod(); - - if (IgnoreLine(mb)) continue; - if (IsAsync(mb)) - { - sb.Append("async "); - TryResolveStateMachineMethod(ref mb, out var decType); - } - - // return type - if (mb is MethodInfo mi) - { - sb.Append(BeautifyType(mi.ReturnType, false)); - sb.Append(" "); - } - - // method name - sb.Append(BeautifyType(mb.DeclaringType, false)); - if (!mb.IsConstructor) - { - sb.Append("."); - } - sb.Append(mb.Name); - if (mb.IsGenericMethod) - { - sb.Append("<"); - foreach (var item in mb.GetGenericArguments()) - { - sb.Append(BeautifyType(item, true)); - } - sb.Append(">"); - } - - // parameter - sb.Append("("); - sb.Append(string.Join(", ", mb.GetParameters().Select(p => BeautifyType(p.ParameterType, true) + " " + p.Name))); - sb.Append(")"); - - // file name - if (displayFilenames && (sf.GetILOffset() != -1)) - { - String fileName = null; - - try - { - fileName = sf.GetFileName(); - } - catch (NotSupportedException) - { - displayFilenames = false; - } - catch (SecurityException) - { - displayFilenames = false; - } - - if (fileName != null) - { - sb.Append(' '); - sb.AppendFormat(CultureInfo.InvariantCulture, "in {0}:{1}", SimplifyPath(fileName), sf.GetFileLineNumber()); - } - } - - sb.AppendLine(); - } - return sb.ToString(); - } - - - static bool IsAsync(MethodBase methodInfo) - { - var declareType = methodInfo.DeclaringType; - return typeof(IAsyncStateMachine).IsAssignableFrom(declareType); - } - - // code from Ben.Demystifier/EnhancedStackTrace.Frame.cs - static bool TryResolveStateMachineMethod(ref MethodBase method, out Type declaringType) - { - declaringType = method.DeclaringType; - - var parentType = declaringType.DeclaringType; - if (parentType == null) - { - return false; - } - - var methods = parentType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly); - if (methods == null) - { - return false; - } - - foreach (var candidateMethod in methods) - { - var attributes = candidateMethod.GetCustomAttributes(); - if (attributes == null) - { - continue; - } - - foreach (var asma in attributes) - { - if (asma.StateMachineType == declaringType) - { - method = candidateMethod; - declaringType = candidateMethod.DeclaringType; - // Mark the iterator as changed; so it gets the + annotation of the original method - // async statemachines resolve directly to their builder methods so aren't marked as changed - return asma is IteratorStateMachineAttribute; - } - } - } - - return false; - } - - static string BeautifyType(Type t, bool shortName) - { - if (builtInTypeNames.TryGetValue(t, out var builtin)) - { - return builtin; - } - if (t.IsGenericParameter) return t.Name; - if (t.IsArray) return BeautifyType(t.GetElementType(), shortName) + "[]"; - if (t.FullName?.StartsWith("System.ValueTuple") ?? false) - { - return "(" + string.Join(", ", t.GetGenericArguments().Select(x => BeautifyType(x, true))) + ")"; - } - if (!t.IsGenericType) return shortName ? t.Name : t.FullName ?? t.Name; - - var innerFormat = string.Join(", ", t.GetGenericArguments().Select(x => BeautifyType(x, true))); - - var genericType = t.GetGenericTypeDefinition().FullName; - if (genericType == "System.Threading.Tasks.Task`1") - { - genericType = "Task"; - } - - return typeBeautifyRegex.Replace(genericType, "") + "<" + innerFormat + ">"; - } - - static bool IgnoreLine(MethodBase methodInfo) - { - var declareType = methodInfo.DeclaringType.FullName; - if (declareType == "System.Threading.ExecutionContext") - { - return true; - } - else if (declareType.StartsWith("System.Runtime.CompilerServices")) - { - return true; - } - else if (declareType.StartsWith("UniRx.Async.CompilerServices")) - { - return true; - } - else if (declareType == "System.Threading.Tasks.AwaitTaskContinuation") - { - return true; - } - else if (declareType.StartsWith("System.Threading.Tasks.Task")) - { - return true; - } - - return false; - } - - static string SimplifyPath(string path) - { - var fi = new FileInfo(path); - if (fi.Directory == null) - { - return fi.Name; - } - else - { - return fi.Directory.Name + "/" + fi.Name; - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/DiagnosticsExtensions.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/DiagnosticsExtensions.cs.meta deleted file mode 100644 index 6c1f06c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/DiagnosticsExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f80fb1c9ed4c99447be1b0a47a8d980b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor.meta b/Assets/Plugins/UniRx/Scripts/Async/Editor.meta index 40bc442..4211ee2 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor.meta +++ b/Assets/Plugins/UniRx/Scripts/Async/Editor.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b137462cdaca62241abbbe13cdf5c8ec +guid: fc29e5d0ccd114140b288e0a89645780 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor/SplitterGUILayout.cs b/Assets/Plugins/UniRx/Scripts/Async/Editor/SplitterGUILayout.cs deleted file mode 100644 index bca6a95..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor/SplitterGUILayout.cs +++ /dev/null @@ -1,64 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Linq; -using System.Reflection; -using UnityEditor; -using UnityEngine; - -namespace UniRx.Async.Editor -{ - // reflection call of UnityEditor.SplitterGUILayout - internal static class SplitterGUILayout - { - static BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - - static Lazy splitterStateType = new Lazy(() => - { - var type = typeof(EditorWindow).Assembly.GetTypes().First(x => x.FullName == "UnityEditor.SplitterState"); - return type; - }); - - static Lazy splitterStateCtor = new Lazy(() => - { - var type = splitterStateType.Value; - return type.GetConstructor(flags, null, new Type[] { typeof(float[]), typeof(int[]), typeof(int[]) }, null); - }); - - static Lazy splitterGUILayoutType = new Lazy(() => - { - var type = typeof(EditorWindow).Assembly.GetTypes().First(x => x.FullName == "UnityEditor.SplitterGUILayout"); - return type; - }); - - static Lazy beginVerticalSplit = new Lazy(() => - { - var type = splitterGUILayoutType.Value; - return type.GetMethod("BeginVerticalSplit", flags, null, new Type[] { splitterStateType.Value, typeof(GUILayoutOption[]) }, null); - }); - - static Lazy endVerticalSplit = new Lazy(() => - { - var type = splitterGUILayoutType.Value; - return type.GetMethod("EndVerticalSplit", flags, null, Type.EmptyTypes, null); - }); - - public static object CreateSplitterState(float[] relativeSizes, int[] minSizes, int[] maxSizes) - { - return splitterStateCtor.Value.Invoke(new object[] { relativeSizes, minSizes, maxSizes }); - } - - public static void BeginVerticalSplit(object splitterState, params GUILayoutOption[] options) - { - beginVerticalSplit.Value.Invoke(null, new object[] { splitterState, options }); - } - - public static void EndVerticalSplit() - { - endVerticalSplit.Value.Invoke(null, Type.EmptyTypes); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor/SplitterGUILayout.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Editor/SplitterGUILayout.cs.meta deleted file mode 100644 index 4d718f4..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor/SplitterGUILayout.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 40ef2e46f900131419e869398a8d3c9d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniRx.Async.Editor.asmdef b/Assets/Plugins/UniRx/Scripts/Async/Editor/UniRx.Async.Editor.asmdef deleted file mode 100644 index 37c0de4..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniRx.Async.Editor.asmdef +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "UniRx.Async.Editor", - "references": [ - "UniRx.Async" - ], - "optionalUnityReferences": [], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerTreeView.cs b/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerTreeView.cs deleted file mode 100644 index 7e03931..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerTreeView.cs +++ /dev/null @@ -1,180 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System; -using UnityEditor.IMGUI.Controls; -using UniRx.Async.Internal; -using System.Text; - -namespace UniRx.Async.Editor -{ - public class UniTaskTrackerViewItem : TreeViewItem - { - public string TaskType { get; set; } - public string Elapsed { get; set; } - public string Status { get; set; } - - string position; - public string Position - { - get { return position; } - set - { - position = value; - PositionFirstLine = GetFirstLine(position); - } - } - - public string PositionFirstLine { get; private set; } - - static string GetFirstLine(string str) - { - var sb = new StringBuilder(); - for (int i = 0; i < str.Length; i++) - { - if (str[i] == '\r' || str[i] == '\n') - { - break; - } - sb.Append(str[i]); - } - return sb.ToString(); - } - - public UniTaskTrackerViewItem(int id) : base(id) - { - - } - } - - public class UniTaskTrackerTreeView : TreeView - { - const string sortedColumnIndexStateKey = "UniTaskTrackerTreeView_sortedColumnIndex"; - - public IReadOnlyList CurrentBindingItems; - - public UniTaskTrackerTreeView() - : this(new TreeViewState(), new MultiColumnHeader(new MultiColumnHeaderState(new[] - { - new MultiColumnHeaderState.Column() { headerContent = new GUIContent("TaskType"), width = 20}, - new MultiColumnHeaderState.Column() { headerContent = new GUIContent("Elapsed"), width = 10}, - new MultiColumnHeaderState.Column() { headerContent = new GUIContent("Status"), width = 10}, - new MultiColumnHeaderState.Column() { headerContent = new GUIContent("Position")}, - }))) - { - } - - UniTaskTrackerTreeView(TreeViewState state, MultiColumnHeader header) - : base(state, header) - { - rowHeight = 20; - showAlternatingRowBackgrounds = true; - showBorder = true; - header.sortingChanged += Header_sortingChanged; - - header.ResizeToFit(); - Reload(); - - header.sortedColumnIndex = SessionState.GetInt(sortedColumnIndexStateKey, 1); - } - - public void ReloadAndSort() - { - var currentSelected = this.state.selectedIDs; - Reload(); - Header_sortingChanged(this.multiColumnHeader); - this.state.selectedIDs = currentSelected; - } - - private void Header_sortingChanged(MultiColumnHeader multiColumnHeader) - { - SessionState.SetInt(sortedColumnIndexStateKey, multiColumnHeader.sortedColumnIndex); - var index = multiColumnHeader.sortedColumnIndex; - var ascending = multiColumnHeader.IsSortedAscending(multiColumnHeader.sortedColumnIndex); - - var items = rootItem.children.Cast(); - - IOrderedEnumerable orderedEnumerable; - switch (index) - { - case 0: - orderedEnumerable = ascending ? items.OrderBy(item => item.TaskType) : items.OrderByDescending(item => item.TaskType); - break; - case 1: - orderedEnumerable = ascending ? items.OrderBy(item => double.Parse(item.Elapsed)) : items.OrderByDescending(item => double.Parse(item.Elapsed)); - break; - case 2: - orderedEnumerable = ascending ? items.OrderBy(item => item.Status) : items.OrderByDescending(item => item.Elapsed); - break; - case 3: - orderedEnumerable = ascending ? items.OrderBy(item => item.Position) : items.OrderByDescending(item => item.PositionFirstLine); - break; - default: - throw new ArgumentOutOfRangeException(nameof(index), index, null); - } - - CurrentBindingItems = rootItem.children = orderedEnumerable.Cast().ToList(); - BuildRows(rootItem); - } - - protected override TreeViewItem BuildRoot() - { - var root = new TreeViewItem { depth = -1 }; - - var children = new List(); - - TaskTracker.ForEachActiveTask((trackingId, awaiterType, status, created, stackTrace) => - { - children.Add(new UniTaskTrackerViewItem(trackingId) { TaskType = awaiterType, Status = status.ToString(), Elapsed = (DateTime.UtcNow - created).TotalSeconds.ToString("00.00"), Position = stackTrace }); - }); - - CurrentBindingItems = children; - root.children = CurrentBindingItems as List; - return root; - } - - protected override bool CanMultiSelect(TreeViewItem item) - { - return false; - } - - protected override void RowGUI(RowGUIArgs args) - { - var item = args.item as UniTaskTrackerViewItem; - - for (var visibleColumnIndex = 0; visibleColumnIndex < args.GetNumVisibleColumns(); visibleColumnIndex++) - { - var rect = args.GetCellRect(visibleColumnIndex); - var columnIndex = args.GetColumn(visibleColumnIndex); - - var labelStyle = args.selected ? EditorStyles.whiteLabel : EditorStyles.label; - labelStyle.alignment = TextAnchor.MiddleLeft; - switch (columnIndex) - { - case 0: - EditorGUI.LabelField(rect, item.TaskType, labelStyle); - break; - case 1: - EditorGUI.LabelField(rect, item.Elapsed, labelStyle); - break; - case 2: - EditorGUI.LabelField(rect, item.Status, labelStyle); - break; - case 3: - EditorGUI.LabelField(rect, item.PositionFirstLine, labelStyle); - break; - default: - throw new ArgumentOutOfRangeException(nameof(columnIndex), columnIndex, null); - } - } - } - } - -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerTreeView.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerTreeView.cs.meta deleted file mode 100644 index 9b34d7b..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerTreeView.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 52e2d973a2156674e8c1c9433ed031f7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerWindow.cs b/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerWindow.cs deleted file mode 100644 index 5acb2c4..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerWindow.cs +++ /dev/null @@ -1,211 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System; -using UnityEditor.IMGUI.Controls; -using UniRx.Async.Internal; - -namespace UniRx.Async.Editor -{ - public class UniTaskTrackerWindow : EditorWindow - { - static int interval; - - static UniTaskTrackerWindow window; - - [MenuItem("Window/UniRx/UniTask Tracker")] - public static void OpenWindow() - { - if (window != null) - { - window.Close(); - } - - // will called OnEnable(singleton instance will be set). - GetWindow("UniTask Tracker").Show(); - } - - static readonly GUILayoutOption[] EmptyLayoutOption = new GUILayoutOption[0]; - - UniTaskTrackerTreeView treeView; - object splitterState; - - void OnEnable() - { - window = this; // set singleton. - splitterState = SplitterGUILayout.CreateSplitterState(new float[] { 75f, 25f }, new int[] { 32, 32 }, null); - treeView = new UniTaskTrackerTreeView(); - TaskTracker.EditorEnableState.EnableAutoReload = EditorPrefs.GetBool(TaskTracker.EnableAutoReloadKey, false); - TaskTracker.EditorEnableState.EnableTracking = EditorPrefs.GetBool(TaskTracker.EnableTrackingKey, false); - TaskTracker.EditorEnableState.EnableStackTrace = EditorPrefs.GetBool(TaskTracker.EnableStackTraceKey, false); - } - - void OnGUI() - { - // Head - RenderHeadPanel(); - - // Splittable - SplitterGUILayout.BeginVerticalSplit(this.splitterState, EmptyLayoutOption); - { - // Column Tabble - RenderTable(); - - // StackTrace details - RenderDetailsPanel(); - } - SplitterGUILayout.EndVerticalSplit(); - } - - #region HeadPanel - - public static bool EnableAutoReload => TaskTracker.EditorEnableState.EnableAutoReload; - public static bool EnableTracking => TaskTracker.EditorEnableState.EnableTracking; - public static bool EnableStackTrace => TaskTracker.EditorEnableState.EnableStackTrace; - static readonly GUIContent EnableAutoReloadHeadContent = EditorGUIUtility.TrTextContent("Enable AutoReload", "Reload automatically.", (Texture)null); - static readonly GUIContent ReloadHeadContent = EditorGUIUtility.TrTextContent("Reload", "Reload View.", (Texture)null); - static readonly GUIContent GCHeadContent = EditorGUIUtility.TrTextContent("GC.Collect", "Invoke GC.Collect.", (Texture)null); - static readonly GUIContent EnableTrackingHeadContent = EditorGUIUtility.TrTextContent("Enable Tracking", "Start to track async/await UniTask. Performance impact: low", (Texture)null); - static readonly GUIContent EnableStackTraceHeadContent = EditorGUIUtility.TrTextContent("Enable StackTrace", "Capture StackTrace when task is started. Performance impact: high", (Texture)null); - - // [Enable Tracking] | [Enable StackTrace] - void RenderHeadPanel() - { - EditorGUILayout.BeginVertical(EmptyLayoutOption); - EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, EmptyLayoutOption); - - if (GUILayout.Toggle(EnableAutoReload, EnableAutoReloadHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption) != EnableAutoReload) - { - TaskTracker.EditorEnableState.EnableAutoReload = !EnableAutoReload; - } - - if (GUILayout.Toggle(EnableTracking, EnableTrackingHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption) != EnableTracking) - { - TaskTracker.EditorEnableState.EnableTracking = !EnableTracking; - } - - if (GUILayout.Toggle(EnableStackTrace, EnableStackTraceHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption) != EnableStackTrace) - { - TaskTracker.EditorEnableState.EnableStackTrace = !EnableStackTrace; - } - - GUILayout.FlexibleSpace(); - - if (GUILayout.Button(ReloadHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption)) - { - TaskTracker.CheckAndResetDirty(); - treeView.ReloadAndSort(); - Repaint(); - } - - if (GUILayout.Button(GCHeadContent, EditorStyles.toolbarButton, EmptyLayoutOption)) - { - GC.Collect(0); - } - - EditorGUILayout.EndHorizontal(); - EditorGUILayout.EndVertical(); - } - - #endregion - - #region TableColumn - - Vector2 tableScroll; - GUIStyle tableListStyle; - - void RenderTable() - { - if (tableListStyle == null) - { - tableListStyle = new GUIStyle("CN Box"); - tableListStyle.margin.top = 0; - tableListStyle.padding.left = 3; - } - - EditorGUILayout.BeginVertical(tableListStyle, EmptyLayoutOption); - - this.tableScroll = EditorGUILayout.BeginScrollView(this.tableScroll, new GUILayoutOption[] - { - GUILayout.ExpandWidth(true), - GUILayout.MaxWidth(2000f) - }); - var controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[] - { - GUILayout.ExpandHeight(true), - GUILayout.ExpandWidth(true) - }); - - - treeView?.OnGUI(controlRect); - - EditorGUILayout.EndScrollView(); - EditorGUILayout.EndVertical(); - } - - private void Update() - { - if (EnableAutoReload) - { - if (interval++ % 120 == 0) - { - if (TaskTracker.CheckAndResetDirty()) - { - treeView.ReloadAndSort(); - Repaint(); - } - } - } - } - - #endregion - - #region Details - - static GUIStyle detailsStyle; - Vector2 detailsScroll; - - void RenderDetailsPanel() - { - if (detailsStyle == null) - { - detailsStyle = new GUIStyle(EditorStyles.wordWrappedLabel); - detailsStyle.wordWrap = false; - detailsStyle.stretchHeight = true; - detailsStyle.margin.right = 15; - } - - string message = ""; - var selected = treeView.state.selectedIDs; - if (selected.Count > 0) - { - var first = selected[0]; - var item = treeView.CurrentBindingItems.FirstOrDefault(x => x.id == first) as UniTaskTrackerViewItem; - if (item != null) - { - message = item.Position; - } - } - - detailsScroll = EditorGUILayout.BeginScrollView(this.detailsScroll, EmptyLayoutOption); - var vector = detailsStyle.CalcSize(new GUIContent(message)); - EditorGUILayout.SelectableLabel(message, detailsStyle, new GUILayoutOption[] - { - GUILayout.ExpandHeight(true), - GUILayout.ExpandWidth(true), - GUILayout.MinWidth(vector.x), - GUILayout.MinHeight(vector.y) - }); - EditorGUILayout.EndScrollView(); - } - - #endregion - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerWindow.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerWindow.cs.meta deleted file mode 100644 index ba1b704..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniTaskTrackerWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5bee3e3860e37484aa3b861bf76d129f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/EnumerableAsyncExtensions.cs b/Assets/Plugins/UniRx/Scripts/Async/EnumerableAsyncExtensions.cs deleted file mode 100644 index 344ccc4..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/EnumerableAsyncExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; - -namespace UniRx.Async -{ - public static class EnumerableAsyncExtensions - { - // overload resolver - .Select(async x => { }) : IEnumerable> - - public static IEnumerable Select(this IEnumerable source, Func selector) - { - return System.Linq.Enumerable.Select(source, selector); - } - - public static IEnumerable> Select(this IEnumerable source, Func> selector) - { - return System.Linq.Enumerable.Select(source, selector); - } - - public static IEnumerable Select(this IEnumerable source, Func selector) - { - return System.Linq.Enumerable.Select(source, selector); - } - - public static IEnumerable> Select(this IEnumerable source, Func> selector) - { - return System.Linq.Enumerable.Select(source, selector); - } - } -} - - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/EnumerableAsyncExtensions.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/EnumerableAsyncExtensions.cs.meta deleted file mode 100644 index d2e4930..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/EnumerableAsyncExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ff50260d74bd54c4b92cf99895549445 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/EnumeratorAsyncExtensions.cs b/Assets/Plugins/UniRx/Scripts/Async/EnumeratorAsyncExtensions.cs deleted file mode 100644 index 5f3411e..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/EnumeratorAsyncExtensions.cs +++ /dev/null @@ -1,149 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections; -using System.Runtime.ExceptionServices; -using System.Threading; -using UniRx.Async.Internal; - -namespace UniRx.Async -{ - public static class EnumeratorAsyncExtensions - { - public static IAwaiter GetAwaiter(this IEnumerator enumerator) - { - var awaiter = new EnumeratorAwaiter(enumerator, CancellationToken.None); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, awaiter); - } - return awaiter; - } - - public static UniTask ToUniTask(this IEnumerator enumerator) - { - var awaiter = new EnumeratorAwaiter(enumerator, CancellationToken.None); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, awaiter); - } - return new UniTask(awaiter); - } - - public static UniTask ConfigureAwait(this IEnumerator enumerator, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken)) - { - var awaiter = new EnumeratorAwaiter(enumerator, cancellationToken); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(timing, awaiter); - } - return new UniTask(awaiter); - } - - class EnumeratorAwaiter : IAwaiter, IPlayerLoopItem - { - IEnumerator innerEnumerator; - CancellationToken cancellationToken; - Action continuation; - AwaiterStatus status; - ExceptionDispatchInfo exception; - - public EnumeratorAwaiter(IEnumerator innerEnumerator, CancellationToken cancellationToken) - { - if (cancellationToken.IsCancellationRequested) - { - status = AwaiterStatus.Canceled; - return; - } - - this.innerEnumerator = innerEnumerator; - this.status = AwaiterStatus.Pending; - this.cancellationToken = cancellationToken; - this.continuation = null; - - TaskTracker.TrackActiveTask(this, 2); - } - - public bool IsCompleted => status.IsCompleted(); - - public AwaiterStatus Status => status; - - public void GetResult() - { - switch (status) - { - case AwaiterStatus.Succeeded: - break; - case AwaiterStatus.Pending: - Error.ThrowNotYetCompleted(); - break; - case AwaiterStatus.Faulted: - exception.Throw(); - break; - case AwaiterStatus.Canceled: - Error.ThrowOperationCanceledException(); - break; - default: - break; - } - } - - public bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - InvokeContinuation(AwaiterStatus.Canceled); - return false; - } - - var success = false; - try - { - if (innerEnumerator.MoveNext()) - { - return true; - } - else - { - success = true; - } - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - } - - InvokeContinuation(success ? AwaiterStatus.Succeeded : AwaiterStatus.Faulted); - return false; - } - - void InvokeContinuation(AwaiterStatus status) - { - this.status = status; - var cont = this.continuation; - - // cleanup - TaskTracker.RemoveTracking(this); - this.continuation = null; - this.cancellationToken = CancellationToken.None; - this.innerEnumerator = null; - - if (cont != null) cont.Invoke(); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = continuation; - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/EnumeratorAsyncExtensions.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/EnumeratorAsyncExtensions.cs.meta deleted file mode 100644 index a07b336..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/EnumeratorAsyncExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bc661232f11e4a741af54ba1c175d5ee -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/IAwaiter.cs b/Assets/Plugins/UniRx/Scripts/Async/IAwaiter.cs deleted file mode 100644 index 6450ea5..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/IAwaiter.cs +++ /dev/null @@ -1,64 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 - -using System.Runtime.CompilerServices; - -namespace UniRx.Async -{ - public enum AwaiterStatus - { - /// The operation has not yet completed. - Pending = 0, - /// The operation completed successfully. - Succeeded = 1, - /// The operation completed with an error. - Faulted = 2, - /// The operation completed due to cancellation. - Canceled = 3 - } - - public interface IAwaiter : ICriticalNotifyCompletion - { - AwaiterStatus Status { get; } - bool IsCompleted { get; } - void GetResult(); - } - - public interface IAwaiter : IAwaiter - { - new T GetResult(); - } - - public static class AwaiterStatusExtensions - { - /// != Pending. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsCompleted(this AwaiterStatus status) - { - return status != AwaiterStatus.Pending; - } - - /// == Succeeded. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsCompletedSuccessfully(this AwaiterStatus status) - { - return status == AwaiterStatus.Succeeded; - } - - /// == Canceled. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsCanceled(this AwaiterStatus status) - { - return status == AwaiterStatus.Canceled; - } - - /// == Faulted. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsFaulted(this AwaiterStatus status) - { - return status == AwaiterStatus.Faulted; - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/IAwaiter.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/IAwaiter.cs.meta deleted file mode 100644 index b225d1c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/IAwaiter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3e4d023d8404ab742b5e808c98097c3c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPool.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPool.cs deleted file mode 100644 index 75bc2f9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPool.cs +++ /dev/null @@ -1,152 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; - -namespace UniRx.Async.Internal -{ - // Same interface as System.Buffers.ArrayPool but only provides Shared. - - public sealed class ArrayPool // public, can use from other assembly. - { - // Same size as System.Buffers.DefaultArrayPool - const int DefaultMaxNumberOfArraysPerBucket = 50; - - static readonly T[] EmptyArray = new T[0]; - - public static readonly ArrayPool Shared = new ArrayPool(); - - readonly MinimumQueue[] buckets; - readonly SpinLock[] locks; - - ArrayPool() - { - // see: GetQueueIndex - buckets = new MinimumQueue[18]; - locks = new SpinLock[18]; - for (int i = 0; i < buckets.Length; i++) - { - buckets[i] = new MinimumQueue(4); - locks[i] = new SpinLock(false); - } - } - - public T[] Rent(int minimumLength) - { - if (minimumLength < 0) - { - throw new ArgumentOutOfRangeException("minimumLength"); - } - else if (minimumLength == 0) - { - return EmptyArray; - } - - var size = CalculateSize(minimumLength); - var index = GetQueueIndex(size); - if (index != -1) - { - var q = buckets[index]; - var lockTaken = false; - try - { - locks[index].Enter(ref lockTaken); - - if (q.Count != 0) - { - return q.Dequeue(); - } - } - finally - { - if (lockTaken) locks[index].Exit(false); - } - } - - return new T[size]; - } - - public void Return(T[] array, bool clearArray = false) - { - if (array == null || array.Length == 0) - { - return; - } - - var index = GetQueueIndex(array.Length); - if (index != -1) - { - if (clearArray) - { - Array.Clear(array, 0, array.Length); - } - - var q = buckets[index]; - var lockTaken = false; - - try - { - locks[index].Enter(ref lockTaken); - - if (q.Count > DefaultMaxNumberOfArraysPerBucket) - { - return; - } - - q.Enqueue(array); - } - finally - { - if (lockTaken) locks[index].Exit(false); - } - } - } - - static int CalculateSize(int size) - { - size--; - size |= size >> 1; - size |= size >> 2; - size |= size >> 4; - size |= size >> 8; - size |= size >> 16; - size += 1; - - if (size < 8) - { - size = 8; - } - - return size; - } - - static int GetQueueIndex(int size) - { - switch (size) - { - case 8: return 0; - case 16: return 1; - case 32: return 2; - case 64: return 3; - case 128: return 4; - case 256: return 5; - case 512: return 6; - case 1024: return 7; - case 2048: return 8; - case 4096: return 9; - case 8192: return 10; - case 16384: return 11; - case 32768: return 12; - case 65536: return 13; - case 131072: return 14; - case 262144: return 15; - case 524288: return 16; - case 1048576: return 17; // max array length - default: - return -1; - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPool.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPool.cs.meta deleted file mode 100644 index 693816c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPool.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f83ebad81fb89fb4882331616ca6d248 -timeCreated: 1532361008 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPoolUtil.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPoolUtil.cs deleted file mode 100644 index 5f9ae6a..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPoolUtil.cs +++ /dev/null @@ -1,112 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; - -namespace UniRx.Async.Internal -{ - public static class ArrayPoolUtil - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void EnsureCapacity(ref T[] array, int index, ArrayPool pool) - { - if (array.Length <= index) - { - EnsureCapacityCore(ref array, index, pool); - } - } - - [MethodImpl(MethodImplOptions.NoInlining)] - static void EnsureCapacityCore(ref T[] array, int index, ArrayPool pool) - { - if (array.Length <= index) - { - var newSize = array.Length * 2; - var newArray = pool.Rent((index < newSize) ? newSize : (index * 2)); - Array.Copy(array, 0, newArray, 0, array.Length); - - pool.Return(array, clearArray: !RuntimeHelpersAbstraction.IsWellKnownNoReferenceContainsType()); - - array = newArray; - } - } - - public static RentArray Materialize(IEnumerable source) - { - if (source is T[] array) - { - return new RentArray(array, array.Length, null); - } - - var defaultCount = 4; - if (source is ICollection coll) - { - defaultCount = coll.Count; - var pool = ArrayPool.Shared; - var buffer = pool.Rent(defaultCount); - coll.CopyTo(buffer, 0); - return new RentArray(buffer, coll.Count, pool); - } - else if (source is IReadOnlyCollection rcoll) - { - defaultCount = rcoll.Count; - } - - if (defaultCount == 0) - { - return new RentArray(Array.Empty(), 0, null); - } - - { - var pool = ArrayPool.Shared; - - var index = 0; - var buffer = pool.Rent(defaultCount); - foreach (var item in source) - { - EnsureCapacity(ref buffer, index, pool); - buffer[index++] = item; - } - - return new RentArray(buffer, index, pool); - } - } - - public struct RentArray : IDisposable - { - public readonly T[] Array; - public readonly int Length; - ArrayPool pool; - - public RentArray(T[] array, int length, ArrayPool pool) - { - this.Array = array; - this.Length = length; - this.pool = pool; - } - - public void Dispose() - { - DisposeManually(!RuntimeHelpersAbstraction.IsWellKnownNoReferenceContainsType()); - } - - public void DisposeManually(bool clearArray) - { - if (pool != null) - { - if (clearArray) - { - System.Array.Clear(Array, 0, Length); - } - - pool.Return(Array, clearArray: false); - pool = null; - } - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPoolUtil.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPoolUtil.cs.meta deleted file mode 100644 index e06ec65..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayPoolUtil.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 424cc208fb61d4e448b08fcfa0eee25e -timeCreated: 1532361007 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayUtil.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayUtil.cs deleted file mode 100644 index 114a103..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayUtil.cs +++ /dev/null @@ -1,75 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; - -namespace UniRx.Async.Internal -{ - public static class ArrayUtil - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void EnsureCapacity(ref T[] array, int index) - { - if (array.Length <= index) - { - EnsureCore(ref array, index); - } - } - - // rare case, no inlining. - [MethodImpl(MethodImplOptions.NoInlining)] - static void EnsureCore(ref T[] array, int index) - { - var newSize = array.Length * 2; - var newArray = new T[(index < newSize) ? newSize : (index * 2)]; - Array.Copy(array, 0, newArray, 0, array.Length); - - array = newArray; - } - - /// - /// Optimizing utility to avoid .ToArray() that creates buffer copy(cut to just size). - /// - public static (T[] array, int length) Materialize(IEnumerable source) - { - if (source is T[] array) - { - return (array, array.Length); - } - - var defaultCount = 4; - if (source is ICollection coll) - { - defaultCount = coll.Count; - var buffer = new T[defaultCount]; - coll.CopyTo(buffer, 0); - return (buffer, defaultCount); - } - else if (source is IReadOnlyCollection rcoll) - { - defaultCount = rcoll.Count; - } - - if (defaultCount == 0) - { - return (Array.Empty(), 0); - } - - { - var index = 0; - var buffer = new T[defaultCount]; - foreach (var item in source) - { - EnsureCapacity(ref buffer, index); - buffer[index++] = item; - } - - return (buffer, index); - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayUtil.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayUtil.cs.meta deleted file mode 100644 index 645fc4e..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ArrayUtil.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 23146a82ec99f2542a87971c8d3d7988 -timeCreated: 1532361007 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/CancellationTokenHelper.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/CancellationTokenHelper.cs deleted file mode 100644 index 93b3f52..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/CancellationTokenHelper.cs +++ /dev/null @@ -1,32 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Threading; - -namespace UniRx.Async.Internal -{ - public static class CancellationTokenHelper - { - public static bool TrySetOrLinkCancellationToken(ref CancellationToken field, CancellationToken newCancellationToken) - { - if (newCancellationToken == CancellationToken.None) - { - return false; - } - else if (field == CancellationToken.None) - { - field = newCancellationToken; - return true; - } - else if (field == newCancellationToken) - { - return false; - } - - field = CancellationTokenSource.CreateLinkedTokenSource(field, newCancellationToken).Token; - return true; - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/CancellationTokenHelper.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/CancellationTokenHelper.cs.meta deleted file mode 100644 index bf09591..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/CancellationTokenHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 53d1b536fc7e2d4458294ee2c7d9b743 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ContinuationQueue.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/ContinuationQueue.cs deleted file mode 100644 index 41bb5be..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ContinuationQueue.cs +++ /dev/null @@ -1,115 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; - -namespace UniRx.Async.Internal -{ - internal class ContinuationQueue - { - const int MaxArrayLength = 0X7FEFFFFF; - const int InitialSize = 16; - - SpinLock gate = new SpinLock(); - bool dequing = false; - - int actionListCount = 0; - Action[] actionList = new Action[InitialSize]; - - int waitingListCount = 0; - Action[] waitingList = new Action[InitialSize]; - - public void Enqueue(Action continuation) - { - bool lockTaken = false; - try - { - gate.Enter(ref lockTaken); - - if (dequing) - { - // Ensure Capacity - if (waitingList.Length == waitingListCount) - { - var newLength = waitingListCount * 2; - if ((uint)newLength > MaxArrayLength) newLength = MaxArrayLength; - - var newArray = new Action[newLength]; - Array.Copy(waitingList, newArray, waitingListCount); - waitingList = newArray; - } - waitingList[waitingListCount] = continuation; - waitingListCount++; - } - else - { - // Ensure Capacity - if (actionList.Length == actionListCount) - { - var newLength = actionListCount * 2; - if ((uint)newLength > MaxArrayLength) newLength = MaxArrayLength; - - var newArray = new Action[newLength]; - Array.Copy(actionList, newArray, actionListCount); - actionList = newArray; - } - actionList[actionListCount] = continuation; - actionListCount++; - } - } - finally - { - if (lockTaken) gate.Exit(false); - } - } - - public void Run() - { - { - bool lockTaken = false; - try - { - gate.Enter(ref lockTaken); - if (actionListCount == 0) return; - dequing = true; - } - finally - { - if (lockTaken) gate.Exit(false); - } - } - - for (int i = 0; i < actionListCount; i++) - { - var action = actionList[i]; - actionList[i] = null; - - action(); - } - - { - bool lockTaken = false; - try - { - gate.Enter(ref lockTaken); - dequing = false; - - var swapTempActionList = actionList; - - actionListCount = waitingListCount; - actionList = waitingList; - - waitingListCount = 0; - waitingList = swapTempActionList; - } - finally - { - if (lockTaken) gate.Exit(false); - } - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ContinuationQueue.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/ContinuationQueue.cs.meta deleted file mode 100644 index b04e541..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ContinuationQueue.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f66c32454e50f2546b17deadc80a4c77 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/Error.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/Error.cs deleted file mode 100644 index 378af62..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/Error.cs +++ /dev/null @@ -1,63 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Runtime.CompilerServices; - -namespace UniRx.Async.Internal -{ - internal static class Error - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ThrowArgumentNullException(T value, string paramName) - where T : class - { - if (value == null) ThrowArgumentNullExceptionCore(paramName); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - static void ThrowArgumentNullExceptionCore(string paramName) - { - throw new ArgumentNullException(paramName); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public static void ThrowArgumentException(string message) - { - throw new ArgumentException(message); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public static void ThrowNotYetCompleted() - { - throw new InvalidOperationException("Not yet completed."); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public static T ThrowNotYetCompleted() - { - throw new InvalidOperationException("Not yet completed."); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ThrowWhenContinuationIsAlreadyRegistered(T continuationField) - where T : class - { - if (continuationField != null) ThrowInvalidOperationExceptionCore("continuation is already registered."); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - static void ThrowInvalidOperationExceptionCore(string message) - { - throw new InvalidOperationException(message); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public static void ThrowOperationCanceledException() - { - throw new OperationCanceledException(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/Error.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/Error.cs.meta deleted file mode 100644 index 2e5d219..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/Error.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5f39f495294d4604b8082202faf98554 -timeCreated: 1532361007 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/Hack.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/Hack.cs deleted file mode 100644 index 7c600d0..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/Hack.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if NET_4_6 || NET_STANDARD_2_0 || CSHARP_7_OR_LATER - -using System; - -namespace UniRx.Async.Internal -{ - internal static class FuncExtensions - { - // avoid lambda capture - - internal static Action AsFuncOfT(this Action action) - { - return new Action(action.Invoke); - } - - static void Invoke(this Action action, T unused) - { - action(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/Hack.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/Hack.cs.meta deleted file mode 100644 index e77edfc..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/Hack.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4d5a9a3e1f0f069478969f752fde29a9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/LazyPromise.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/LazyPromise.cs deleted file mode 100644 index e62fd59..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/LazyPromise.cs +++ /dev/null @@ -1,130 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; - -namespace UniRx.Async.Internal -{ - internal sealed class LazyPromise : IAwaiter - { - Func factory; - UniTask value; - - public LazyPromise(Func factory) - { - this.factory = factory; - } - - void Create() - { - var f = Interlocked.Exchange(ref factory, null); - if (f != null) - { - value = f(); - } - } - - public bool IsCompleted - { - get - { - Create(); - return value.IsCompleted; - } - } - - public AwaiterStatus Status - { - get - { - Create(); - return value.Status; - } - } - - public void GetResult() - { - Create(); - value.GetResult(); - } - - void IAwaiter.GetResult() - { - GetResult(); - } - - public void UnsafeOnCompleted(Action continuation) - { - Create(); - value.GetAwaiter().UnsafeOnCompleted(continuation); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - } - - internal sealed class LazyPromise : IAwaiter - { - Func> factory; - UniTask value; - - public LazyPromise(Func> factory) - { - this.factory = factory; - } - - void Create() - { - var f = Interlocked.Exchange(ref factory, null); - if (f != null) - { - value = f(); - } - } - - public bool IsCompleted - { - get - { - Create(); - return value.IsCompleted; - } - } - - public AwaiterStatus Status - { - get - { - Create(); - return value.Status; - } - } - - public T GetResult() - { - Create(); - return value.Result; - } - - void IAwaiter.GetResult() - { - GetResult(); - } - - public void UnsafeOnCompleted(Action continuation) - { - Create(); - value.GetAwaiter().UnsafeOnCompleted(continuation); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/LazyPromise.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/LazyPromise.cs.meta deleted file mode 100644 index ee8f3f7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/LazyPromise.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe7a4187b7f89f84582fd1e466a7f27e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/MinimumQueue.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/MinimumQueue.cs deleted file mode 100644 index 0cc40cd..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/MinimumQueue.cs +++ /dev/null @@ -1,122 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -#endif - -using System; -using System.Runtime.CompilerServices; - -namespace UniRx.Async.Internal -{ - // optimized version of Standard Queue. - public class MinimumQueue - { - const int MinimumGrow = 4; - const int GrowFactor = 200; - - T[] array; - int head; - int tail; - int size; - - public MinimumQueue(int capacity) - { - if (capacity < 0) throw new ArgumentOutOfRangeException("capacity"); - array = new T[capacity]; - head = tail = size = 0; - } - - public int Count - { -#if NET_4_6 || NET_STANDARD_2_0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] -#endif - get { return size; } - } - - public T Peek() - { - if (size == 0) ThrowForEmptyQueue(); - return array[head]; - } - -#if NET_4_6 || NET_STANDARD_2_0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] -#endif - public void Enqueue(T item) - { - if (size == array.Length) - { - Grow(); - } - - array[tail] = item; - MoveNext(ref tail); - size++; - } - -#if NET_4_6 || NET_STANDARD_2_0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] -#endif - public T Dequeue() - { - if (size == 0) ThrowForEmptyQueue(); - - int head = this.head; - T[] array = this.array; - T removed = array[head]; - array[head] = default(T); - MoveNext(ref this.head); - size--; - return removed; - } - - void Grow() - { - int newcapacity = (int)((long)array.Length * (long)GrowFactor / 100); - if (newcapacity < array.Length + MinimumGrow) - { - newcapacity = array.Length + MinimumGrow; - } - SetCapacity(newcapacity); - } - - void SetCapacity(int capacity) - { - T[] newarray = new T[capacity]; - if (size > 0) - { - if (head < tail) - { - Array.Copy(array, head, newarray, 0, size); - } - else - { - Array.Copy(array, head, newarray, 0, array.Length - head); - Array.Copy(array, 0, newarray, array.Length - head, tail); - } - } - - array = newarray; - head = 0; - tail = (size == capacity) ? 0 : size; - } - -#if NET_4_6 || NET_STANDARD_2_0 - [MethodImpl(MethodImplOptions.AggressiveInlining)] -#endif - void MoveNext(ref int index) - { - int tmp = index + 1; - if (tmp == array.Length) - { - tmp = 0; - } - index = tmp; - } - - void ThrowForEmptyQueue() - { - throw new InvalidOperationException("EmptyQueue"); - } - } -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/MinimumQueue.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/MinimumQueue.cs.meta deleted file mode 100644 index dc06736..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/MinimumQueue.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7d63add489ccc99498114d79702b904d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/PlayerLoopRunner.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/PlayerLoopRunner.cs deleted file mode 100644 index 86da337..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/PlayerLoopRunner.cs +++ /dev/null @@ -1,153 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - -using System; -using UnityEngine; - -namespace UniRx.Async.Internal -{ - internal sealed class PlayerLoopRunner - { - const int InitialSize = 16; - - readonly object runningAndQueueLock = new object(); - readonly object arrayLock = new object(); - readonly Action unhandledExceptionCallback; - - int tail = 0; - bool running = false; - IPlayerLoopItem[] loopItems = new IPlayerLoopItem[InitialSize]; - MinimumQueue waitQueue = new MinimumQueue(InitialSize); - - public PlayerLoopRunner() - { - this.unhandledExceptionCallback = ex => Debug.LogException(ex); - } - - public void AddAction(IPlayerLoopItem item) - { - lock (runningAndQueueLock) - { - if (running) - { - waitQueue.Enqueue(item); - return; - } - } - - lock (arrayLock) - { - // Ensure Capacity - if (loopItems.Length == tail) - { - Array.Resize(ref loopItems, checked(tail * 2)); - } - loopItems[tail++] = item; - } - } - - public void Run() - { - lock (runningAndQueueLock) - { - running = true; - } - - lock (arrayLock) - { - var j = tail - 1; - - // eliminate array-bound check for i - for (int i = 0; i < loopItems.Length; i++) - { - var action = loopItems[i]; - if (action != null) - { - try - { - if (!action.MoveNext()) - { - loopItems[i] = null; - } - else - { - continue; // next i - } - } - catch (Exception ex) - { - loopItems[i] = null; - try - { - unhandledExceptionCallback(ex); - } - catch { } - } - } - - // find null, loop from tail - while (i < j) - { - var fromTail = loopItems[j]; - if (fromTail != null) - { - try - { - if (!fromTail.MoveNext()) - { - loopItems[j] = null; - j--; - continue; // next j - } - else - { - // swap - loopItems[i] = fromTail; - loopItems[j] = null; - j--; - goto NEXT_LOOP; // next i - } - } - catch (Exception ex) - { - loopItems[j] = null; - j--; - try - { - unhandledExceptionCallback(ex); - } - catch { } - continue; // next j - } - } - else - { - j--; - } - } - - tail = i; // loop end - break; // LOOP END - - NEXT_LOOP: - continue; - } - - - lock (runningAndQueueLock) - { - running = false; - while (waitQueue.Count != 0) - { - if (loopItems.Length == tail) - { - Array.Resize(ref loopItems, checked(tail * 2)); - } - loopItems[tail++] = waitQueue.Dequeue(); - } - } - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/PlayerLoopRunner.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/PlayerLoopRunner.cs.meta deleted file mode 100644 index 603dbc9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/PlayerLoopRunner.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 340c6d420bb4f484aa8683415ea92571 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/PromiseHelper.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/PromiseHelper.cs deleted file mode 100644 index 33b3a54..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/PromiseHelper.cs +++ /dev/null @@ -1,34 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; - -namespace UniRx.Async.Internal -{ - public static class PromiseHelper - { - public static void TrySetResultAll(IEnumerable source, T value) - where TPromise : class, IResolvePromise - { - var rentArray = ArrayPoolUtil.Materialize(source); - var clearArray = true; - try - { - var array = rentArray.Array; - var len = rentArray.Length; - for (int i = 0; i < len; i++) - { - array[i].TrySetResult(value); - array[i] = null; - } - clearArray = false; - } - finally - { - rentArray.DisposeManually(clearArray); - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ReusablePromise.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/ReusablePromise.cs deleted file mode 100644 index f8fd318..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ReusablePromise.cs +++ /dev/null @@ -1,399 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Diagnostics; -using System.Runtime.ExceptionServices; -using System.Threading; - -namespace UniRx.Async.Internal -{ - // 'public', user can use this(but be careful). - - public abstract class ReusablePromise : IAwaiter - { - ExceptionDispatchInfo exception; - object continuation; // Action or Queue - AwaiterStatus status; - - public UniTask Task => new UniTask(this); - - // can override for control 'start/reset' timing. - public virtual bool IsCompleted => status.IsCompleted(); - - public virtual void GetResult() - { - switch (status) - { - case AwaiterStatus.Succeeded: - return; - case AwaiterStatus.Faulted: - exception.Throw(); - break; - case AwaiterStatus.Canceled: - throw new OperationCanceledException(); - default: - break; - } - - throw new InvalidOperationException("Invalid Status:" + status); - } - - public AwaiterStatus Status => status; - - void IAwaiter.GetResult() - { - GetResult(); - } - - public void ResetStatus(bool forceReset) - { - if (forceReset) - { - status = AwaiterStatus.Pending; - } - else if (status == AwaiterStatus.Succeeded) - { - status = AwaiterStatus.Pending; - } - } - - public virtual bool TrySetCanceled() - { - if (status == AwaiterStatus.Pending) - { - status = AwaiterStatus.Canceled; - TryInvokeContinuation(); - return true; - } - return false; - } - - public virtual bool TrySetException(Exception ex) - { - if (status == AwaiterStatus.Pending) - { - status = AwaiterStatus.Faulted; - exception = ExceptionDispatchInfo.Capture(ex); - TryInvokeContinuation(); - return true; - } - return false; - } - - public virtual bool TrySetResult() - { - if (status == AwaiterStatus.Pending) - { - status = AwaiterStatus.Succeeded; - TryInvokeContinuation(); - return true; - } - return false; - } - - void TryInvokeContinuation() - { - if (continuation == null) return; - - if (continuation is Action act) - { - continuation = null; - act(); - } - else - { - // reuse Queue(don't null clear) - var q = (MinimumQueue)continuation; - var size = q.Count; - for (int i = 0; i < size; i++) - { - q.Dequeue().Invoke(); - } - } - } - - public void OnCompleted(Action action) - { - UnsafeOnCompleted(action); - } - - public void UnsafeOnCompleted(Action action) - { - if (continuation == null) - { - continuation = action; - return; - } - else - { - if (continuation is Action act) - { - var q = new MinimumQueue(4); - q.Enqueue(act); - q.Enqueue(action); - continuation = q; - return; - } - else - { - ((MinimumQueue)continuation).Enqueue(action); - } - } - } - } - - public abstract class ReusablePromise : IAwaiter - { - T result; - ExceptionDispatchInfo exception; - object continuation; // Action or Queue - AwaiterStatus status; - - public UniTask Task => new UniTask(this); - - // can override for control 'start/reset' timing. - public virtual bool IsCompleted => status.IsCompleted(); - - protected T RawResult => result; - - protected void ForceSetResult(T result) - { - this.result = result; - } - - public virtual T GetResult() - { - switch (status) - { - case AwaiterStatus.Succeeded: - return result; - case AwaiterStatus.Faulted: - exception.Throw(); - break; - case AwaiterStatus.Canceled: - throw new OperationCanceledException(); - default: - break; - } - - throw new InvalidOperationException("Invalid Status:" + status); - } - - public AwaiterStatus Status => status; - - void IAwaiter.GetResult() - { - GetResult(); - } - - public void ResetStatus(bool forceReset) - { - if (forceReset) - { - status = AwaiterStatus.Pending; - } - else if (status == AwaiterStatus.Succeeded) - { - status = AwaiterStatus.Pending; - } - } - - public virtual bool TrySetCanceled() - { - if (status == AwaiterStatus.Pending) - { - status = AwaiterStatus.Canceled; - TryInvokeContinuation(); - return true; - } - return false; - } - - public virtual bool TrySetException(Exception ex) - { - if (status == AwaiterStatus.Pending) - { - status = AwaiterStatus.Faulted; - exception = ExceptionDispatchInfo.Capture(ex); - TryInvokeContinuation(); - return true; - } - return false; - } - - public virtual bool TrySetResult(T result) - { - if (status == AwaiterStatus.Pending) - { - status = AwaiterStatus.Succeeded; - this.result = result; - TryInvokeContinuation(); - return true; - } - return false; - } - - protected void TryInvokeContinuation() - { - if (continuation == null) return; - - if (continuation is Action act) - { - continuation = null; - act(); - } - else - { - // reuse Queue(don't null clear) - var q = (MinimumQueue)continuation; - var size = q.Count; - for (int i = 0; i < size; i++) - { - q.Dequeue().Invoke(); - } - } - } - - public void OnCompleted(Action action) - { - UnsafeOnCompleted(action); - } - - public void UnsafeOnCompleted(Action action) - { - if (continuation == null) - { - continuation = action; - return; - } - else - { - if (continuation is Action act) - { - var q = new MinimumQueue(4); - q.Enqueue(act); - q.Enqueue(action); - continuation = q; - return; - } - else - { - ((MinimumQueue)continuation).Enqueue(action); - } - } - } - } - -#if !UniRxLibrary - - public abstract class PlayerLoopReusablePromiseBase : ReusablePromise, IPlayerLoopItem - { - readonly PlayerLoopTiming timing; - protected readonly CancellationToken cancellationToken; - bool isRunning = false; - -#if UNITY_EDITOR - string capturedStackTraceForDebugging; -#endif - - public PlayerLoopReusablePromiseBase(PlayerLoopTiming timing, CancellationToken cancellationToken, int skipTrackFrameCountAdditive) - { - this.timing = timing; - this.cancellationToken = cancellationToken; - -#if UNITY_EDITOR - this.capturedStackTraceForDebugging = TaskTracker.CaptureStackTrace(skipTrackFrameCountAdditive + 1); // 1 is self, -#endif - } - - public override bool IsCompleted - { - get - { - if (Status == AwaiterStatus.Canceled || Status == AwaiterStatus.Faulted) return true; - - if (!isRunning) - { - isRunning = true; - ResetStatus(false); - OnRunningStart(); -#if UNITY_EDITOR - TaskTracker.TrackActiveTask(this, capturedStackTraceForDebugging); -#endif - PlayerLoopHelper.AddAction(timing, this); - } - return false; - } - } - - protected abstract void OnRunningStart(); - - protected void Complete() - { - isRunning = false; -#if UNITY_EDITOR - TaskTracker.RemoveTracking(this); -#endif - } - - public abstract bool MoveNext(); - } - - public abstract class PlayerLoopReusablePromiseBase : ReusablePromise, IPlayerLoopItem - { - readonly PlayerLoopTiming timing; - protected readonly CancellationToken cancellationToken; - bool isRunning = false; - -#if UNITY_EDITOR - string capturedStackTraceForDebugging; -#endif - - public PlayerLoopReusablePromiseBase(PlayerLoopTiming timing, CancellationToken cancellationToken, int skipTrackFrameCountAdditive) - { - this.timing = timing; - this.cancellationToken = cancellationToken; - -#if UNITY_EDITOR - this.capturedStackTraceForDebugging = TaskTracker.CaptureStackTrace(skipTrackFrameCountAdditive + 1); // 1 is self, -#endif - } - - public override bool IsCompleted - { - get - { - if (Status == AwaiterStatus.Canceled || Status == AwaiterStatus.Faulted) return true; - - if (!isRunning) - { - isRunning = true; - ResetStatus(false); - OnRunningStart(); -#if UNITY_EDITOR - TaskTracker.TrackActiveTask(this, capturedStackTraceForDebugging); -#endif - PlayerLoopHelper.AddAction(timing, this); - } - return false; - } - } - - protected abstract void OnRunningStart(); - - protected void Complete() - { - isRunning = false; -#if UNITY_EDITOR - TaskTracker.RemoveTracking(this); -#endif - } - - public abstract bool MoveNext(); - } - -#endif -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/ReusablePromise.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/ReusablePromise.cs.meta deleted file mode 100644 index d86918f..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/ReusablePromise.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a8cfc99b5928c0242919aac2121b02bb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/RuntimeHelpersAbstraction.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/RuntimeHelpersAbstraction.cs deleted file mode 100644 index 2bf4ceb..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/RuntimeHelpersAbstraction.cs +++ /dev/null @@ -1,62 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -#if !UniRxLibrary -using UnityEngine; -#endif - -namespace UniRx.Async.Internal -{ - public static class RuntimeHelpersAbstraction - { - // If we can use RuntimeHelpers.IsReferenceOrContainsReferences(.NET Core 2.0), use it. - public static bool IsWellKnownNoReferenceContainsType() - { - return WellKnownNoReferenceContainsType.IsWellKnownType; - } - - static bool WellKnownNoReferenceContainsTypeInitialize(Type t) - { - // The primitive types are Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double, and Single. - if (t.IsPrimitive) return true; - - if (t.IsEnum) return true; - if (t == typeof(DateTime)) return true; - if (t == typeof(DateTimeOffset)) return true; - if (t == typeof(Guid)) return true; - if (t == typeof(decimal)) return true; - - // unwrap nullable - if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - return WellKnownNoReferenceContainsTypeInitialize(t.GetGenericArguments()[0]); - } - -#if !UniRxLibrary - // or add other wellknown types(Vector, etc...) here - if (t == typeof(Vector2)) return true; - if (t == typeof(Vector3)) return true; - if (t == typeof(Vector4)) return true; - if (t == typeof(Color)) return true; - if (t == typeof(Rect)) return true; - if (t == typeof(Bounds)) return true; - if (t == typeof(Quaternion)) return true; -#endif - - return false; - } - - static class WellKnownNoReferenceContainsType - { - public static readonly bool IsWellKnownType; - - static WellKnownNoReferenceContainsType() - { - IsWellKnownType = WellKnownNoReferenceContainsTypeInitialize(typeof(T)); - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/RuntimeHelpersAbstraction.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/RuntimeHelpersAbstraction.cs.meta deleted file mode 100644 index 4254391..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/RuntimeHelpersAbstraction.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 94975e4d4e0c0ea4ba787d3872ce9bb4 -timeCreated: 1532361007 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/TaskTracker.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/TaskTracker.cs deleted file mode 100644 index 4585c27..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/TaskTracker.cs +++ /dev/null @@ -1,150 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; - -namespace UniRx.Async.Internal -{ - public static class TaskTracker - { -#if UNITY_EDITOR - - static int trackingId = 0; - - public const string EnableAutoReloadKey = "UniTaskTrackerWindow_EnableAutoReloadKey"; - public const string EnableTrackingKey = "UniTaskTrackerWindow_EnableTrackingKey"; - public const string EnableStackTraceKey = "UniTaskTrackerWindow_EnableStackTraceKey"; - - public static class EditorEnableState - { - static bool enableAutoReload; - public static bool EnableAutoReload - { - get { return enableAutoReload; } - set - { - enableAutoReload = value; - UnityEditor.EditorPrefs.SetBool(EnableAutoReloadKey, value); - } - } - - static bool enableTracking; - public static bool EnableTracking - { - get { return enableTracking; } - set - { - enableTracking = value; - UnityEditor.EditorPrefs.SetBool(EnableTrackingKey, value); - } - } - - static bool enableStackTrace; - public static bool EnableStackTrace - { - get { return enableStackTrace; } - set - { - enableStackTrace = value; - UnityEditor.EditorPrefs.SetBool(EnableStackTraceKey, value); - } - } - } - -#endif - - - static List> listPool = new List>(); - - static readonly WeakDictionary tracking = new WeakDictionary(); - - [Conditional("UNITY_EDITOR")] - public static void TrackActiveTask(IAwaiter task, int skipFrame = 1) - { -#if UNITY_EDITOR - dirty = true; - if (!EditorEnableState.EnableTracking) return; - var stackTrace = EditorEnableState.EnableStackTrace ? new StackTrace(skipFrame, true).CleanupAsyncStackTrace() : ""; - tracking.TryAdd(task, (Interlocked.Increment(ref trackingId), DateTime.UtcNow, stackTrace)); -#endif - } - - [Conditional("UNITY_EDITOR")] - public static void TrackActiveTask(IAwaiter task, string stackTrace) - { -#if UNITY_EDITOR - dirty = true; - if (!EditorEnableState.EnableTracking) return; - var success = tracking.TryAdd(task, (Interlocked.Increment(ref trackingId), DateTime.UtcNow, stackTrace)); -#endif - } - - public static string CaptureStackTrace(int skipFrame) - { -#if UNITY_EDITOR - if (!EditorEnableState.EnableTracking) return ""; - var stackTrace = EditorEnableState.EnableStackTrace ? new StackTrace(skipFrame + 1, true).CleanupAsyncStackTrace() : ""; - return stackTrace; -#else - return null; -#endif - } - - [Conditional("UNITY_EDITOR")] - public static void RemoveTracking(IAwaiter task) - { -#if UNITY_EDITOR - dirty = true; - if (!EditorEnableState.EnableTracking) return; - var success = tracking.TryRemove(task); -#endif - } - - static bool dirty; - - public static bool CheckAndResetDirty() - { - var current = dirty; - dirty = false; - return current; - } - - /// (trackingId, awaiterType, awaiterStatus, createdTime, stackTrace) - public static void ForEachActiveTask(Action action) - { - lock (listPool) - { - var count = tracking.ToList(ref listPool, clear: false); - try - { - for (int i = 0; i < count; i++) - { - string typeName = null; - var keyType = listPool[i].Key.GetType(); - if (keyType.IsNested) - { - typeName = keyType.DeclaringType.Name + "." + keyType.Name; - } - else - { - typeName = keyType.Name; - } - - action(listPool[i].Value.trackingId, typeName, listPool[i].Key.Status, listPool[i].Value.addTime, listPool[i].Value.stackTrace); - listPool[i] = new KeyValuePair(null, (0, default(DateTime), null)); // clear - } - } - catch - { - listPool.Clear(); - throw; - } - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/TaskTracker.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/TaskTracker.cs.meta deleted file mode 100644 index 5563bf7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/TaskTracker.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a203c73eb4ccdbb44bddfd82d38fdda9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/WeakDictionary.cs b/Assets/Plugins/UniRx/Scripts/Async/Internal/WeakDictionary.cs deleted file mode 100644 index e4b395e..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/WeakDictionary.cs +++ /dev/null @@ -1,334 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Threading; - -namespace UniRx.Async.Internal -{ - // Add, Remove, Enumerate with sweep. All operations are thread safe(in spinlock). - public class WeakDictionary - where TKey : class - { - Entry[] buckets; - int size; - SpinLock gate; // mutable struct(not readonly) - - readonly float loadFactor; - readonly IEqualityComparer keyEqualityComparer; - - public WeakDictionary(int capacity = 4, float loadFactor = 0.75f, IEqualityComparer keyComparer = null) - { - var tableSize = CalculateCapacity(capacity, loadFactor); - this.buckets = new Entry[tableSize]; - this.loadFactor = loadFactor; - this.gate = new SpinLock(false); - this.keyEqualityComparer = keyComparer ?? EqualityComparer.Default; - } - - public bool TryAdd(TKey key, TValue value) - { - bool lockTaken = false; - try - { - gate.Enter(ref lockTaken); - return TryAddInternal(key, value); - } - finally - { - if (lockTaken) gate.Exit(false); - } - } - - public bool TryGetValue(TKey key, out TValue value) - { - bool lockTaken = false; - try - { - if (TryGetEntry(key, out _, out var entry)) - { - value = entry.Value; - return true; - } - - value = default(TValue); - return false; - } - finally - { - if (lockTaken) gate.Exit(false); - } - } - - public bool TryRemove(TKey key) - { - bool lockTaken = false; - try - { - if (TryGetEntry(key, out var hashIndex, out var entry)) - { - Remove(hashIndex, entry); - return true; - } - - return false; - } - finally - { - if (lockTaken) gate.Exit(false); - } - } - - bool TryAddInternal(TKey key, TValue value) - { - var nextCapacity = CalculateCapacity(size + 1, loadFactor); - - TRY_ADD_AGAIN: - if (buckets.Length < nextCapacity) - { - // rehash - var nextBucket = new Entry[nextCapacity]; - for (int i = 0; i < buckets.Length; i++) - { - var e = buckets[i]; - while (e != null) - { - AddToBuckets(nextBucket, key, e.Value, e.Hash); - e = e.Next; - } - } - - buckets = nextBucket; - goto TRY_ADD_AGAIN; - } - else - { - // add entry - var successAdd = AddToBuckets(buckets, key, value, keyEqualityComparer.GetHashCode(key)); - if (successAdd) size++; - return successAdd; - } - } - - bool AddToBuckets(Entry[] targetBuckets, TKey newKey, TValue value, int keyHash) - { - var h = keyHash; - var hashIndex = h & (targetBuckets.Length - 1); - - TRY_ADD_AGAIN: - if (targetBuckets[hashIndex] == null) - { - targetBuckets[hashIndex] = new Entry - { - Key = new WeakReference(newKey, false), - Value = value, - Hash = h - }; - - return true; - } - else - { - // add to last. - var entry = targetBuckets[hashIndex]; - while (entry != null) - { - if (entry.Key.TryGetTarget(out var target)) - { - if (keyEqualityComparer.Equals(newKey, target)) - { - return false; // duplicate - } - } - else - { - Remove(hashIndex, entry); - if (targetBuckets[hashIndex] == null) goto TRY_ADD_AGAIN; // add new entry - } - - if (entry.Next != null) - { - entry = entry.Next; - } - else - { - // found last - entry.Next = new Entry - { - Key = new WeakReference(newKey, false), - Value = value, - Hash = h - }; - entry.Next.Prev = entry; - } - } - - return false; - } - } - - bool TryGetEntry(TKey key, out int hashIndex, out Entry entry) - { - var table = buckets; - var hash = keyEqualityComparer.GetHashCode(key); - hashIndex = hash & table.Length - 1; - entry = table[hashIndex]; - - while (entry != null) - { - if (entry.Key.TryGetTarget(out var target)) - { - if (keyEqualityComparer.Equals(key, target)) - { - return true; - } - } - else - { - // sweap - Remove(hashIndex, entry); - } - - entry = entry.Next; - } - - return false; - } - - void Remove(int hashIndex, Entry entry) - { - if (entry.Prev == null && entry.Next == null) - { - buckets[hashIndex] = null; - } - else - { - if (entry.Prev == null) - { - buckets[hashIndex] = entry.Next; - } - if (entry.Prev != null) - { - entry.Prev.Next = entry.Next; - } - if (entry.Next != null) - { - entry.Next.Prev = entry.Prev; - } - } - size--; - } - - public List> ToList() - { - var list = new List>(size); - ToList(ref list, false); - return list; - } - - // avoid allocate everytime. - public int ToList(ref List> list, bool clear = true) - { - if (clear) - { - list.Clear(); - } - - var listIndex = 0; - - bool lockTaken = false; - try - { - for (int i = 0; i < buckets.Length; i++) - { - var entry = buckets[i]; - while (entry != null) - { - if (entry.Key.TryGetTarget(out var target)) - { - var item = new KeyValuePair(target, entry.Value); - if (listIndex < list.Count) - { - list[listIndex++] = item; - } - else - { - list.Add(item); - listIndex++; - } - } - else - { - // sweap - Remove(i, entry); - } - - entry = entry.Next; - } - } - } - finally - { - if (lockTaken) gate.Exit(false); - } - - return listIndex; - } - - static int CalculateCapacity(int collectionSize, float loadFactor) - { - var size = (int)(((float)collectionSize) / loadFactor); - - size--; - size |= size >> 1; - size |= size >> 2; - size |= size >> 4; - size |= size >> 8; - size |= size >> 16; - size += 1; - - if (size < 8) - { - size = 8; - } - return size; - } - - class Entry - { - public WeakReference Key; - public TValue Value; - public int Hash; - public Entry Prev; - public Entry Next; - - // debug only - public override string ToString() - { - if (Key.TryGetTarget(out var target)) - { - return target + "(" + Count() + ")"; - } - else - { - return "(Dead)"; - } - } - - int Count() - { - var count = 1; - var n = this; - while (n.Next != null) - { - count++; - n = n.Next; - } - return count; - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/WeakDictionary.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Internal/WeakDictionary.cs.meta deleted file mode 100644 index 9dc1672..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/WeakDictionary.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6c78563864409714593226af59bcb6f3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/PlayerLoopHelper.cs b/Assets/Plugins/UniRx/Scripts/Async/PlayerLoopHelper.cs deleted file mode 100644 index c7ab469..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/PlayerLoopHelper.cs +++ /dev/null @@ -1,125 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Linq; -using UnityEngine; -using UnityEngine.Experimental.LowLevel; -using UniRx.Async.Internal; -using System.Threading; - -namespace UniRx.Async -{ - public static class UniTaskLoopRunners - { - public struct UniTaskLoopRunnerInitialization { }; - public struct UniTaskLoopRunnerEarlyUpdate { }; - public struct UniTaskLoopRunnerFixedUpdate { }; - public struct UniTaskLoopRunnerPreUpdate { }; - public struct UniTaskLoopRunnerUpdate { }; - public struct UniTaskLoopRunnerPreLateUpdate { }; - public struct UniTaskLoopRunnerPostLateUpdate { }; - - // Yield - - public struct UniTaskLoopRunnerYieldInitialization { }; - public struct UniTaskLoopRunnerYieldEarlyUpdate { }; - public struct UniTaskLoopRunnerYieldFixedUpdate { }; - public struct UniTaskLoopRunnerYieldPreUpdate { }; - public struct UniTaskLoopRunnerYieldUpdate { }; - public struct UniTaskLoopRunnerYieldPreLateUpdate { }; - public struct UniTaskLoopRunnerYieldPostLateUpdate { }; - } - - public enum PlayerLoopTiming - { - Initialization = 0, - EarlyUpdate = 1, - FixedUpdate = 2, - PreUpdate = 3, - Update = 4, - PreLateUpdate = 5, - PostLateUpdate = 6 - } - - public interface IPlayerLoopItem - { - bool MoveNext(); - } - - public static class PlayerLoopHelper - { - public static SynchronizationContext UnitySynchronizationContext => unitySynchronizationContetext; - public static int MainThreadId => mainThreadId; - - static int mainThreadId; - static SynchronizationContext unitySynchronizationContetext; - static ContinuationQueue[] yielders; - static PlayerLoopRunner[] runners; - - static PlayerLoopSystem[] InsertRunner(PlayerLoopSystem loopSystem, Type loopRunnerYieldType, ContinuationQueue cq, Type loopRunnerType, PlayerLoopRunner runner) - { - var yieldLoop = new PlayerLoopSystem - { - type = loopRunnerYieldType, - updateDelegate = cq.Run - }; - - var runnerLoop = new PlayerLoopSystem - { - type = loopRunnerType, - updateDelegate = runner.Run - }; - - var dest = new PlayerLoopSystem[loopSystem.subSystemList.Length + 2]; - Array.Copy(loopSystem.subSystemList, 0, dest, 2, loopSystem.subSystemList.Length); - dest[0] = yieldLoop; - dest[1] = runnerLoop; - return dest; - } - - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] - static void Init() - { - // capture default(unity) sync-context. - unitySynchronizationContetext = SynchronizationContext.Current; - mainThreadId = Thread.CurrentThread.ManagedThreadId; - - if (runners != null) return; // already initialized - - var playerLoop = PlayerLoop.GetDefaultPlayerLoop(); - Initialize(ref playerLoop); - } - - public static void Initialize(ref PlayerLoopSystem playerLoop) - { - yielders = new ContinuationQueue[7]; - runners = new PlayerLoopRunner[7]; - - var copyList = playerLoop.subSystemList.ToArray(); - - copyList[0].subSystemList = InsertRunner(copyList[0], typeof(UniTaskLoopRunners.UniTaskLoopRunnerYieldInitialization), yielders[0] = new ContinuationQueue(), typeof(UniTaskLoopRunners.UniTaskLoopRunnerInitialization), runners[0] = new PlayerLoopRunner()); - copyList[1].subSystemList = InsertRunner(copyList[1], typeof(UniTaskLoopRunners.UniTaskLoopRunnerYieldEarlyUpdate), yielders[1] = new ContinuationQueue(), typeof(UniTaskLoopRunners.UniTaskLoopRunnerEarlyUpdate), runners[1] = new PlayerLoopRunner()); - copyList[2].subSystemList = InsertRunner(copyList[2], typeof(UniTaskLoopRunners.UniTaskLoopRunnerYieldFixedUpdate), yielders[2] = new ContinuationQueue(), typeof(UniTaskLoopRunners.UniTaskLoopRunnerFixedUpdate), runners[2] = new PlayerLoopRunner()); - copyList[3].subSystemList = InsertRunner(copyList[3], typeof(UniTaskLoopRunners.UniTaskLoopRunnerYieldPreUpdate), yielders[3] = new ContinuationQueue(), typeof(UniTaskLoopRunners.UniTaskLoopRunnerPreUpdate), runners[3] = new PlayerLoopRunner()); - copyList[4].subSystemList = InsertRunner(copyList[4], typeof(UniTaskLoopRunners.UniTaskLoopRunnerYieldUpdate), yielders[4] = new ContinuationQueue(), typeof(UniTaskLoopRunners.UniTaskLoopRunnerUpdate), runners[4] = new PlayerLoopRunner()); - copyList[5].subSystemList = InsertRunner(copyList[5], typeof(UniTaskLoopRunners.UniTaskLoopRunnerYieldPreLateUpdate), yielders[5] = new ContinuationQueue(), typeof(UniTaskLoopRunners.UniTaskLoopRunnerPreLateUpdate), runners[5] = new PlayerLoopRunner()); - copyList[6].subSystemList = InsertRunner(copyList[6], typeof(UniTaskLoopRunners.UniTaskLoopRunnerYieldPostLateUpdate), yielders[6] = new ContinuationQueue(), typeof(UniTaskLoopRunners.UniTaskLoopRunnerPostLateUpdate), runners[6] = new PlayerLoopRunner()); - - playerLoop.subSystemList = copyList; - PlayerLoop.SetPlayerLoop(playerLoop); - } - - public static void AddAction(PlayerLoopTiming timing, IPlayerLoopItem action) - { - runners[(int)timing].AddAction(action); - } - - public static void AddContinuation(PlayerLoopTiming timing, Action continuation) - { - yielders[(int)timing].Enqueue(continuation); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/PlayerLoopHelper.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/PlayerLoopHelper.cs.meta deleted file mode 100644 index 2487ef7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/PlayerLoopHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 15fb5b85042f19640b973ce651795aca -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Progress.cs b/Assets/Plugins/UniRx/Scripts/Async/Progress.cs deleted file mode 100644 index a9e76b7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Progress.cs +++ /dev/null @@ -1,87 +0,0 @@ -#if NET_4_6 || NET_STANDARD_2_0 || CSHARP_7_OR_LATER -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; - -namespace UniRx.Async -{ - /// - /// Lightweight IProgress[T] factory. - /// - public static class Progress - { - public static IProgress Create(Action handler) - { - if (handler == null) return NullProgress.Instance; - return new AnonymousProgress(handler); - } - - public static IProgress CreateOnlyValueChanged(Action handler, IEqualityComparer comparer = null) - { - if (handler == null) return NullProgress.Instance; - return new OnlyValueChangedProgress(handler, comparer ?? UnityEqualityComparer.GetDefault()); - } - - sealed class NullProgress : IProgress - { - public static readonly IProgress Instance = new NullProgress(); - - NullProgress() - { - - } - - public void Report(T value) - { - } - } - - sealed class AnonymousProgress : IProgress - { - readonly Action action; - - public AnonymousProgress(Action action) - { - this.action = action; - } - - public void Report(T value) - { - action(value); - } - } - - sealed class OnlyValueChangedProgress : IProgress - { - readonly Action action; - readonly IEqualityComparer comparer; - bool isFirstCall; - T latestValue; - - public OnlyValueChangedProgress(Action action, IEqualityComparer comparer) - { - this.action = action; - this.comparer = comparer; - this.isFirstCall = true; - } - - public void Report(T value) - { - if (isFirstCall) - { - isFirstCall = false; - } - else if (comparer.Equals(value, latestValue)) - { - return; - } - - latestValue = value; - action(value); - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Progress.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Progress.cs.meta deleted file mode 100644 index f0e1f19..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Progress.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e3377e2ae934ed54fb8fd5388e2d9eb9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAnimatorTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAnimatorTrigger.cs deleted file mode 100644 index 00b66cb..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAnimatorTrigger.cs +++ /dev/null @@ -1,54 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncAnimatorTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onAnimatorIK; - AsyncTriggerPromiseDictionary onAnimatorIKs; - AsyncTriggerPromise onAnimatorMove; - AsyncTriggerPromiseDictionary onAnimatorMoves; - - - protected override IEnumerable GetPromises() - { - return Concat(onAnimatorIK, onAnimatorIKs, onAnimatorMove, onAnimatorMoves); - } - - - void OnAnimatorIK(int layerIndex) - { - TrySetResult(onAnimatorIK, onAnimatorIKs, layerIndex); - } - - - public UniTask OnAnimatorIKAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onAnimatorIK, ref onAnimatorIKs, cancellationToken); - } - - - void OnAnimatorMove() - { - TrySetResult(onAnimatorMove, onAnimatorMoves, AsyncUnit.Default); - } - - - public UniTask OnAnimatorMoveAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onAnimatorMove, ref onAnimatorMoves, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAnimatorTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAnimatorTrigger.cs.meta deleted file mode 100644 index 29b2826..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAnimatorTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ae912c37ac7f4cd42b25f22452435103 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAwakeTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAwakeTrigger.cs deleted file mode 100644 index 0710dcb..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAwakeTrigger.cs +++ /dev/null @@ -1,55 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using UnityEngine; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncAwakeTrigger : MonoBehaviour - { - bool called = false; - UniTaskCompletionSource promise; - - void Awake() - { - called = true; - promise?.TrySetResult(); - } - - public UniTask AwakeAsync() - { - if (called) return UniTask.CompletedTask; - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this)); - return new UniTask(promise ?? (promise = new UniTaskCompletionSource())); - } - - private void OnDestroy() - { - promise?.TrySetCanceled(); - } - - class AwakeMonitor : IPlayerLoopItem - { - readonly AsyncAwakeTrigger trigger; - - public AwakeMonitor(AsyncAwakeTrigger trigger) - { - this.trigger = trigger; - } - - public bool MoveNext() - { - if (trigger.called) return false; - if (trigger == null) - { - trigger.OnDestroy(); - return false; - } - return true; - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAwakeTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAwakeTrigger.cs.meta deleted file mode 100644 index 097fdb6..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncAwakeTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ef2840a2586894741a0ae211b8fd669b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncBeginDragTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncBeginDragTrigger.cs deleted file mode 100644 index bef1037..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncBeginDragTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncBeginDragTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onBeginDrag; - AsyncTriggerPromiseDictionary onBeginDrags; - - - protected override IEnumerable GetPromises() - { - return Concat(onBeginDrag, onBeginDrags); - } - - - void OnBeginDrag(PointerEventData eventData) - { - TrySetResult(onBeginDrag, onBeginDrags, eventData); - } - - - public UniTask OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onBeginDrag, ref onBeginDrags, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncBeginDragTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncBeginDragTrigger.cs.meta deleted file mode 100644 index d4a44e9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncBeginDragTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 171fd2191eb22af4fbd92b51815ca757 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCancelTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCancelTrigger.cs deleted file mode 100644 index f484e59..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCancelTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncCancelTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onCancel; - AsyncTriggerPromiseDictionary onCancels; - - - protected override IEnumerable GetPromises() - { - return Concat(onCancel, onCancels); - } - - - void OnCancel(BaseEventData eventData) - { - TrySetResult(onCancel, onCancels, eventData); - } - - - public UniTask OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCancel, ref onCancels, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCancelTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCancelTrigger.cs.meta deleted file mode 100644 index 285efd5..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCancelTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 291886b6e5f2d044a85b2a4dedcaca97 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCanvasGroupChangedTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCanvasGroupChangedTrigger.cs deleted file mode 100644 index 98fb776..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCanvasGroupChangedTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncCanvasGroupChangedTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onCanvasGroupChanged; - AsyncTriggerPromiseDictionary onCanvasGroupChangeds; - - - protected override IEnumerable GetPromises() - { - return Concat(onCanvasGroupChanged, onCanvasGroupChangeds); - } - - - void OnCanvasGroupChanged() - { - TrySetResult(onCanvasGroupChanged, onCanvasGroupChangeds, AsyncUnit.Default); - } - - - public UniTask OnCanvasGroupChangedAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCanvasGroupChanged, ref onCanvasGroupChangeds, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCanvasGroupChangedTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCanvasGroupChangedTrigger.cs.meta deleted file mode 100644 index d0ebc56..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCanvasGroupChangedTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: eddba832648f83046a320ffcacfc771d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollision2DTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollision2DTrigger.cs deleted file mode 100644 index c3f0c9c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollision2DTrigger.cs +++ /dev/null @@ -1,69 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncCollision2DTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onCollisionEnter2D; - AsyncTriggerPromiseDictionary onCollisionEnter2Ds; - AsyncTriggerPromise onCollisionExit2D; - AsyncTriggerPromiseDictionary onCollisionExit2Ds; - AsyncTriggerPromise onCollisionStay2D; - AsyncTriggerPromiseDictionary onCollisionStay2Ds; - - - protected override IEnumerable GetPromises() - { - return Concat(onCollisionEnter2D, onCollisionEnter2Ds, onCollisionExit2D, onCollisionExit2Ds, onCollisionStay2D, onCollisionStay2Ds); - } - - - void OnCollisionEnter2D(Collision2D coll) - { - TrySetResult(onCollisionEnter2D, onCollisionEnter2Ds, coll); - } - - - public UniTask OnCollisionEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCollisionEnter2D, ref onCollisionEnter2Ds, cancellationToken); - } - - - void OnCollisionExit2D(Collision2D coll) - { - TrySetResult(onCollisionExit2D, onCollisionExit2Ds, coll); - } - - - public UniTask OnCollisionExit2DAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCollisionExit2D, ref onCollisionExit2Ds, cancellationToken); - } - - - void OnCollisionStay2D(Collision2D coll) - { - TrySetResult(onCollisionStay2D, onCollisionStay2Ds, coll); - } - - - public UniTask OnCollisionStay2DAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCollisionStay2D, ref onCollisionStay2Ds, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollision2DTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollision2DTrigger.cs.meta deleted file mode 100644 index ad81300..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollision2DTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fbeb63f69bedec44f8003730887f914b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollisionTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollisionTrigger.cs deleted file mode 100644 index 3534c69..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollisionTrigger.cs +++ /dev/null @@ -1,69 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncCollisionTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onCollisionEnter; - AsyncTriggerPromiseDictionary onCollisionEnters; - AsyncTriggerPromise onCollisionExit; - AsyncTriggerPromiseDictionary onCollisionExits; - AsyncTriggerPromise onCollisionStay; - AsyncTriggerPromiseDictionary onCollisionStays; - - - protected override IEnumerable GetPromises() - { - return Concat(onCollisionEnter, onCollisionEnters, onCollisionExit, onCollisionExits, onCollisionStay, onCollisionStays); - } - - - void OnCollisionEnter(Collision collision) - { - TrySetResult(onCollisionEnter, onCollisionEnters, collision); - } - - - public UniTask OnCollisionEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCollisionEnter, ref onCollisionEnters, cancellationToken); - } - - - void OnCollisionExit(Collision collisionInfo) - { - TrySetResult(onCollisionExit, onCollisionExits, collisionInfo); - } - - - public UniTask OnCollisionExitAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCollisionExit, ref onCollisionExits, cancellationToken); - } - - - void OnCollisionStay(Collision collisionInfo) - { - TrySetResult(onCollisionStay, onCollisionStays, collisionInfo); - } - - - public UniTask OnCollisionStayAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCollisionStay, ref onCollisionStays, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollisionTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollisionTrigger.cs.meta deleted file mode 100644 index ebcc28e..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncCollisionTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 72db4a683be8f6a428823502599014a9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDeselectTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDeselectTrigger.cs deleted file mode 100644 index 18ac7d0..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDeselectTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncDeselectTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onDeselect; - AsyncTriggerPromiseDictionary onDeselects; - - - protected override IEnumerable GetPromises() - { - return Concat(onDeselect, onDeselects); - } - - - void OnDeselect(BaseEventData eventData) - { - TrySetResult(onDeselect, onDeselects, eventData); - } - - - public UniTask OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onDeselect, ref onDeselects, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDeselectTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDeselectTrigger.cs.meta deleted file mode 100644 index 9509524..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDeselectTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 30faa9be5bd883e488bdc52f4825c4da -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDestroyTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDestroyTrigger.cs deleted file mode 100644 index f5a6ed6..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDestroyTrigger.cs +++ /dev/null @@ -1,93 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Threading; -using UniRx.Async.Internal; -using UnityEngine; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncDestroyTrigger : MonoBehaviour - { - bool called = false; - UniTaskCompletionSource promise; - CancellationTokenSource cancellationTokenSource; // main cancellation - object canellationTokenSourceOrQueue; // external from AddCancellationTriggerOnDestory - - public CancellationToken CancellationToken - { - get - { - if (cancellationTokenSource == null) - { - cancellationTokenSource = new CancellationTokenSource(); - } - return cancellationTokenSource.Token; - } - } - - /// This function is called when the MonoBehaviour will be destroyed. - void OnDestroy() - { - called = true; - promise?.TrySetResult(); - cancellationTokenSource?.Cancel(); - cancellationTokenSource?.Dispose(); - if (canellationTokenSourceOrQueue != null) - { - if (canellationTokenSourceOrQueue is CancellationTokenSource cts) - { - cts.Cancel(); - cts.Dispose(); - } - else - { - var q = (MinimumQueue)canellationTokenSourceOrQueue; - while (q.Count != 0) - { - var c = q.Dequeue(); - c.Cancel(); - c.Dispose(); - } - } - canellationTokenSourceOrQueue = null; - } - } - - /// This function is called when the MonoBehaviour will be destroyed. - public UniTask OnDestroyAsync() - { - if (called) return UniTask.CompletedTask; - return new UniTask(promise ?? (promise = new UniTaskCompletionSource())); - } - - /// Add Cancellation Triggers on destroy - public void AddCancellationTriggerOnDestory(CancellationTokenSource cts) - { - if (called) - { - cts.Cancel(); - cts.Dispose(); - } - - if (canellationTokenSourceOrQueue == null) - { - canellationTokenSourceOrQueue = cts; - } - else if (canellationTokenSourceOrQueue is CancellationTokenSource c) - { - var q = new MinimumQueue(4); - q.Enqueue(c); - q.Enqueue(cts); - canellationTokenSourceOrQueue = q; - } - else - { - ((MinimumQueue)canellationTokenSourceOrQueue).Enqueue(cts); - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDestroyTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDestroyTrigger.cs.meta deleted file mode 100644 index 6450049..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDestroyTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f4afdcb1cbadf954ba8b1cf465429e17 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDragTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDragTrigger.cs deleted file mode 100644 index 46ad8d9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDragTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncDragTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onDrag; - AsyncTriggerPromiseDictionary onDrags; - - - protected override IEnumerable GetPromises() - { - return Concat(onDrag, onDrags); - } - - - void OnDrag(PointerEventData eventData) - { - TrySetResult(onDrag, onDrags, eventData); - } - - - public UniTask OnDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onDrag, ref onDrags, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDragTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDragTrigger.cs.meta deleted file mode 100644 index d259f40..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDragTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 52242547ba60ea74f8a2e3bbab5fcdfa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDropTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDropTrigger.cs deleted file mode 100644 index 8993952..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDropTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncDropTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onDrop; - AsyncTriggerPromiseDictionary onDrops; - - - protected override IEnumerable GetPromises() - { - return Concat(onDrop, onDrops); - } - - - void OnDrop(PointerEventData eventData) - { - TrySetResult(onDrop, onDrops, eventData); - } - - - public UniTask OnDropAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onDrop, ref onDrops, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDropTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDropTrigger.cs.meta deleted file mode 100644 index 2a15847..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncDropTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 42d65fd5e4be25f41a927eca25b0acf7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEnableDisableTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEnableDisableTrigger.cs deleted file mode 100644 index 092b97f..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEnableDisableTrigger.cs +++ /dev/null @@ -1,55 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncEnableDisableTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onEnable; - AsyncTriggerPromiseDictionary onEnables; - AsyncTriggerPromise onDisable; - AsyncTriggerPromiseDictionary onDisables; - - - protected override IEnumerable GetPromises() - { - return Concat(onEnable, onEnables, onDisable, onDisables); - } - - - void OnEnable() - { - TrySetResult(onEnable, onEnables, AsyncUnit.Default); - } - - - public UniTask OnEnableAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onEnable, ref onEnables, cancellationToken); - } - - - void OnDisable() - { - TrySetResult(onDisable, onDisables, AsyncUnit.Default); - } - - - public UniTask OnDisableAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onDisable, ref onDisables, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEnableDisableTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEnableDisableTrigger.cs.meta deleted file mode 100644 index 8e61a0f..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEnableDisableTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d0bf9142b63b4cb43b693f0b83b3dbe7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEndDragTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEndDragTrigger.cs deleted file mode 100644 index cbaa823..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEndDragTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncEndDragTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onEndDrag; - AsyncTriggerPromiseDictionary onEndDrags; - - - protected override IEnumerable GetPromises() - { - return Concat(onEndDrag, onEndDrags); - } - - - void OnEndDrag(PointerEventData eventData) - { - TrySetResult(onEndDrag, onEndDrags, eventData); - } - - - public UniTask OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onEndDrag, ref onEndDrags, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEndDragTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEndDragTrigger.cs.meta deleted file mode 100644 index 98f67b8..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEndDragTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8298d43de348acc4aa4e7dbf30472dbf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEventTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEventTrigger.cs deleted file mode 100644 index 218fedc..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEventTrigger.cs +++ /dev/null @@ -1,264 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncEventTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onDeselect; - AsyncTriggerPromiseDictionary onDeselects; - AsyncTriggerPromise onMove; - AsyncTriggerPromiseDictionary onMoves; - AsyncTriggerPromise onPointerDown; - AsyncTriggerPromiseDictionary onPointerDowns; - AsyncTriggerPromise onPointerEnter; - AsyncTriggerPromiseDictionary onPointerEnters; - AsyncTriggerPromise onPointerExit; - AsyncTriggerPromiseDictionary onPointerExits; - AsyncTriggerPromise onPointerUp; - AsyncTriggerPromiseDictionary onPointerUps; - AsyncTriggerPromise onSelect; - AsyncTriggerPromiseDictionary onSelects; - AsyncTriggerPromise onPointerClick; - AsyncTriggerPromiseDictionary onPointerClicks; - AsyncTriggerPromise onSubmit; - AsyncTriggerPromiseDictionary onSubmits; - AsyncTriggerPromise onDrag; - AsyncTriggerPromiseDictionary onDrags; - AsyncTriggerPromise onBeginDrag; - AsyncTriggerPromiseDictionary onBeginDrags; - AsyncTriggerPromise onEndDrag; - AsyncTriggerPromiseDictionary onEndDrags; - AsyncTriggerPromise onDrop; - AsyncTriggerPromiseDictionary onDrops; - AsyncTriggerPromise onUpdateSelected; - AsyncTriggerPromiseDictionary onUpdateSelecteds; - AsyncTriggerPromise onInitializePotentialDrag; - AsyncTriggerPromiseDictionary onInitializePotentialDrags; - AsyncTriggerPromise onCancel; - AsyncTriggerPromiseDictionary onCancels; - AsyncTriggerPromise onScroll; - AsyncTriggerPromiseDictionary onScrolls; - - - protected override IEnumerable GetPromises() - { - return Concat(onDeselect, onDeselects, onMove, onMoves, onPointerDown, onPointerDowns, onPointerEnter, onPointerEnters, onPointerExit, onPointerExits, onPointerUp, onPointerUps, onSelect, onSelects, onPointerClick, onPointerClicks, onSubmit, onSubmits, onDrag, onDrags, onBeginDrag, onBeginDrags, onEndDrag, onEndDrags, onDrop, onDrops, onUpdateSelected, onUpdateSelecteds, onInitializePotentialDrag, onInitializePotentialDrags, onCancel, onCancels, onScroll, onScrolls); - } - - void OnDeselect(BaseEventData eventData) - { - TrySetResult(onDeselect, onDeselects, eventData); - } - - - public UniTask OnDeselectAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onDeselect, ref onDeselects, cancellationToken); - } - - - void OnMove(AxisEventData eventData) - { - TrySetResult(onMove, onMoves, eventData); - } - - - public UniTask OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMove, ref onMoves, cancellationToken); - } - - - void OnPointerDown(PointerEventData eventData) - { - TrySetResult(onPointerDown, onPointerDowns, eventData); - } - - - public UniTask OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerDown, ref onPointerDowns, cancellationToken); - } - - - void OnPointerEnter(PointerEventData eventData) - { - TrySetResult(onPointerEnter, onPointerEnters, eventData); - } - - - public UniTask OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerEnter, ref onPointerEnters, cancellationToken); - } - - - void OnPointerExit(PointerEventData eventData) - { - TrySetResult(onPointerExit, onPointerExits, eventData); - } - - - public UniTask OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerExit, ref onPointerExits, cancellationToken); - } - - - void OnPointerUp(PointerEventData eventData) - { - TrySetResult(onPointerUp, onPointerUps, eventData); - } - - - public UniTask OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerUp, ref onPointerUps, cancellationToken); - } - - - void OnSelect(BaseEventData eventData) - { - TrySetResult(onSelect, onSelects, eventData); - } - - - public UniTask OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onSelect, ref onSelects, cancellationToken); - } - - - void OnPointerClick(PointerEventData eventData) - { - TrySetResult(onPointerClick, onPointerClicks, eventData); - } - - - public UniTask OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerClick, ref onPointerClicks, cancellationToken); - } - - - void OnSubmit(BaseEventData eventData) - { - TrySetResult(onSubmit, onSubmits, eventData); - } - - - public UniTask OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onSubmit, ref onSubmits, cancellationToken); - } - - - void OnDrag(PointerEventData eventData) - { - TrySetResult(onDrag, onDrags, eventData); - } - - - public UniTask OnDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onDrag, ref onDrags, cancellationToken); - } - - - void OnBeginDrag(PointerEventData eventData) - { - TrySetResult(onBeginDrag, onBeginDrags, eventData); - } - - - public UniTask OnBeginDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onBeginDrag, ref onBeginDrags, cancellationToken); - } - - - void OnEndDrag(PointerEventData eventData) - { - TrySetResult(onEndDrag, onEndDrags, eventData); - } - - - public UniTask OnEndDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onEndDrag, ref onEndDrags, cancellationToken); - } - - - void OnDrop(PointerEventData eventData) - { - TrySetResult(onDrop, onDrops, eventData); - } - - - public UniTask OnDropAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onDrop, ref onDrops, cancellationToken); - } - - - void OnUpdateSelected(BaseEventData eventData) - { - TrySetResult(onUpdateSelected, onUpdateSelecteds, eventData); - } - - - public UniTask OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onUpdateSelected, ref onUpdateSelecteds, cancellationToken); - } - - - void OnInitializePotentialDrag(PointerEventData eventData) - { - TrySetResult(onInitializePotentialDrag, onInitializePotentialDrags, eventData); - } - - - public UniTask OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onInitializePotentialDrag, ref onInitializePotentialDrags, cancellationToken); - } - - - void OnCancel(BaseEventData eventData) - { - TrySetResult(onCancel, onCancels, eventData); - } - - - public UniTask OnCancelAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onCancel, ref onCancels, cancellationToken); - } - - - void OnScroll(PointerEventData eventData) - { - TrySetResult(onScroll, onScrolls, eventData); - } - - - public UniTask OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onScroll, ref onScrolls, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEventTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEventTrigger.cs.meta deleted file mode 100644 index c901478..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncEventTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 89997820797ad6d43b17971a8bd0d8fe -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncFixedUpdateTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncFixedUpdateTrigger.cs deleted file mode 100644 index 8cfc821..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncFixedUpdateTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncFixedUpdateTrigger : AsyncTriggerBase - { - AsyncTriggerPromise fixedUpdate; - AsyncTriggerPromiseDictionary fixedUpdates; - - - protected override IEnumerable GetPromises() - { - return Concat(fixedUpdate, fixedUpdates); - } - - - void FixedUpdate() - { - TrySetResult(fixedUpdate, fixedUpdates, AsyncUnit.Default); - } - - - public UniTask FixedUpdateAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref fixedUpdate, ref fixedUpdates, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncFixedUpdateTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncFixedUpdateTrigger.cs.meta deleted file mode 100644 index 7154af6..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncFixedUpdateTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c74b906c4294aaa4e900f6e7f8b36df6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncInitializePotentialDragTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncInitializePotentialDragTrigger.cs deleted file mode 100644 index 59e04b4..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncInitializePotentialDragTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncInitializePotentialDragTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onInitializePotentialDrag; - AsyncTriggerPromiseDictionary onInitializePotentialDrags; - - - protected override IEnumerable GetPromises() - { - return Concat(onInitializePotentialDrag, onInitializePotentialDrags); - } - - - void OnInitializePotentialDrag(PointerEventData eventData) - { - TrySetResult(onInitializePotentialDrag, onInitializePotentialDrags, eventData); - } - - - public UniTask OnInitializePotentialDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onInitializePotentialDrag, ref onInitializePotentialDrags, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncInitializePotentialDragTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncInitializePotentialDragTrigger.cs.meta deleted file mode 100644 index 0df8a5b..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncInitializePotentialDragTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ae0733adc239a324f8b934ffb119abd8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncJointTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncJointTrigger.cs deleted file mode 100644 index 9321182..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncJointTrigger.cs +++ /dev/null @@ -1,55 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncJointTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onJointBreak; - AsyncTriggerPromiseDictionary onJointBreaks; - AsyncTriggerPromise onJointBreak2D; - AsyncTriggerPromiseDictionary onJointBreak2Ds; - - - protected override IEnumerable GetPromises() - { - return Concat(onJointBreak, onJointBreaks, onJointBreak2D, onJointBreak2Ds); - } - - - void OnJointBreak(float breakForce) - { - TrySetResult(onJointBreak, onJointBreaks, breakForce); - } - - - public UniTask OnJointBreakAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onJointBreak, ref onJointBreaks, cancellationToken); - } - - - void OnJointBreak2D(Joint2D brokenJoint) - { - TrySetResult(onJointBreak2D, onJointBreak2Ds, brokenJoint); - } - - - public UniTask OnJointBreak2DAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onJointBreak2D, ref onJointBreak2Ds, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncJointTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncJointTrigger.cs.meta deleted file mode 100644 index 8220736..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncJointTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 04dc74e7b2368094f9153921804a1fb7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncLateUpdateTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncLateUpdateTrigger.cs deleted file mode 100644 index e88dfd8..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncLateUpdateTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncLateUpdateTrigger : AsyncTriggerBase - { - AsyncTriggerPromise lateUpdate; - AsyncTriggerPromiseDictionary lateUpdates; - - - protected override IEnumerable GetPromises() - { - return Concat(lateUpdate, lateUpdates); - } - - - void LateUpdate() - { - TrySetResult(lateUpdate, lateUpdates, AsyncUnit.Default); - } - - - public UniTask LateUpdateAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref lateUpdate, ref lateUpdates, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncLateUpdateTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncLateUpdateTrigger.cs.meta deleted file mode 100644 index 391059d..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncLateUpdateTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a4fb2b4c09cb4ec4a82b934f2038eb36 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMouseTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMouseTrigger.cs deleted file mode 100644 index 243fb00..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMouseTrigger.cs +++ /dev/null @@ -1,129 +0,0 @@ - -#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO) - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncMouseTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onMouseDown; - AsyncTriggerPromiseDictionary onMouseDowns; - AsyncTriggerPromise onMouseDrag; - AsyncTriggerPromiseDictionary onMouseDrags; - AsyncTriggerPromise onMouseEnter; - AsyncTriggerPromiseDictionary onMouseEnters; - AsyncTriggerPromise onMouseExit; - AsyncTriggerPromiseDictionary onMouseExits; - AsyncTriggerPromise onMouseOver; - AsyncTriggerPromiseDictionary onMouseOvers; - AsyncTriggerPromise onMouseUp; - AsyncTriggerPromiseDictionary onMouseUps; - AsyncTriggerPromise onMouseUpAsButton; - AsyncTriggerPromiseDictionary onMouseUpAsButtons; - - - protected override IEnumerable GetPromises() - { - return Concat(onMouseDown, onMouseDowns, onMouseDrag, onMouseDrags, onMouseEnter, onMouseEnters, onMouseExit, onMouseExits, onMouseOver, onMouseOvers, onMouseUp, onMouseUps, onMouseUpAsButton, onMouseUpAsButtons); - } - - - void OnMouseDown() - { - TrySetResult(onMouseDown, onMouseDowns, AsyncUnit.Default); - } - - - public UniTask OnMouseDownAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMouseDown, ref onMouseDowns, cancellationToken); - } - - - void OnMouseDrag() - { - TrySetResult(onMouseDrag, onMouseDrags, AsyncUnit.Default); - } - - - public UniTask OnMouseDragAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMouseDrag, ref onMouseDrags, cancellationToken); - } - - - void OnMouseEnter() - { - TrySetResult(onMouseEnter, onMouseEnters, AsyncUnit.Default); - } - - - public UniTask OnMouseEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMouseEnter, ref onMouseEnters, cancellationToken); - } - - - void OnMouseExit() - { - TrySetResult(onMouseExit, onMouseExits, AsyncUnit.Default); - } - - - public UniTask OnMouseExitAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMouseExit, ref onMouseExits, cancellationToken); - } - - - void OnMouseOver() - { - TrySetResult(onMouseOver, onMouseOvers, AsyncUnit.Default); - } - - - public UniTask OnMouseOverAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMouseOver, ref onMouseOvers, cancellationToken); - } - - - void OnMouseUp() - { - TrySetResult(onMouseUp, onMouseUps, AsyncUnit.Default); - } - - - public UniTask OnMouseUpAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMouseUp, ref onMouseUps, cancellationToken); - } - - - void OnMouseUpAsButton() - { - TrySetResult(onMouseUpAsButton, onMouseUpAsButtons, AsyncUnit.Default); - } - - - public UniTask OnMouseUpAsButtonAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMouseUpAsButton, ref onMouseUpAsButtons, cancellationToken); - } - - - } -} - -#endif - - -#endif diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMouseTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMouseTrigger.cs.meta deleted file mode 100644 index 9e8706f..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMouseTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 57ad5120e9c4d424484c963791467272 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMoveTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMoveTrigger.cs deleted file mode 100644 index cab098c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMoveTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncMoveTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onMove; - AsyncTriggerPromiseDictionary onMoves; - - - protected override IEnumerable GetPromises() - { - return Concat(onMove, onMoves); - } - - - void OnMove(AxisEventData eventData) - { - TrySetResult(onMove, onMoves, eventData); - } - - - public UniTask OnMoveAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onMove, ref onMoves, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMoveTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMoveTrigger.cs.meta deleted file mode 100644 index 2ea01b7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncMoveTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1699926e875c24d4aa34bc8817f96f0e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncParticleTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncParticleTrigger.cs deleted file mode 100644 index 4e22b36..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncParticleTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncParticleTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onParticleCollision; - AsyncTriggerPromiseDictionary onParticleCollisions; - - - protected override IEnumerable GetPromises() - { - return Concat(onParticleCollision, onParticleCollisions); - } - - - void OnParticleCollision(GameObject other) - { - TrySetResult(onParticleCollision, onParticleCollisions, other); - } - - - public UniTask OnParticleCollisionAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onParticleCollision, ref onParticleCollisions, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncParticleTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncParticleTrigger.cs.meta deleted file mode 100644 index 4a162c7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncParticleTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 27d3f2efd47fb1d4fb2e9130f97ea8aa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerClickTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerClickTrigger.cs deleted file mode 100644 index 64b902d..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerClickTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncPointerClickTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onPointerClick; - AsyncTriggerPromiseDictionary onPointerClicks; - - - protected override IEnumerable GetPromises() - { - return Concat(onPointerClick, onPointerClicks); - } - - - void OnPointerClick(PointerEventData eventData) - { - TrySetResult(onPointerClick, onPointerClicks, eventData); - } - - - public UniTask OnPointerClickAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerClick, ref onPointerClicks, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerClickTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerClickTrigger.cs.meta deleted file mode 100644 index 67447a7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerClickTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9f8865abf2db3d248b3730cdb18bb8b7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerDownTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerDownTrigger.cs deleted file mode 100644 index 2e32bfc..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerDownTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncPointerDownTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onPointerDown; - AsyncTriggerPromiseDictionary onPointerDowns; - - - protected override IEnumerable GetPromises() - { - return Concat(onPointerDown, onPointerDowns); - } - - - void OnPointerDown(PointerEventData eventData) - { - TrySetResult(onPointerDown, onPointerDowns, eventData); - } - - - public UniTask OnPointerDownAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerDown, ref onPointerDowns, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerDownTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerDownTrigger.cs.meta deleted file mode 100644 index 851cfe4..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerDownTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7c5132395605eaa498a7efedee5acdd7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerEnterTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerEnterTrigger.cs deleted file mode 100644 index 36ed2e3..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerEnterTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncPointerEnterTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onPointerEnter; - AsyncTriggerPromiseDictionary onPointerEnters; - - - protected override IEnumerable GetPromises() - { - return Concat(onPointerEnter, onPointerEnters); - } - - - void OnPointerEnter(PointerEventData eventData) - { - TrySetResult(onPointerEnter, onPointerEnters, eventData); - } - - - public UniTask OnPointerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerEnter, ref onPointerEnters, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerEnterTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerEnterTrigger.cs.meta deleted file mode 100644 index 9a01b93..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerEnterTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 18887d476d48533498efd14224a2f651 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerExitTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerExitTrigger.cs deleted file mode 100644 index 3cf2575..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerExitTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncPointerExitTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onPointerExit; - AsyncTriggerPromiseDictionary onPointerExits; - - - protected override IEnumerable GetPromises() - { - return Concat(onPointerExit, onPointerExits); - } - - - void OnPointerExit(PointerEventData eventData) - { - TrySetResult(onPointerExit, onPointerExits, eventData); - } - - - public UniTask OnPointerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerExit, ref onPointerExits, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerExitTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerExitTrigger.cs.meta deleted file mode 100644 index 39ab381..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerExitTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9e3ed09876a11a84794795809ebee243 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerUpTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerUpTrigger.cs deleted file mode 100644 index 4f56fa9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerUpTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncPointerUpTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onPointerUp; - AsyncTriggerPromiseDictionary onPointerUps; - - - protected override IEnumerable GetPromises() - { - return Concat(onPointerUp, onPointerUps); - } - - - void OnPointerUp(PointerEventData eventData) - { - TrySetResult(onPointerUp, onPointerUps, eventData); - } - - - public UniTask OnPointerUpAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onPointerUp, ref onPointerUps, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerUpTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerUpTrigger.cs.meta deleted file mode 100644 index 7be4e27..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncPointerUpTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7a0493ea32f81314cbbaf2b635ba3167 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncRectTransformTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncRectTransformTrigger.cs deleted file mode 100644 index 4fab679..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncRectTransformTrigger.cs +++ /dev/null @@ -1,55 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncRectTransformTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onRectTransformDimensionsChange; - AsyncTriggerPromiseDictionary onRectTransformDimensionsChanges; - AsyncTriggerPromise onRectTransformRemoved; - AsyncTriggerPromiseDictionary onRectTransformRemoveds; - - - protected override IEnumerable GetPromises() - { - return Concat(onRectTransformDimensionsChange, onRectTransformDimensionsChanges, onRectTransformRemoved, onRectTransformRemoveds); - } - - - void OnRectTransformDimensionsChange() - { - TrySetResult(onRectTransformDimensionsChange, onRectTransformDimensionsChanges, AsyncUnit.Default); - } - - - public UniTask OnRectTransformDimensionsChangeAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onRectTransformDimensionsChange, ref onRectTransformDimensionsChanges, cancellationToken); - } - - - void OnRectTransformRemoved() - { - TrySetResult(onRectTransformRemoved, onRectTransformRemoveds, AsyncUnit.Default); - } - - - public UniTask OnRectTransformRemovedAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onRectTransformRemoved, ref onRectTransformRemoveds, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncRectTransformTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncRectTransformTrigger.cs.meta deleted file mode 100644 index 98c4f70..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncRectTransformTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dfe3470221c66c84397c0783c62b24e7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncScrollTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncScrollTrigger.cs deleted file mode 100644 index 7a28c64..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncScrollTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncScrollTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onScroll; - AsyncTriggerPromiseDictionary onScrolls; - - - protected override IEnumerable GetPromises() - { - return Concat(onScroll, onScrolls); - } - - - void OnScroll(PointerEventData eventData) - { - TrySetResult(onScroll, onScrolls, eventData); - } - - - public UniTask OnScrollAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onScroll, ref onScrolls, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncScrollTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncScrollTrigger.cs.meta deleted file mode 100644 index 541bdbe..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncScrollTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7c751e9d3deb97d4d8691a8a583c2afd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSelectTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSelectTrigger.cs deleted file mode 100644 index 093ec79..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSelectTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncSelectTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onSelect; - AsyncTriggerPromiseDictionary onSelects; - - - protected override IEnumerable GetPromises() - { - return Concat(onSelect, onSelects); - } - - - void OnSelect(BaseEventData eventData) - { - TrySetResult(onSelect, onSelects, eventData); - } - - - public UniTask OnSelectAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onSelect, ref onSelects, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSelectTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSelectTrigger.cs.meta deleted file mode 100644 index dd4563b..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSelectTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fcc2347251a4fc5498a03f0c17382920 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncStartTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncStartTrigger.cs deleted file mode 100644 index 4c65c8c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncStartTrigger.cs +++ /dev/null @@ -1,64 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using UnityEngine; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncStartTrigger : MonoBehaviour - { - bool awakeCalled = false; - bool called = false; - UniTaskCompletionSource promise; - - void Awake() - { - awakeCalled = true; - } - - void Start() - { - called = true; - promise?.TrySetResult(); - } - - public UniTask StartAsync() - { - if (called) return UniTask.CompletedTask; - if (!awakeCalled) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this)); - } - return new UniTask(promise ?? (promise = new UniTaskCompletionSource())); - } - - private void OnDestroy() - { - promise?.TrySetCanceled(); - } - - class AwakeMonitor : IPlayerLoopItem - { - readonly AsyncStartTrigger trigger; - - public AwakeMonitor(AsyncStartTrigger trigger) - { - this.trigger = trigger; - } - - public bool MoveNext() - { - if (trigger.awakeCalled) return false; - if (trigger == null) - { - trigger.OnDestroy(); - return false; - } - return true; - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncStartTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncStartTrigger.cs.meta deleted file mode 100644 index 9ef06e8..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncStartTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b4fd0f75e54ec3d4fbcb7fc65b11646b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSubmitTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSubmitTrigger.cs deleted file mode 100644 index 0dd4206..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSubmitTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncSubmitTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onSubmit; - AsyncTriggerPromiseDictionary onSubmits; - - - protected override IEnumerable GetPromises() - { - return Concat(onSubmit, onSubmits); - } - - - void OnSubmit(BaseEventData eventData) - { - TrySetResult(onSubmit, onSubmits, eventData); - } - - - public UniTask OnSubmitAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onSubmit, ref onSubmits, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSubmitTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSubmitTrigger.cs.meta deleted file mode 100644 index 16b6b05..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncSubmitTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 97e85abc2d7ec0c44adfbe5ee971aad3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTransformChangedTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTransformChangedTrigger.cs deleted file mode 100644 index acad97e..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTransformChangedTrigger.cs +++ /dev/null @@ -1,69 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncTransformChangedTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onBeforeTransformParentChanged; - AsyncTriggerPromiseDictionary onBeforeTransformParentChangeds; - AsyncTriggerPromise onTransformParentChanged; - AsyncTriggerPromiseDictionary onTransformParentChangeds; - AsyncTriggerPromise onTransformChildrenChanged; - AsyncTriggerPromiseDictionary onTransformChildrenChangeds; - - - protected override IEnumerable GetPromises() - { - return Concat(onBeforeTransformParentChanged, onBeforeTransformParentChangeds, onTransformParentChanged, onTransformParentChangeds, onTransformChildrenChanged, onTransformChildrenChangeds); - } - - - void OnBeforeTransformParentChanged() - { - TrySetResult(onBeforeTransformParentChanged, onBeforeTransformParentChangeds, AsyncUnit.Default); - } - - - public UniTask OnBeforeTransformParentChangedAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onBeforeTransformParentChanged, ref onBeforeTransformParentChangeds, cancellationToken); - } - - - void OnTransformParentChanged() - { - TrySetResult(onTransformParentChanged, onTransformParentChangeds, AsyncUnit.Default); - } - - - public UniTask OnTransformParentChangedAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onTransformParentChanged, ref onTransformParentChangeds, cancellationToken); - } - - - void OnTransformChildrenChanged() - { - TrySetResult(onTransformChildrenChanged, onTransformChildrenChangeds, AsyncUnit.Default); - } - - - public UniTask OnTransformChildrenChangedAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onTransformChildrenChanged, ref onTransformChildrenChangeds, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTransformChangedTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTransformChangedTrigger.cs.meta deleted file mode 100644 index 60b6c38..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTransformChangedTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 053f983cd760f5e4394be8fd657243c1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTrigger2DTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTrigger2DTrigger.cs deleted file mode 100644 index dc33415..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTrigger2DTrigger.cs +++ /dev/null @@ -1,69 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncTrigger2DTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onTriggerEnter2D; - AsyncTriggerPromiseDictionary onTriggerEnter2Ds; - AsyncTriggerPromise onTriggerExit2D; - AsyncTriggerPromiseDictionary onTriggerExit2Ds; - AsyncTriggerPromise onTriggerStay2D; - AsyncTriggerPromiseDictionary onTriggerStay2Ds; - - - protected override IEnumerable GetPromises() - { - return Concat(onTriggerEnter2D, onTriggerEnter2Ds, onTriggerExit2D, onTriggerExit2Ds, onTriggerStay2D, onTriggerStay2Ds); - } - - - void OnTriggerEnter2D(Collider2D other) - { - TrySetResult(onTriggerEnter2D, onTriggerEnter2Ds, other); - } - - - public UniTask OnTriggerEnter2DAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onTriggerEnter2D, ref onTriggerEnter2Ds, cancellationToken); - } - - - void OnTriggerExit2D(Collider2D other) - { - TrySetResult(onTriggerExit2D, onTriggerExit2Ds, other); - } - - - public UniTask OnTriggerExit2DAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onTriggerExit2D, ref onTriggerExit2Ds, cancellationToken); - } - - - void OnTriggerStay2D(Collider2D other) - { - TrySetResult(onTriggerStay2D, onTriggerStay2Ds, other); - } - - - public UniTask OnTriggerStay2DAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onTriggerStay2D, ref onTriggerStay2Ds, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTrigger2DTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTrigger2DTrigger.cs.meta deleted file mode 100644 index 8d88bad..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTrigger2DTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 102f8eba36bc2a54e878e67aca9686e5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerBase.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerBase.cs deleted file mode 100644 index ceb4f7f..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerBase.cs +++ /dev/null @@ -1,271 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Threading; -using UniRx.Async.Internal; -using UnityEngine; - -namespace UniRx.Async.Triggers -{ - public interface ICancelablePromise - { - CancellationToken RegisteredCancellationToken { get; } - bool TrySetCanceled(); - } - - public class AsyncTriggerPromise : ReusablePromise, IPromise, ICancelablePromise - { - public CancellationToken RegisteredCancellationToken { get; private set; } - - public AsyncTriggerPromise() - : this(CancellationToken.None) - { - } - - public AsyncTriggerPromise(CancellationToken cancellationToken) - { - this.RegisteredCancellationToken = cancellationToken; - TaskTracker.TrackActiveTask(this); - } - - public override T GetResult() - { - if (Status == AwaiterStatus.Pending) return RawResult; - return base.GetResult(); - } - - public override bool TrySetResult(T result) - { - if (Status == AwaiterStatus.Pending) - { - // keep status as Pending. - this.ForceSetResult(result); - TryInvokeContinuation(); - return true; - } - return false; - } - - public override bool TrySetCanceled() - { - if (Status == AwaiterStatus.Canceled) return false; - TaskTracker.RemoveTracking(this); - return base.TrySetCanceled(); - } - } - - public interface ICancellationTokenKeyDictionary - { - void Remove(CancellationToken token); - } - - public class AsyncTriggerPromiseDictionary : - Dictionary>, - ICancellationTokenKeyDictionary, - IEnumerable - { - public AsyncTriggerPromiseDictionary() - : base(CancellationTokenEqualityComparer.Default) - { - } - - IEnumerator IEnumerable.GetEnumerator() - { - return Values.GetEnumerator(); - } - - void ICancellationTokenKeyDictionary.Remove(CancellationToken token) - { - this.Remove(token); - } - } - - public abstract class AsyncTriggerBase : MonoBehaviour - { - static readonly Action Callback = CancelCallback; - - bool calledAwake = false; - bool destroyCalled = false; - CancellationTokenRegistration[] registeredCancellations; - int registeredCancellationsCount; - - protected abstract IEnumerable GetPromises(); - - static protected IEnumerable Concat(ICancelablePromise p1, IEnumerable p1s) - { - if (p1 != null) yield return p1; - if (p1s != null) foreach (var item in p1s) yield return item; - } - - static protected IEnumerable Concat( - ICancelablePromise p1, IEnumerable p1s, - ICancelablePromise p2, IEnumerable p2s) - { - if (p1 != null) yield return p1; - if (p1s != null) foreach (var item in p1s) yield return item; - if (p2 != null) yield return p2; - if (p2s != null) foreach (var item in p2s) yield return item; - } - - static protected IEnumerable Concat( - ICancelablePromise p1, IEnumerable p1s, - ICancelablePromise p2, IEnumerable p2s, - ICancelablePromise p3, IEnumerable p3s) - { - if (p1 != null) yield return p1; - if (p1s != null) foreach (var item in p1s) yield return item; - if (p2 != null) yield return p2; - if (p2s != null) foreach (var item in p2s) yield return item; - if (p3 != null) yield return p3; - if (p3s != null) foreach (var item in p3s) yield return item; - } - - static protected IEnumerable Concat( - ICancelablePromise p1, IEnumerable p1s, - ICancelablePromise p2, IEnumerable p2s, - ICancelablePromise p3, IEnumerable p3s, - ICancelablePromise p4, IEnumerable p4s) - { - if (p1 != null) yield return p1; - if (p1s != null) foreach (var item in p1s) yield return item; - if (p2 != null) yield return p2; - if (p2s != null) foreach (var item in p2s) yield return item; - if (p3 != null) yield return p3; - if (p3s != null) foreach (var item in p3s) yield return item; - if (p4 != null) yield return p4; - if (p4s != null) foreach (var item in p4s) yield return item; - } - - // otherwise... - static protected IEnumerable Concat(params object[] promises) - { - foreach (var item in promises) - { - if (item is ICancelablePromise p) - { - yield return p; - } - else if (item is IEnumerable ps) - { - foreach (var p2 in ps) - { - yield return p2; - } - } - } - } - - protected UniTask GetOrAddPromise(ref AsyncTriggerPromise promise, ref AsyncTriggerPromiseDictionary promises, CancellationToken cancellationToken) - { - if (destroyCalled) return UniTask.FromCanceled(); - - if (!cancellationToken.CanBeCanceled) - { - if (promise == null) - { - promise = new AsyncTriggerPromise(); - if (!calledAwake) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this)); - } - } - return promise.Task; - } - - if (promises == null) promises = new AsyncTriggerPromiseDictionary(); - - if (promises.TryGetValue(cancellationToken, out var cancellablePromise)) - { - return cancellablePromise.Task; - } - - cancellablePromise = new AsyncTriggerPromise(); - promises.Add(cancellationToken, cancellablePromise); - if (!calledAwake) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this)); - } - - var registrationToken = cancellationToken.RegisterWithoutCaptureExecutionContext(Callback, Tuple.Create((ICancellationTokenKeyDictionary)promises, (ICancelablePromise)cancellablePromise)); - if (registeredCancellations == null) - { - registeredCancellations = ArrayPool.Shared.Rent(4); - } - ArrayPoolUtil.EnsureCapacity(ref registeredCancellations, registeredCancellationsCount + 1, ArrayPool.Shared); - registeredCancellations[registeredCancellationsCount++] = registrationToken; - - return cancellablePromise.Task; - } - - static void CancelCallback(object state) - { - var tuple = (Tuple)state; - var dict = tuple.Item1; - var promise = tuple.Item2; - - promise.TrySetCanceled(); - dict.Remove(promise.RegisteredCancellationToken); - } - - protected void TrySetResult(ReusablePromise promise, AsyncTriggerPromiseDictionary promises, T value) - { - if (promise != null) - { - promise.TrySetResult(value); - } - if (promises != null) - { - PromiseHelper.TrySetResultAll(promises.Values, value); - } - } - - void Awake() - { - calledAwake = true; - } - - void OnDestroy() - { - if (destroyCalled) return; - destroyCalled = true; - foreach (var item in GetPromises()) - { - item.TrySetCanceled(); - } - if (registeredCancellations != null) - { - for (int i = 0; i < registeredCancellationsCount; i++) - { - registeredCancellations[i].Dispose(); - registeredCancellations[i] = default(CancellationTokenRegistration); - } - ArrayPool.Shared.Return(registeredCancellations); - } - } - - class AwakeMonitor : IPlayerLoopItem - { - readonly AsyncTriggerBase trigger; - - public AwakeMonitor(AsyncTriggerBase trigger) - { - this.trigger = trigger; - } - - public bool MoveNext() - { - if (trigger.calledAwake) return false; - if (trigger == null) - { - trigger.OnDestroy(); - return false; - } - return true; - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerBase.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerBase.cs.meta deleted file mode 100644 index e101ea2..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2c0c2bcee832c6641b25949c412f020f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerExtensions.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerExtensions.cs deleted file mode 100644 index 8413968..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerExtensions.cs +++ /dev/null @@ -1,511 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Threading; -using UnityEngine; - -namespace UniRx.Async.Triggers -{ - public static class AsyncTriggerExtensions - { - // Util. - - static T GetOrAddComponent(GameObject gameObject) - where T : Component - { - var component = gameObject.GetComponent(); - if (component == null) - { - component = gameObject.AddComponent(); - } - - return component; - } - - // Special for single operation. - - /// This function is called when the MonoBehaviour will be destroyed. - public static UniTask OnDestroyAsync(this GameObject gameObject) - { - return gameObject.GetAsyncDestroyTrigger().OnDestroyAsync(); - } - - /// This function is called when the MonoBehaviour will be destroyed. - public static UniTask OnDestroyAsync(this Component component) - { - return component.GetAsyncDestroyTrigger().OnDestroyAsync(); - } - - /// This CancellationToken is canceled when the MonoBehaviour will be destroyed. - public static CancellationToken GetCancellationTokenOnDestroy(this GameObject gameObject) - { - return gameObject.GetAsyncDestroyTrigger().CancellationToken; - } - - /// This CancellationToken is canceled when the MonoBehaviour will be destroyed. - public static CancellationToken GetCancellationTokenOnDestroy(this Component component) - { - return component.GetAsyncDestroyTrigger().CancellationToken; - } - - public static UniTask StartAsync(this GameObject gameObject) - { - return gameObject.GetAsyncStartTrigger().StartAsync(); - } - - public static UniTask StartAsync(this Component component) - { - return component.GetAsyncStartTrigger().StartAsync(); - } - - public static UniTask AwakeAsync(this GameObject gameObject) - { - return gameObject.GetAsyncAwakeTrigger().AwakeAsync(); - } - - public static UniTask AwakeAsync(this Component component) - { - return component.GetAsyncAwakeTrigger().AwakeAsync(); - } - - // Get Triggers. - - /// Get for OnAnimatorIKAsync | OnAnimatorMoveAsync. - public static AsyncAnimatorTrigger GetAsyncAnimatorTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnAnimatorIKAsync | OnAnimatorMoveAsync. - public static AsyncAnimatorTrigger GetAsyncAnimatorTrigger(this Component component) - { - return component.gameObject.GetAsyncAnimatorTrigger(); - } - - /// Get for AwakeAsync. - public static AsyncAwakeTrigger GetAsyncAwakeTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for AwakeAsync. - public static AsyncAwakeTrigger GetAsyncAwakeTrigger(this Component component) - { - return component.gameObject.GetAsyncAwakeTrigger(); - } - - /// Get for OnBeginDragAsync. - public static AsyncBeginDragTrigger GetAsyncBeginDragTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnBeginDragAsync. - public static AsyncBeginDragTrigger GetAsyncBeginDragTrigger(this Component component) - { - return component.gameObject.GetAsyncBeginDragTrigger(); - } - - /// Get for OnCancelAsync. - public static AsyncCancelTrigger GetAsyncCancelTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnCancelAsync. - public static AsyncCancelTrigger GetAsyncCancelTrigger(this Component component) - { - return component.gameObject.GetAsyncCancelTrigger(); - } - - /// Get for OnCanvasGroupChangedAsync. - public static AsyncCanvasGroupChangedTrigger GetAsyncCanvasGroupChangedTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnCanvasGroupChangedAsync. - public static AsyncCanvasGroupChangedTrigger GetAsyncCanvasGroupChangedTrigger(this Component component) - { - return component.gameObject.GetAsyncCanvasGroupChangedTrigger(); - } - - /// Get for OnCollisionEnter2DAsync | OnCollisionExit2DAsync | OnCollisionStay2DAsync. - public static AsyncCollision2DTrigger GetAsyncCollision2DTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnCollisionEnter2DAsync | OnCollisionExit2DAsync | OnCollisionStay2DAsync. - public static AsyncCollision2DTrigger GetAsyncCollision2DTrigger(this Component component) - { - return component.gameObject.GetAsyncCollision2DTrigger(); - } - - /// Get for OnCollisionEnterAsync | OnCollisionExitAsync | OnCollisionStayAsync. - public static AsyncCollisionTrigger GetAsyncCollisionTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnCollisionEnterAsync | OnCollisionExitAsync | OnCollisionStayAsync. - public static AsyncCollisionTrigger GetAsyncCollisionTrigger(this Component component) - { - return component.gameObject.GetAsyncCollisionTrigger(); - } - - /// Get for OnDeselectAsync. - public static AsyncDeselectTrigger GetAsyncDeselectTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnDeselectAsync. - public static AsyncDeselectTrigger GetAsyncDeselectTrigger(this Component component) - { - return component.gameObject.GetAsyncDeselectTrigger(); - } - - /// Get for OnDestroyAsync. - public static AsyncDestroyTrigger GetAsyncDestroyTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnDestroyAsync. - public static AsyncDestroyTrigger GetAsyncDestroyTrigger(this Component component) - { - return component.gameObject.GetAsyncDestroyTrigger(); - } - - /// Get for OnDragAsync. - public static AsyncDragTrigger GetAsyncDragTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnDragAsync. - public static AsyncDragTrigger GetAsyncDragTrigger(this Component component) - { - return component.gameObject.GetAsyncDragTrigger(); - } - - /// Get for OnDropAsync. - public static AsyncDropTrigger GetAsyncDropTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnDropAsync. - public static AsyncDropTrigger GetAsyncDropTrigger(this Component component) - { - return component.gameObject.GetAsyncDropTrigger(); - } - - /// Get for OnEnableAsync | OnDisableAsync. - public static AsyncEnableDisableTrigger GetAsyncEnableDisableTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnEnableAsync | OnDisableAsync. - public static AsyncEnableDisableTrigger GetAsyncEnableDisableTrigger(this Component component) - { - return component.gameObject.GetAsyncEnableDisableTrigger(); - } - - /// Get for OnEndDragAsync. - public static AsyncEndDragTrigger GetAsyncEndDragTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnEndDragAsync. - public static AsyncEndDragTrigger GetAsyncEndDragTrigger(this Component component) - { - return component.gameObject.GetAsyncEndDragTrigger(); - } - - /// Get for FixedUpdateAsync. - public static AsyncFixedUpdateTrigger GetAsyncFixedUpdateTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for FixedUpdateAsync. - public static AsyncFixedUpdateTrigger GetAsyncFixedUpdateTrigger(this Component component) - { - return component.gameObject.GetAsyncFixedUpdateTrigger(); - } - - /// Get for OnInitializePotentialDragAsync. - public static AsyncInitializePotentialDragTrigger GetAsyncInitializePotentialDragTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnInitializePotentialDragAsync. - public static AsyncInitializePotentialDragTrigger GetAsyncInitializePotentialDragTrigger(this Component component) - { - return component.gameObject.GetAsyncInitializePotentialDragTrigger(); - } - - /// Get for OnJointBreakAsync. - public static AsyncJointTrigger GetAsyncJointTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnJointBreakAsync. - public static AsyncJointTrigger GetAsyncJointTrigger(this Component component) - { - return component.gameObject.GetAsyncJointTrigger(); - } - - /// Get for LateUpdateAsync. - public static AsyncLateUpdateTrigger GetAsyncLateUpdateTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for LateUpdateAsync. - public static AsyncLateUpdateTrigger GetAsyncLateUpdateTrigger(this Component component) - { - return component.gameObject.GetAsyncLateUpdateTrigger(); - } - -#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_METRO) - - /// Get for OnMouseDownAsync | OnMouseDragAsync | OnMouseEnterAsync | OnMouseExitAsync | OnMouseOverAsync | OnMouseUpAsync | OnMouseUpAsButtonAsync. - public static AsyncMouseTrigger GetAsyncMouseTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnMouseDownAsync | OnMouseDragAsync | OnMouseEnterAsync | OnMouseExitAsync | OnMouseOverAsync | OnMouseUpAsync | OnMouseUpAsButtonAsync. - public static AsyncMouseTrigger GetAsyncMouseTrigger(this Component component) - { - return component.gameObject.GetAsyncMouseTrigger(); - } - -#endif - - /// Get for OnMoveAsync. - public static AsyncMoveTrigger GetAsyncMoveTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnMoveAsync. - public static AsyncMoveTrigger GetAsyncMoveTrigger(this Component component) - { - return component.gameObject.GetAsyncMoveTrigger(); - } - - /// Get for OnParticleCollisionAsync | OnParticleTriggerAsync. - public static AsyncParticleTrigger GetAsyncParticleTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnParticleCollisionAsync | OnParticleTriggerAsync. - public static AsyncParticleTrigger GetAsyncParticleTrigger(this Component component) - { - return component.gameObject.GetAsyncParticleTrigger(); - } - - /// Get for OnPointerClickAsync. - public static AsyncPointerClickTrigger GetAsyncPointerClickTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnPointerClickAsync. - public static AsyncPointerClickTrigger GetAsyncPointerClickTrigger(this Component component) - { - return component.gameObject.GetAsyncPointerClickTrigger(); - } - - /// Get for OnPointerDownAsync. - public static AsyncPointerDownTrigger GetAsyncPointerDownTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnPointerDownAsync. - public static AsyncPointerDownTrigger GetAsyncPointerDownTrigger(this Component component) - { - return component.gameObject.GetAsyncPointerDownTrigger(); - } - - /// Get for OnPointerEnterAsync. - public static AsyncPointerEnterTrigger GetAsyncPointerEnterTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnPointerEnterAsync. - public static AsyncPointerEnterTrigger GetAsyncPointerEnterTrigger(this Component component) - { - return component.gameObject.GetAsyncPointerEnterTrigger(); - } - - /// Get for OnPointerExitAsync. - public static AsyncPointerExitTrigger GetAsyncPointerExitTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnPointerExitAsync. - public static AsyncPointerExitTrigger GetAsyncPointerExitTrigger(this Component component) - { - return component.gameObject.GetAsyncPointerExitTrigger(); - } - - /// Get for OnPointerUpAsync. - public static AsyncPointerUpTrigger GetAsyncPointerUpTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnPointerUpAsync. - public static AsyncPointerUpTrigger GetAsyncPointerUpTrigger(this Component component) - { - return component.gameObject.GetAsyncPointerUpTrigger(); - } - - /// Get for OnRectTransformDimensionsChange | OnRectTransformDimensionsChangeAsync | OnRectTransformRemoved | OnRectTransformRemovedAsync. - public static AsyncRectTransformTrigger GetAsyncRectTransformTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnRectTransformDimensionsChange | OnRectTransformDimensionsChangeAsync | OnRectTransformRemoved | OnRectTransformRemovedAsync. - public static AsyncRectTransformTrigger GetAsyncRectTransformTrigger(this Component component) - { - return component.gameObject.GetAsyncRectTransformTrigger(); - } - - /// Get for OnScrollAsync. - public static AsyncScrollTrigger GetAsyncScrollTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnScrollAsync. - public static AsyncScrollTrigger GetAsyncScrollTrigger(this Component component) - { - return component.gameObject.GetAsyncScrollTrigger(); - } - - /// Get for OnSelectAsync. - public static AsyncSelectTrigger GetAsyncSelectTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnSelectAsync. - public static AsyncSelectTrigger GetAsyncSelectTrigger(this Component component) - { - return component.gameObject.GetAsyncSelectTrigger(); - } - - /// Get for StartAsync. - public static AsyncStartTrigger GetAsyncStartTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for StartAsync. - public static AsyncStartTrigger GetAsyncStartTrigger(this Component component) - { - return component.gameObject.GetAsyncStartTrigger(); - } - - /// Get for OnSubmitAsync. - public static AsyncSubmitTrigger GetAsyncSubmitTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnSubmitAsync. - public static AsyncSubmitTrigger GetAsyncSubmitTrigger(this Component component) - { - return component.gameObject.GetAsyncSubmitTrigger(); - } - - /// Get for OnBeforeTransformParentChangedAsync | OnTransformParentChangedAsync | OnTransformChildrenChangedAsync. - public static AsyncTransformChangedTrigger GetAsyncTransformChangedTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnBeforeTransformParentChangedAsync | OnTransformParentChangedAsync | OnTransformChildrenChangedAsync. - public static AsyncTransformChangedTrigger GetAsyncTransformChangedTrigger(this Component component) - { - return component.gameObject.GetAsyncTransformChangedTrigger(); - } - - /// Get for OnTriggerEnter2DAsync | OnTriggerExit2DAsync | OnTriggerStay2DAsync. - public static AsyncTrigger2DTrigger GetAsyncTrigger2DTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnTriggerEnter2DAsync | OnTriggerExit2DAsync | OnTriggerStay2DAsync. - public static AsyncTrigger2DTrigger GetAsyncTrigger2DTrigger(this Component component) - { - return component.gameObject.GetAsyncTrigger2DTrigger(); - } - - /// Get for OnTriggerEnterAsync | OnTriggerExitAsync | OnTriggerStayAsync. - public static AsyncTriggerTrigger GetAsyncTriggerTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnTriggerEnterAsync | OnTriggerExitAsync | OnTriggerStayAsync. - public static AsyncTriggerTrigger GetAsyncTriggerTrigger(this Component component) - { - return component.gameObject.GetAsyncTriggerTrigger(); - } - - /// Get for OnUpdateSelectedAsync. - public static AsyncUpdateSelectedTrigger GetAsyncUpdateSelectedTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnUpdateSelectedAsync. - public static AsyncUpdateSelectedTrigger GetAsyncUpdateSelectedTrigger(this Component component) - { - return component.gameObject.GetAsyncUpdateSelectedTrigger(); - } - - /// Get for UpdateAsync. - public static AsyncUpdateTrigger GetAsyncUpdateTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for UpdateAsync. - public static AsyncUpdateTrigger GetAsyncUpdateTrigger(this Component component) - { - return component.gameObject.GetAsyncUpdateTrigger(); - } - - /// Get for OnBecameInvisibleAsync | OnBecameVisibleAsync. - public static AsyncVisibleTrigger GetAsyncVisibleTrigger(this GameObject gameObject) - { - return GetOrAddComponent(gameObject); - } - - /// Get for OnBecameInvisibleAsync | OnBecameVisibleAsync. - public static AsyncVisibleTrigger GetAsyncVisibleTrigger(this Component component) - { - return component.gameObject.GetAsyncVisibleTrigger(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerExtensions.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerExtensions.cs.meta deleted file mode 100644 index 348783d..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 59b61dbea1562a84fb7a38ae0a0a0f88 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerTrigger.cs deleted file mode 100644 index 22f3c94..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerTrigger.cs +++ /dev/null @@ -1,69 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncTriggerTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onTriggerEnter; - AsyncTriggerPromiseDictionary onTriggerEnters; - AsyncTriggerPromise onTriggerExit; - AsyncTriggerPromiseDictionary onTriggerExits; - AsyncTriggerPromise onTriggerStay; - AsyncTriggerPromiseDictionary onTriggerStays; - - - protected override IEnumerable GetPromises() - { - return Concat(onTriggerEnter, onTriggerEnters, onTriggerExit, onTriggerExits, onTriggerStay, onTriggerStays); - } - - - void OnTriggerEnter(Collider other) - { - TrySetResult(onTriggerEnter, onTriggerEnters, other); - } - - - public UniTask OnTriggerEnterAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onTriggerEnter, ref onTriggerEnters, cancellationToken); - } - - - void OnTriggerExit(Collider other) - { - TrySetResult(onTriggerExit, onTriggerExits, other); - } - - - public UniTask OnTriggerExitAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onTriggerExit, ref onTriggerExits, cancellationToken); - } - - - void OnTriggerStay(Collider other) - { - TrySetResult(onTriggerStay, onTriggerStays, other); - } - - - public UniTask OnTriggerStayAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onTriggerStay, ref onTriggerStays, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerTrigger.cs.meta deleted file mode 100644 index b9f7efb..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncTriggerTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 46bbbbaa910762c4786906e10b6b7b8e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateSelectedTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateSelectedTrigger.cs deleted file mode 100644 index 5f7536e..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateSelectedTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncUpdateSelectedTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onUpdateSelected; - AsyncTriggerPromiseDictionary onUpdateSelecteds; - - - protected override IEnumerable GetPromises() - { - return Concat(onUpdateSelected, onUpdateSelecteds); - } - - - void OnUpdateSelected(BaseEventData eventData) - { - TrySetResult(onUpdateSelected, onUpdateSelecteds, eventData); - } - - - public UniTask OnUpdateSelectedAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onUpdateSelected, ref onUpdateSelecteds, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateSelectedTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateSelectedTrigger.cs.meta deleted file mode 100644 index 395b43c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateSelectedTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ba5b0a4234e164e41b85f10b709d72e9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateTrigger.cs deleted file mode 100644 index 258eec9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateTrigger.cs +++ /dev/null @@ -1,41 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncUpdateTrigger : AsyncTriggerBase - { - AsyncTriggerPromise update; - AsyncTriggerPromiseDictionary updates; - - - protected override IEnumerable GetPromises() - { - return Concat(update, updates); - } - - - void Update() - { - TrySetResult(update, updates, AsyncUnit.Default); - } - - - public UniTask UpdateAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref update, ref updates, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateTrigger.cs.meta deleted file mode 100644 index d2277f7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncUpdateTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c6053bbe25af0d6439712f7c5fc4afc7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncVisibleTrigger.cs b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncVisibleTrigger.cs deleted file mode 100644 index df9596e..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncVisibleTrigger.cs +++ /dev/null @@ -1,55 +0,0 @@ - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; -using System.Threading; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace UniRx.Async.Triggers -{ - [DisallowMultipleComponent] - public class AsyncVisibleTrigger : AsyncTriggerBase - { - AsyncTriggerPromise onBecameInvisible; - AsyncTriggerPromiseDictionary onBecameInvisibles; - AsyncTriggerPromise onBecameVisible; - AsyncTriggerPromiseDictionary onBecameVisibles; - - - protected override IEnumerable GetPromises() - { - return Concat(onBecameInvisible, onBecameInvisibles, onBecameVisible, onBecameVisibles); - } - - - void OnBecameInvisible() - { - TrySetResult(onBecameInvisible, onBecameInvisibles, AsyncUnit.Default); - } - - - public UniTask OnBecameInvisibleAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onBecameInvisible, ref onBecameInvisibles, cancellationToken); - } - - - void OnBecameVisible() - { - TrySetResult(onBecameVisible, onBecameVisibles, AsyncUnit.Default); - } - - - public UniTask OnBecameVisibleAsync(CancellationToken cancellationToken = default(CancellationToken)) - { - return GetOrAddPromise(ref onBecameVisible, ref onBecameVisibles, cancellationToken); - } - - - } -} - -#endif - diff --git a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncVisibleTrigger.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncVisibleTrigger.cs.meta deleted file mode 100644 index 24b33ec..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/Triggers/AsyncVisibleTrigger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 57ebfef2a87c49c46ad6454db136f3ef -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniRx.Async.asmdef b/Assets/Plugins/UniRx/Scripts/Async/UniRx.Async.asmdef deleted file mode 100644 index bb982ba..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniRx.Async.asmdef +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "UniRx.Async", - "references": [], - "optionalUnityReferences": [], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false -} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Bridge.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Bridge.cs deleted file mode 100644 index 814bd02..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Bridge.cs +++ /dev/null @@ -1,20 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections; - -namespace UniRx.Async -{ - // UnityEngine Bridges. - - public partial struct UniTask - { - public static IEnumerator ToCoroutine(Func taskFactory) - { - return taskFactory().ToCoroutine(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Bridge.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Bridge.cs.meta deleted file mode 100644 index 6f8da80..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Bridge.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bd6beac8e0ebd264e9ba246c39429c72 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Delay.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Delay.cs deleted file mode 100644 index d828358..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Delay.cs +++ /dev/null @@ -1,246 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Runtime.CompilerServices; -using System.Threading; -using UniRx.Async.Internal; -using UnityEngine; - -namespace UniRx.Async -{ - public partial struct UniTask - { - public static YieldAwaitable Yield(PlayerLoopTiming timing = PlayerLoopTiming.Update) - { - // optimized for single continuation - return new YieldAwaitable(timing); - } - - public static UniTask Yield(PlayerLoopTiming timing, CancellationToken cancellationToken) - { - return new UniTask(new YieldPromise(timing, cancellationToken)); - } - - public static UniTask DelayFrame(int delayFrameCount, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken)) - { - if (delayFrameCount < 0) - { - throw new ArgumentOutOfRangeException("Delay does not allow minus delayFrameCount. delayFrameCount:" + delayFrameCount); - } - - var source = new DelayFramePromise(delayFrameCount, delayTiming, cancellationToken); - return source.Task; - } - - public static UniTask Delay(int millisecondsDelay, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken)) - { - var delayTimeSpan = TimeSpan.FromMilliseconds(millisecondsDelay); - if (delayTimeSpan < TimeSpan.Zero) - { - throw new ArgumentOutOfRangeException("Delay does not allow minus delayFrameCount. delayTimeSpan:" + delayTimeSpan); - } - - return (ignoreTimeScale) - ? new DelayIgnoreTimeScalePromise(delayTimeSpan, delayTiming, cancellationToken).Task - : new DelayPromise(delayTimeSpan, delayTiming, cancellationToken).Task; - } - - public static UniTask Delay(TimeSpan delayTimeSpan, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken)) - { - if (delayTimeSpan < TimeSpan.Zero) - { - throw new ArgumentOutOfRangeException("Delay does not allow minus delayFrameCount. delayTimeSpan:" + delayTimeSpan); - } - - return (ignoreTimeScale) - ? new DelayIgnoreTimeScalePromise(delayTimeSpan, delayTiming, cancellationToken).Task - : new DelayPromise(delayTimeSpan, delayTiming, cancellationToken).Task; - } - - class YieldPromise : PlayerLoopReusablePromiseBase - { - public YieldPromise(PlayerLoopTiming timing, CancellationToken cancellationToken) - : base(timing, cancellationToken, 2) - { - } - - protected override void OnRunningStart() - { - } - - public override bool MoveNext() - { - Complete(); - if (cancellationToken.IsCancellationRequested) - { - TrySetCanceled(); - } - else - { - TrySetResult(); - } - - return false; - } - } - - class DelayFramePromise : PlayerLoopReusablePromiseBase - { - readonly int delayFrameCount; - int currentFrameCount; - - public DelayFramePromise(int delayFrameCount, PlayerLoopTiming timing, CancellationToken cancellationToken) - : base(timing, cancellationToken, 2) - { - this.delayFrameCount = delayFrameCount; - this.currentFrameCount = 0; - } - - protected override void OnRunningStart() - { - currentFrameCount = 0; - } - - public override bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - Complete(); - TrySetCanceled(); - return false; - } - - if (currentFrameCount == delayFrameCount) - { - Complete(); - TrySetResult(currentFrameCount); - return false; - } - - currentFrameCount++; - return true; - } - } - - class DelayPromise : PlayerLoopReusablePromiseBase - { - readonly float delayFrameTimeSpan; - float elapsed; - - public DelayPromise(TimeSpan delayFrameTimeSpan, PlayerLoopTiming timing, CancellationToken cancellationToken) - : base(timing, cancellationToken, 2) - { - this.delayFrameTimeSpan = (float)delayFrameTimeSpan.TotalSeconds; - } - - protected override void OnRunningStart() - { - this.elapsed = 0.0f; - } - - public override bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - Complete(); - TrySetCanceled(); - return false; - } - - elapsed += Time.deltaTime; - if (elapsed >= delayFrameTimeSpan) - { - Complete(); - TrySetResult(); - return false; - } - - return true; - } - } - - class DelayIgnoreTimeScalePromise : PlayerLoopReusablePromiseBase - { - readonly float delayFrameTimeSpan; - float elapsed; - - public DelayIgnoreTimeScalePromise(TimeSpan delayFrameTimeSpan, PlayerLoopTiming timing, CancellationToken cancellationToken) - : base(timing, cancellationToken, 2) - { - this.delayFrameTimeSpan = (float)delayFrameTimeSpan.TotalSeconds; - } - - protected override void OnRunningStart() - { - this.elapsed = 0.0f; - } - - public override bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - Complete(); - TrySetCanceled(); - return false; - } - - elapsed += Time.unscaledDeltaTime; - - if (elapsed >= delayFrameTimeSpan) - { - Complete(); - TrySetResult(); - return false; - } - - return true; - } - } - } - - public struct YieldAwaitable - { - readonly PlayerLoopTiming timing; - - public YieldAwaitable(PlayerLoopTiming timing) - { - this.timing = timing; - } - - public Awaiter GetAwaiter() - { - return new Awaiter(timing); - } - - public UniTask ToUniTask() - { - return UniTask.Yield(timing, CancellationToken.None); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - readonly PlayerLoopTiming timing; - - public Awaiter(PlayerLoopTiming timing) - { - this.timing = timing; - } - - public bool IsCompleted => false; - - public void GetResult() { } - - public void OnCompleted(Action continuation) - { - PlayerLoopHelper.AddContinuation(timing, continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - PlayerLoopHelper.AddContinuation(timing, continuation); - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Delay.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Delay.cs.meta deleted file mode 100644 index 08ce579..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Delay.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ecff7972251de0848b2c0fa89bbd3489 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Factory.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Factory.cs deleted file mode 100644 index 0150450..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Factory.cs +++ /dev/null @@ -1,121 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; - -namespace UniRx.Async -{ - public partial struct UniTask - { - static readonly UniTask CanceledUniTask = new Func(() => - { - var promise = new UniTaskCompletionSource(); - promise.TrySetCanceled(); - promise.MarkHandled(); - return new UniTask(promise); - })(); - - public static UniTask CompletedTask - { - get - { - return new UniTask(); - } - } - - public static UniTask FromException(Exception ex) - { - var promise = new UniTaskCompletionSource(); - promise.TrySetException(ex); - promise.MarkHandled(); - return new UniTask(promise); - } - - public static UniTask FromException(Exception ex) - { - var promise = new UniTaskCompletionSource(); - promise.TrySetException(ex); - promise.MarkHandled(); - return new UniTask(promise); - } - - public static UniTask FromResult(T value) - { - return new UniTask(value); - } - - public static UniTask FromCanceled() - { - return CanceledUniTask; - } - - public static UniTask FromCanceled() - { - return CanceledUniTaskCache.Task; - } - - public static UniTask FromCanceled(CancellationToken token) - { - var promise = new UniTaskCompletionSource(); - promise.TrySetException(new OperationCanceledException(token)); - promise.MarkHandled(); - return new UniTask(promise); - } - - public static UniTask FromCanceled(CancellationToken token) - { - var promise = new UniTaskCompletionSource(); - promise.TrySetException(new OperationCanceledException(token)); - promise.MarkHandled(); - return new UniTask(promise); - } - - /// shorthand of new UniTask[T](Func[UniTask[T]] factory) - public static UniTask Lazy(Func> factory) - { - return new UniTask(factory); - } - - /// - /// helper of create add UniTaskVoid to delegate. - /// For example: FooEvent += () => UniTask.Void(async () => { /* */ }) - /// - public static void Void(Func asyncAction) - { - asyncAction().Forget(); - } - - /// - /// helper of create add UniTaskVoid to delegate. - /// For example: FooEvent += (sender, e) => UniTask.Void(async arg => { /* */ }, (sender, e)) - /// - public static void Void(Func asyncAction, T state) - { - asyncAction(state).Forget(); - } - - static class CanceledUniTaskCache - { - public static readonly UniTask Task; - - static CanceledUniTaskCache() - { - var promise = new UniTaskCompletionSource(); - promise.TrySetCanceled(); - promise.MarkHandled(); - Task = new UniTask(promise); - } - } - } - - internal static class CompletedTasks - { - public static readonly UniTask True = UniTask.FromResult(true); - public static readonly UniTask False = UniTask.FromResult(false); - public static readonly UniTask Zero = UniTask.FromResult(0); - public static readonly UniTask MinusOne = UniTask.FromResult(-1); - public static readonly UniTask One = UniTask.FromResult(1); - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Factory.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Factory.cs.meta deleted file mode 100644 index 31bc0c9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Factory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4e12b66d6b9bd7845b04a594cbe386b4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Run.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Run.cs deleted file mode 100644 index 508be8d..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Run.cs +++ /dev/null @@ -1,58 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; - -namespace UniRx.Async -{ - public partial struct UniTask - { - /// Run action on the threadPool and return to main thread if configureAwait = true. - public static async UniTask Run(Action action, bool configureAwait = true) - { - await UniTask.SwitchToThreadPool(); - action(); - if (configureAwait) - { - await UniTask.Yield(); - } - } - - /// Run action on the threadPool and return to main thread if configureAwait = true. - public static async UniTask Run(Action action, object state, bool configureAwait = true) - { - await UniTask.SwitchToThreadPool(); - action(state); - if (configureAwait) - { - await UniTask.Yield(); - } - } - - /// Run action on the threadPool and return to main thread if configureAwait = true. - public static async UniTask Run(Func func, bool configureAwait = true) - { - await UniTask.SwitchToThreadPool(); - var result = func(); - if (configureAwait) - { - await UniTask.Yield(); - } - return result; - } - - /// Run action on the threadPool and return to main thread if configureAwait = true. - public static async UniTask Run(Func func, object state, bool configureAwait = true) - { - await UniTask.SwitchToThreadPool(); - var result = func(state); - if (configureAwait) - { - await UniTask.Yield(); - } - return result; - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Run.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Run.cs.meta deleted file mode 100644 index 9a780ae..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Run.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8473162fc285a5f44bcca90f7da073e7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Threading.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Threading.cs deleted file mode 100644 index 8087e2d..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Threading.cs +++ /dev/null @@ -1,184 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; -using UniRx.Async.Internal; - -namespace UniRx.Async -{ - public partial struct UniTask - { -#if !UniRxLibrary - - /// - /// If running on mainthread, do nothing. Otherwise, same as UniTask.Yield(PlayerLoopTiming.Update). - /// - public static SwitchToMainThreadAwaitable SwitchToMainThread() - { - return new SwitchToMainThreadAwaitable(); - } - -#endif - - public static SwitchToThreadPoolAwaitable SwitchToThreadPool() - { - return new SwitchToThreadPoolAwaitable(); - } - - public static SwitchToTaskPoolAwaitable SwitchToTaskPool() - { - return new SwitchToTaskPoolAwaitable(); - } - - public static SwitchToSynchronizationContextAwaitable SwitchToSynchronizationContext(SynchronizationContext syncContext) - { - Error.ThrowArgumentNullException(syncContext, nameof(syncContext)); - return new SwitchToSynchronizationContextAwaitable(syncContext); - } - } - -#if !UniRxLibrary - - public struct SwitchToMainThreadAwaitable - { - public Awaiter GetAwaiter() => new Awaiter(); - - public struct Awaiter : ICriticalNotifyCompletion - { - public bool IsCompleted - { - get - { - var currentThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId; - if (PlayerLoopHelper.MainThreadId == currentThreadId) - { - return true; // run immediate. - } - else - { - return false; // register continuation. - } - } - } - - public void GetResult() { } - - public void OnCompleted(Action continuation) - { - PlayerLoopHelper.AddContinuation(PlayerLoopTiming.Update, continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - PlayerLoopHelper.AddContinuation(PlayerLoopTiming.Update, continuation); - } - } - } - -#endif - - public struct SwitchToThreadPoolAwaitable - { - public Awaiter GetAwaiter() => new Awaiter(); - - public struct Awaiter : ICriticalNotifyCompletion - { - static readonly WaitCallback switchToCallback = Callback; - - public bool IsCompleted => false; - public void GetResult() { } - - public void OnCompleted(Action continuation) - { - ThreadPool.UnsafeQueueUserWorkItem(switchToCallback, continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - ThreadPool.UnsafeQueueUserWorkItem(switchToCallback, continuation); - } - - static void Callback(object state) - { - var continuation = (Action)state; - continuation(); - } - } - } - - public struct SwitchToTaskPoolAwaitable - { - public Awaiter GetAwaiter() => new Awaiter(); - - public struct Awaiter : ICriticalNotifyCompletion - { - static readonly Action switchToCallback = Callback; - - public bool IsCompleted => false; - public void GetResult() { } - - public void OnCompleted(Action continuation) - { - Task.Factory.StartNew(switchToCallback, continuation, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); - } - - public void UnsafeOnCompleted(Action continuation) - { - Task.Factory.StartNew(switchToCallback, continuation, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); - } - - static void Callback(object state) - { - var continuation = (Action)state; - continuation(); - } - } - } - - public struct SwitchToSynchronizationContextAwaitable - { - readonly SynchronizationContext synchronizationContext; - - public SwitchToSynchronizationContextAwaitable(SynchronizationContext synchronizationContext) - { - this.synchronizationContext = synchronizationContext; - } - - public Awaiter GetAwaiter() => new Awaiter(synchronizationContext); - - public struct Awaiter : ICriticalNotifyCompletion - { - static readonly SendOrPostCallback switchToCallback = Callback; - readonly SynchronizationContext synchronizationContext; - - public Awaiter(SynchronizationContext synchronizationContext) - { - this.synchronizationContext = synchronizationContext; - } - - public bool IsCompleted => false; - public void GetResult() { } - - public void OnCompleted(Action continuation) - { - synchronizationContext.Post(switchToCallback, continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - synchronizationContext.Post(switchToCallback, continuation); - } - - static void Callback(object state) - { - var continuation = (Action)state; - continuation(); - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Threading.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.Threading.cs.meta deleted file mode 100644 index fa512b8..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.Threading.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4132ea600454134439fa2c7eb931b5e6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WaitUntil.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WaitUntil.cs deleted file mode 100644 index 7326201..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WaitUntil.cs +++ /dev/null @@ -1,235 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Threading; -using UniRx.Async.Internal; - -namespace UniRx.Async -{ - public partial struct UniTask - { - public static UniTask WaitUntil(Func predicate, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken)) - { - var promise = new WaitUntilPromise(predicate, timing, cancellationToken); - return promise.Task; - } - - public static UniTask WaitWhile(Func predicate, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken)) - { - var promise = new WaitWhilePromise(predicate, timing, cancellationToken); - return promise.Task; - } - - public static UniTask WaitUntilValueChanged(T target, Func monitorFunction, PlayerLoopTiming monitorTiming = PlayerLoopTiming.Update, IEqualityComparer equalityComparer = null, CancellationToken cancellationToken = default(CancellationToken)) - where T : class - { - var unityObject = target as UnityEngine.Object; - var isUnityObject = !object.ReferenceEquals(target, null); // don't use (unityObject == null) - - return (isUnityObject) - ? new WaitUntilValueChangedUnityObjectPromise(target, monitorFunction, equalityComparer, monitorTiming, cancellationToken).Task - : new WaitUntilValueChangedStandardObjectPromise(target, monitorFunction, equalityComparer, monitorTiming, cancellationToken).Task; - } - - class WaitUntilPromise : PlayerLoopReusablePromiseBase - { - readonly Func predicate; - - public WaitUntilPromise(Func predicate, PlayerLoopTiming timing, CancellationToken cancellationToken) - : base(timing, cancellationToken, 1) - { - this.predicate = predicate; - } - - protected override void OnRunningStart() - { - } - - public override bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - Complete(); - TrySetCanceled(); - return false; - } - - bool result = default(bool); - try - { - result = predicate(); - } - catch (Exception ex) - { - Complete(); - TrySetException(ex); - return false; - } - - if (result) - { - Complete(); - TrySetResult(); - return false; - } - - return true; - } - } - - class WaitWhilePromise : PlayerLoopReusablePromiseBase - { - readonly Func predicate; - - public WaitWhilePromise(Func predicate, PlayerLoopTiming timing, CancellationToken cancellationToken) - : base(timing, cancellationToken, 1) - { - this.predicate = predicate; - } - - protected override void OnRunningStart() - { - } - - public override bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - Complete(); - TrySetCanceled(); - return false; - } - - bool result = default(bool); - try - { - result = predicate(); - } - catch (Exception ex) - { - Complete(); - TrySetException(ex); - return false; - } - - if (!result) - { - Complete(); - TrySetResult(); - return false; - } - - return true; - } - } - - // where T : UnityEngine.Object, can not add constraint - class WaitUntilValueChangedUnityObjectPromise : PlayerLoopReusablePromiseBase - { - readonly T target; - readonly Func monitorFunction; - readonly IEqualityComparer equalityComparer; - U currentValue; - - public WaitUntilValueChangedUnityObjectPromise(T target, Func monitorFunction, IEqualityComparer equalityComparer, PlayerLoopTiming timing, CancellationToken cancellationToken) - : base(timing, cancellationToken, 1) - { - this.target = target; - this.monitorFunction = monitorFunction; - this.equalityComparer = equalityComparer ?? UnityEqualityComparer.GetDefault(); - this.currentValue = monitorFunction(target); - } - - protected override void OnRunningStart() - { - } - - public override bool MoveNext() - { - if (cancellationToken.IsCancellationRequested || target == null) // destroyed = cancel. - { - Complete(); - TrySetCanceled(); - return false; - } - - U nextValue = default(U); - try - { - nextValue = monitorFunction(target); - if (equalityComparer.Equals(currentValue, nextValue)) - { - return true; - } - } - catch (Exception ex) - { - Complete(); - TrySetException(ex); - return false; - } - - Complete(); - currentValue = nextValue; - TrySetResult(nextValue); - return false; - } - } - - class WaitUntilValueChangedStandardObjectPromise : PlayerLoopReusablePromiseBase - where T : class - { - readonly WeakReference target; - readonly Func monitorFunction; - readonly IEqualityComparer equalityComparer; - U currentValue; - - public WaitUntilValueChangedStandardObjectPromise(T target, Func monitorFunction, IEqualityComparer equalityComparer, PlayerLoopTiming timing, CancellationToken cancellationToken) - : base(timing, cancellationToken, 1) - { - this.target = new WeakReference(target, false); // wrap in WeakReference. - this.monitorFunction = monitorFunction; - this.equalityComparer = equalityComparer ?? UnityEqualityComparer.GetDefault(); - this.currentValue = monitorFunction(target); - } - - protected override void OnRunningStart() - { - } - - public override bool MoveNext() - { - if (cancellationToken.IsCancellationRequested || !target.TryGetTarget(out var t)) - { - Complete(); - TrySetCanceled(); - return false; - } - - U nextValue = default(U); - try - { - nextValue = monitorFunction(t); - if (equalityComparer.Equals(currentValue, nextValue)) - { - return true; - } - } - catch (Exception ex) - { - Complete(); - TrySetException(ex); - return false; - } - - Complete(); - currentValue = nextValue; - TrySetResult(nextValue); - return false; - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WaitUntil.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WaitUntil.cs.meta deleted file mode 100644 index 6e64dc7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WaitUntil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 87c9c533491903a4288536b5ac173db8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.Generated.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.Generated.cs deleted file mode 100644 index bda09db..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.Generated.cs +++ /dev/null @@ -1,1863 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.ExceptionServices; -using System.Threading; - -namespace UniRx.Async -{ - public partial struct UniTask - { - public static async UniTask<(T1 result1, T2 result2)> WhenAll(UniTask task1, UniTask task2) - { - return await new WhenAllPromise(task1, task2); - } - - public static async UniTask<(T1 result1, T2 result2, T3 result3)> WhenAll(UniTask task1, UniTask task2, UniTask task3) - { - return await new WhenAllPromise(task1, task2, task3); - } - - public static async UniTask<(T1 result1, T2 result2, T3 result3, T4 result4)> WhenAll(UniTask task1, UniTask task2, UniTask task3, UniTask task4) - { - return await new WhenAllPromise(task1, task2, task3, task4); - } - - public static async UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)> WhenAll(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) - { - return await new WhenAllPromise(task1, task2, task3, task4, task5); - } - - public static async UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6)> WhenAll(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) - { - return await new WhenAllPromise(task1, task2, task3, task4, task5, task6); - } - - public static async UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7)> WhenAll(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) - { - return await new WhenAllPromise(task1, task2, task3, task4, task5, task6, task7); - } - - class WhenAllPromise - { - const int MaxCount = 2; - - T1 result1; - T2 result2; - ExceptionDispatchInfo exception; - int completeCount; - Action whenComplete; - - public WhenAllPromise(UniTask task1, UniTask task2) - { - this.completeCount = 0; - this.whenComplete = null; - this.result1 = default(T1); - this.result2 = default(T2); - this.exception = null; - - RunTask1(task1); - RunTask2(task2); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - void RunTask1(UniTask task) - { - if (task.IsCompleted) - { - try - { - result1 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask1Async(task).Forget(); - } - } - - async UniTaskVoid RunTask1Async(UniTask task) - { - try - { - result1 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask2(UniTask task) - { - if (task.IsCompleted) - { - try - { - result2 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask2Async(task).Forget(); - } - } - - async UniTaskVoid RunTask2Async(UniTask task) - { - try - { - result2 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAllPromise parent; - - public Awaiter(WhenAllPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.exception != null || parent.completeCount == MaxCount; - } - } - - public (T1, T2) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return (parent.result1, parent.result2); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAllPromise - { - const int MaxCount = 3; - - T1 result1; - T2 result2; - T3 result3; - ExceptionDispatchInfo exception; - int completeCount; - Action whenComplete; - - public WhenAllPromise(UniTask task1, UniTask task2, UniTask task3) - { - this.completeCount = 0; - this.whenComplete = null; - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.exception = null; - - RunTask1(task1); - RunTask2(task2); - RunTask3(task3); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - void RunTask1(UniTask task) - { - if (task.IsCompleted) - { - try - { - result1 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask1Async(task).Forget(); - } - } - - async UniTaskVoid RunTask1Async(UniTask task) - { - try - { - result1 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask2(UniTask task) - { - if (task.IsCompleted) - { - try - { - result2 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask2Async(task).Forget(); - } - } - - async UniTaskVoid RunTask2Async(UniTask task) - { - try - { - result2 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask3(UniTask task) - { - if (task.IsCompleted) - { - try - { - result3 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask3Async(task).Forget(); - } - } - - async UniTaskVoid RunTask3Async(UniTask task) - { - try - { - result3 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAllPromise parent; - - public Awaiter(WhenAllPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.exception != null || parent.completeCount == MaxCount; - } - } - - public (T1, T2, T3) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return (parent.result1, parent.result2, parent.result3); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAllPromise - { - const int MaxCount = 4; - - T1 result1; - T2 result2; - T3 result3; - T4 result4; - ExceptionDispatchInfo exception; - int completeCount; - Action whenComplete; - - public WhenAllPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4) - { - this.completeCount = 0; - this.whenComplete = null; - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.result4 = default(T4); - this.exception = null; - - RunTask1(task1); - RunTask2(task2); - RunTask3(task3); - RunTask4(task4); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - void RunTask1(UniTask task) - { - if (task.IsCompleted) - { - try - { - result1 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask1Async(task).Forget(); - } - } - - async UniTaskVoid RunTask1Async(UniTask task) - { - try - { - result1 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask2(UniTask task) - { - if (task.IsCompleted) - { - try - { - result2 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask2Async(task).Forget(); - } - } - - async UniTaskVoid RunTask2Async(UniTask task) - { - try - { - result2 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask3(UniTask task) - { - if (task.IsCompleted) - { - try - { - result3 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask3Async(task).Forget(); - } - } - - async UniTaskVoid RunTask3Async(UniTask task) - { - try - { - result3 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask4(UniTask task) - { - if (task.IsCompleted) - { - try - { - result4 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask4Async(task).Forget(); - } - } - - async UniTaskVoid RunTask4Async(UniTask task) - { - try - { - result4 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAllPromise parent; - - public Awaiter(WhenAllPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.exception != null || parent.completeCount == MaxCount; - } - } - - public (T1, T2, T3, T4) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return (parent.result1, parent.result2, parent.result3, parent.result4); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAllPromise - { - const int MaxCount = 5; - - T1 result1; - T2 result2; - T3 result3; - T4 result4; - T5 result5; - ExceptionDispatchInfo exception; - int completeCount; - Action whenComplete; - - public WhenAllPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) - { - this.completeCount = 0; - this.whenComplete = null; - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.result4 = default(T4); - this.result5 = default(T5); - this.exception = null; - - RunTask1(task1); - RunTask2(task2); - RunTask3(task3); - RunTask4(task4); - RunTask5(task5); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - void RunTask1(UniTask task) - { - if (task.IsCompleted) - { - try - { - result1 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask1Async(task).Forget(); - } - } - - async UniTaskVoid RunTask1Async(UniTask task) - { - try - { - result1 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask2(UniTask task) - { - if (task.IsCompleted) - { - try - { - result2 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask2Async(task).Forget(); - } - } - - async UniTaskVoid RunTask2Async(UniTask task) - { - try - { - result2 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask3(UniTask task) - { - if (task.IsCompleted) - { - try - { - result3 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask3Async(task).Forget(); - } - } - - async UniTaskVoid RunTask3Async(UniTask task) - { - try - { - result3 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask4(UniTask task) - { - if (task.IsCompleted) - { - try - { - result4 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask4Async(task).Forget(); - } - } - - async UniTaskVoid RunTask4Async(UniTask task) - { - try - { - result4 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask5(UniTask task) - { - if (task.IsCompleted) - { - try - { - result5 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask5Async(task).Forget(); - } - } - - async UniTaskVoid RunTask5Async(UniTask task) - { - try - { - result5 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAllPromise parent; - - public Awaiter(WhenAllPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.exception != null || parent.completeCount == MaxCount; - } - } - - public (T1, T2, T3, T4, T5) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return (parent.result1, parent.result2, parent.result3, parent.result4, parent.result5); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAllPromise - { - const int MaxCount = 6; - - T1 result1; - T2 result2; - T3 result3; - T4 result4; - T5 result5; - T6 result6; - ExceptionDispatchInfo exception; - int completeCount; - Action whenComplete; - - public WhenAllPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) - { - this.completeCount = 0; - this.whenComplete = null; - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.result4 = default(T4); - this.result5 = default(T5); - this.result6 = default(T6); - this.exception = null; - - RunTask1(task1); - RunTask2(task2); - RunTask3(task3); - RunTask4(task4); - RunTask5(task5); - RunTask6(task6); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - void RunTask1(UniTask task) - { - if (task.IsCompleted) - { - try - { - result1 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask1Async(task).Forget(); - } - } - - async UniTaskVoid RunTask1Async(UniTask task) - { - try - { - result1 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask2(UniTask task) - { - if (task.IsCompleted) - { - try - { - result2 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask2Async(task).Forget(); - } - } - - async UniTaskVoid RunTask2Async(UniTask task) - { - try - { - result2 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask3(UniTask task) - { - if (task.IsCompleted) - { - try - { - result3 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask3Async(task).Forget(); - } - } - - async UniTaskVoid RunTask3Async(UniTask task) - { - try - { - result3 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask4(UniTask task) - { - if (task.IsCompleted) - { - try - { - result4 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask4Async(task).Forget(); - } - } - - async UniTaskVoid RunTask4Async(UniTask task) - { - try - { - result4 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask5(UniTask task) - { - if (task.IsCompleted) - { - try - { - result5 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask5Async(task).Forget(); - } - } - - async UniTaskVoid RunTask5Async(UniTask task) - { - try - { - result5 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask6(UniTask task) - { - if (task.IsCompleted) - { - try - { - result6 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask6Async(task).Forget(); - } - } - - async UniTaskVoid RunTask6Async(UniTask task) - { - try - { - result6 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAllPromise parent; - - public Awaiter(WhenAllPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.exception != null || parent.completeCount == MaxCount; - } - } - - public (T1, T2, T3, T4, T5, T6) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return (parent.result1, parent.result2, parent.result3, parent.result4, parent.result5, parent.result6); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAllPromise - { - const int MaxCount = 7; - - T1 result1; - T2 result2; - T3 result3; - T4 result4; - T5 result5; - T6 result6; - T7 result7; - ExceptionDispatchInfo exception; - int completeCount; - Action whenComplete; - - public WhenAllPromise(UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) - { - this.completeCount = 0; - this.whenComplete = null; - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.result4 = default(T4); - this.result5 = default(T5); - this.result6 = default(T6); - this.result7 = default(T7); - this.exception = null; - - RunTask1(task1); - RunTask2(task2); - RunTask3(task3); - RunTask4(task4); - RunTask5(task5); - RunTask6(task6); - RunTask7(task7); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - void RunTask1(UniTask task) - { - if (task.IsCompleted) - { - try - { - result1 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask1Async(task).Forget(); - } - } - - async UniTaskVoid RunTask1Async(UniTask task) - { - try - { - result1 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask2(UniTask task) - { - if (task.IsCompleted) - { - try - { - result2 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask2Async(task).Forget(); - } - } - - async UniTaskVoid RunTask2Async(UniTask task) - { - try - { - result2 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask3(UniTask task) - { - if (task.IsCompleted) - { - try - { - result3 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask3Async(task).Forget(); - } - } - - async UniTaskVoid RunTask3Async(UniTask task) - { - try - { - result3 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask4(UniTask task) - { - if (task.IsCompleted) - { - try - { - result4 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask4Async(task).Forget(); - } - } - - async UniTaskVoid RunTask4Async(UniTask task) - { - try - { - result4 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask5(UniTask task) - { - if (task.IsCompleted) - { - try - { - result5 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask5Async(task).Forget(); - } - } - - async UniTaskVoid RunTask5Async(UniTask task) - { - try - { - result5 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask6(UniTask task) - { - if (task.IsCompleted) - { - try - { - result6 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask6Async(task).Forget(); - } - } - - async UniTaskVoid RunTask6Async(UniTask task) - { - try - { - result6 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - void RunTask7(UniTask task) - { - if (task.IsCompleted) - { - try - { - result7 = task.Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - else - { - RunTask7Async(task).Forget(); - } - } - - async UniTaskVoid RunTask7Async(UniTask task) - { - try - { - result7 = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == MaxCount) - { - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAllPromise parent; - - public Awaiter(WhenAllPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.exception != null || parent.completeCount == MaxCount; - } - } - - public (T1, T2, T3, T4, T5, T6, T7) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return (parent.result1, parent.result2, parent.result3, parent.result4, parent.result5, parent.result6, parent.result7); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.Generated.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.Generated.cs.meta deleted file mode 100644 index 40ed46c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.Generated.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5110117231c8a6d4095fd0cbd3f4c142 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.cs deleted file mode 100644 index 715e55b..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.cs +++ /dev/null @@ -1,298 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Runtime.ExceptionServices; -using System.Threading; -using UniRx.Async.Internal; - -namespace UniRx.Async -{ - public partial struct UniTask - { - // UniTask - - public static async UniTask WhenAll(params UniTask[] tasks) - { - return await new WhenAllPromise(tasks, tasks.Length); - } - - public static async UniTask WhenAll(IEnumerable> tasks) - { - WhenAllPromise promise; - using (var span = ArrayPoolUtil.Materialize(tasks)) - { - promise = new WhenAllPromise(span.Array, span.Length); - } - - return await promise; - } - - public static async UniTask WhenAll(params UniTask[] tasks) - { - await new WhenAllPromise(tasks, tasks.Length); - } - - public static async UniTask WhenAll(IEnumerable tasks) - { - WhenAllPromise promise; - using (var span = ArrayPoolUtil.Materialize(tasks)) - { - promise = new WhenAllPromise(span.Array, span.Length); - } - - await promise; - } - - class WhenAllPromise - { - readonly T[] result; - int completeCount; - Action whenComplete; - ExceptionDispatchInfo exception; - - public WhenAllPromise(UniTask[] tasks, int tasksLength) - { - this.completeCount = 0; - this.whenComplete = null; - this.exception = null; - this.result = new T[tasksLength]; - - for (int i = 0; i < tasksLength; i++) - { - if (tasks[i].IsCompleted) - { - T value = default(T); - try - { - value = tasks[i].Result; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - continue; - } - - result[i] = value; - var count = Interlocked.Increment(ref completeCount); - if (count == result.Length) - { - TryCallContinuation(); - } - } - else - { - RunTask(tasks[i], i).Forget(); - } - } - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask(UniTask task, int index) - { - T value = default(T); - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - result[index] = value; - var count = Interlocked.Increment(ref completeCount); - if (count == result.Length) - { - TryCallContinuation(); - } - } - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAllPromise parent; - - public Awaiter(WhenAllPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.exception != null || parent.result.Length == parent.completeCount; - } - } - - public T[] GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return parent.result; - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAllPromise - { - int completeCount; - int resultLength; - Action whenComplete; - ExceptionDispatchInfo exception; - - public WhenAllPromise(UniTask[] tasks, int tasksLength) - { - this.completeCount = 0; - this.whenComplete = null; - this.exception = null; - this.resultLength = tasksLength; - - for (int i = 0; i < tasksLength; i++) - { - if (tasks[i].IsCompleted) - { - try - { - tasks[i].GetResult(); - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - continue; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == resultLength) - { - TryCallContinuation(); - } - } - else - { - RunTask(tasks[i], i).Forget(); - } - } - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask(UniTask task, int index) - { - try - { - await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == resultLength) - { - TryCallContinuation(); - } - } - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAllPromise parent; - - public Awaiter(WhenAllPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.exception != null || parent.resultLength == parent.completeCount; - } - } - - public void GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.cs.meta deleted file mode 100644 index 0366aa8..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAll.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 355997a305ba64248822eec34998a1a0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.Generated.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.Generated.cs deleted file mode 100644 index ebc0fe2..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.Generated.cs +++ /dev/null @@ -1,1527 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.ExceptionServices; -using System.Threading; - -namespace UniRx.Async -{ - public partial struct UniTask - { - public static async UniTask<(int winArgumentIndex, (bool hasResult, T0 result0), (bool hasResult, T1 result1))> WhenAny(UniTask task0, UniTask task1) - { - return await new WhenAnyPromise(task0, task1); - } - - public static async UniTask<(int winArgumentIndex, (bool hasResult, T0 result0), (bool hasResult, T1 result1), (bool hasResult, T2 result2))> WhenAny(UniTask task0, UniTask task1, UniTask task2) - { - return await new WhenAnyPromise(task0, task1, task2); - } - - public static async UniTask<(int winArgumentIndex, (bool hasResult, T0 result0), (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3))> WhenAny(UniTask task0, UniTask task1, UniTask task2, UniTask task3) - { - return await new WhenAnyPromise(task0, task1, task2, task3); - } - - public static async UniTask<(int winArgumentIndex, (bool hasResult, T0 result0), (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4))> WhenAny(UniTask task0, UniTask task1, UniTask task2, UniTask task3, UniTask task4) - { - return await new WhenAnyPromise(task0, task1, task2, task3, task4); - } - - public static async UniTask<(int winArgumentIndex, (bool hasResult, T0 result0), (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5))> WhenAny(UniTask task0, UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) - { - return await new WhenAnyPromise(task0, task1, task2, task3, task4, task5); - } - - public static async UniTask<(int winArgumentIndex, (bool hasResult, T0 result0), (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6))> WhenAny(UniTask task0, UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) - { - return await new WhenAnyPromise(task0, task1, task2, task3, task4, task5, task6); - } - - public static async UniTask<(int winArgumentIndex, (bool hasResult, T0 result0), (bool hasResult, T1 result1), (bool hasResult, T2 result2), (bool hasResult, T3 result3), (bool hasResult, T4 result4), (bool hasResult, T5 result5), (bool hasResult, T6 result6), (bool hasResult, T7 result7))> WhenAny(UniTask task0, UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) - { - return await new WhenAnyPromise(task0, task1, task2, task3, task4, task5, task6, task7); - } - - class WhenAnyPromise - { - T0 result0; - T1 result1; - ExceptionDispatchInfo exception; - Action whenComplete; - int completeCount; - int winArgumentIndex; - - bool IsCompleted => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask task0, UniTask task1) - { - this.whenComplete = null; - this.exception = null; - this.completeCount = 0; - this.winArgumentIndex = -1; - this.result0 = default(T0); - this.result1 = default(T1); - - RunTask0(task0).Forget(); - RunTask1(task1).Forget(); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask0(UniTask task) - { - T0 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result0 = value; - Volatile.Write(ref winArgumentIndex, 0); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask1(UniTask task) - { - T1 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result1 = value; - Volatile.Write(ref winArgumentIndex, 1); - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsCompleted; - } - } - - public (int, (bool, T0), (bool, T1)) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - var i = parent.winArgumentIndex; - return (i, (i == 0, parent.result0), (i == 1, parent.result1)); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAnyPromise - { - T0 result0; - T1 result1; - T2 result2; - ExceptionDispatchInfo exception; - Action whenComplete; - int completeCount; - int winArgumentIndex; - - bool IsCompleted => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask task0, UniTask task1, UniTask task2) - { - this.whenComplete = null; - this.exception = null; - this.completeCount = 0; - this.winArgumentIndex = -1; - this.result0 = default(T0); - this.result1 = default(T1); - this.result2 = default(T2); - - RunTask0(task0).Forget(); - RunTask1(task1).Forget(); - RunTask2(task2).Forget(); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask0(UniTask task) - { - T0 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result0 = value; - Volatile.Write(ref winArgumentIndex, 0); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask1(UniTask task) - { - T1 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result1 = value; - Volatile.Write(ref winArgumentIndex, 1); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask2(UniTask task) - { - T2 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result2 = value; - Volatile.Write(ref winArgumentIndex, 2); - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsCompleted; - } - } - - public (int, (bool, T0), (bool, T1), (bool, T2)) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - var i = parent.winArgumentIndex; - return (i, (i == 0, parent.result0), (i == 1, parent.result1), (i == 2, parent.result2)); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAnyPromise - { - T0 result0; - T1 result1; - T2 result2; - T3 result3; - ExceptionDispatchInfo exception; - Action whenComplete; - int completeCount; - int winArgumentIndex; - - bool IsCompleted => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask task0, UniTask task1, UniTask task2, UniTask task3) - { - this.whenComplete = null; - this.exception = null; - this.completeCount = 0; - this.winArgumentIndex = -1; - this.result0 = default(T0); - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - - RunTask0(task0).Forget(); - RunTask1(task1).Forget(); - RunTask2(task2).Forget(); - RunTask3(task3).Forget(); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask0(UniTask task) - { - T0 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result0 = value; - Volatile.Write(ref winArgumentIndex, 0); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask1(UniTask task) - { - T1 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result1 = value; - Volatile.Write(ref winArgumentIndex, 1); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask2(UniTask task) - { - T2 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result2 = value; - Volatile.Write(ref winArgumentIndex, 2); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask3(UniTask task) - { - T3 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result3 = value; - Volatile.Write(ref winArgumentIndex, 3); - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsCompleted; - } - } - - public (int, (bool, T0), (bool, T1), (bool, T2), (bool, T3)) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - var i = parent.winArgumentIndex; - return (i, (i == 0, parent.result0), (i == 1, parent.result1), (i == 2, parent.result2), (i == 3, parent.result3)); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAnyPromise - { - T0 result0; - T1 result1; - T2 result2; - T3 result3; - T4 result4; - ExceptionDispatchInfo exception; - Action whenComplete; - int completeCount; - int winArgumentIndex; - - bool IsCompleted => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask task0, UniTask task1, UniTask task2, UniTask task3, UniTask task4) - { - this.whenComplete = null; - this.exception = null; - this.completeCount = 0; - this.winArgumentIndex = -1; - this.result0 = default(T0); - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.result4 = default(T4); - - RunTask0(task0).Forget(); - RunTask1(task1).Forget(); - RunTask2(task2).Forget(); - RunTask3(task3).Forget(); - RunTask4(task4).Forget(); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask0(UniTask task) - { - T0 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result0 = value; - Volatile.Write(ref winArgumentIndex, 0); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask1(UniTask task) - { - T1 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result1 = value; - Volatile.Write(ref winArgumentIndex, 1); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask2(UniTask task) - { - T2 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result2 = value; - Volatile.Write(ref winArgumentIndex, 2); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask3(UniTask task) - { - T3 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result3 = value; - Volatile.Write(ref winArgumentIndex, 3); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask4(UniTask task) - { - T4 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result4 = value; - Volatile.Write(ref winArgumentIndex, 4); - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsCompleted; - } - } - - public (int, (bool, T0), (bool, T1), (bool, T2), (bool, T3), (bool, T4)) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - var i = parent.winArgumentIndex; - return (i, (i == 0, parent.result0), (i == 1, parent.result1), (i == 2, parent.result2), (i == 3, parent.result3), (i == 4, parent.result4)); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAnyPromise - { - T0 result0; - T1 result1; - T2 result2; - T3 result3; - T4 result4; - T5 result5; - ExceptionDispatchInfo exception; - Action whenComplete; - int completeCount; - int winArgumentIndex; - - bool IsCompleted => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask task0, UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) - { - this.whenComplete = null; - this.exception = null; - this.completeCount = 0; - this.winArgumentIndex = -1; - this.result0 = default(T0); - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.result4 = default(T4); - this.result5 = default(T5); - - RunTask0(task0).Forget(); - RunTask1(task1).Forget(); - RunTask2(task2).Forget(); - RunTask3(task3).Forget(); - RunTask4(task4).Forget(); - RunTask5(task5).Forget(); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask0(UniTask task) - { - T0 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result0 = value; - Volatile.Write(ref winArgumentIndex, 0); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask1(UniTask task) - { - T1 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result1 = value; - Volatile.Write(ref winArgumentIndex, 1); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask2(UniTask task) - { - T2 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result2 = value; - Volatile.Write(ref winArgumentIndex, 2); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask3(UniTask task) - { - T3 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result3 = value; - Volatile.Write(ref winArgumentIndex, 3); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask4(UniTask task) - { - T4 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result4 = value; - Volatile.Write(ref winArgumentIndex, 4); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask5(UniTask task) - { - T5 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result5 = value; - Volatile.Write(ref winArgumentIndex, 5); - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsCompleted; - } - } - - public (int, (bool, T0), (bool, T1), (bool, T2), (bool, T3), (bool, T4), (bool, T5)) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - var i = parent.winArgumentIndex; - return (i, (i == 0, parent.result0), (i == 1, parent.result1), (i == 2, parent.result2), (i == 3, parent.result3), (i == 4, parent.result4), (i == 5, parent.result5)); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAnyPromise - { - T0 result0; - T1 result1; - T2 result2; - T3 result3; - T4 result4; - T5 result5; - T6 result6; - ExceptionDispatchInfo exception; - Action whenComplete; - int completeCount; - int winArgumentIndex; - - bool IsCompleted => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask task0, UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) - { - this.whenComplete = null; - this.exception = null; - this.completeCount = 0; - this.winArgumentIndex = -1; - this.result0 = default(T0); - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.result4 = default(T4); - this.result5 = default(T5); - this.result6 = default(T6); - - RunTask0(task0).Forget(); - RunTask1(task1).Forget(); - RunTask2(task2).Forget(); - RunTask3(task3).Forget(); - RunTask4(task4).Forget(); - RunTask5(task5).Forget(); - RunTask6(task6).Forget(); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask0(UniTask task) - { - T0 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result0 = value; - Volatile.Write(ref winArgumentIndex, 0); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask1(UniTask task) - { - T1 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result1 = value; - Volatile.Write(ref winArgumentIndex, 1); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask2(UniTask task) - { - T2 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result2 = value; - Volatile.Write(ref winArgumentIndex, 2); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask3(UniTask task) - { - T3 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result3 = value; - Volatile.Write(ref winArgumentIndex, 3); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask4(UniTask task) - { - T4 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result4 = value; - Volatile.Write(ref winArgumentIndex, 4); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask5(UniTask task) - { - T5 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result5 = value; - Volatile.Write(ref winArgumentIndex, 5); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask6(UniTask task) - { - T6 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result6 = value; - Volatile.Write(ref winArgumentIndex, 6); - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsCompleted; - } - } - - public (int, (bool, T0), (bool, T1), (bool, T2), (bool, T3), (bool, T4), (bool, T5), (bool, T6)) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - var i = parent.winArgumentIndex; - return (i, (i == 0, parent.result0), (i == 1, parent.result1), (i == 2, parent.result2), (i == 3, parent.result3), (i == 4, parent.result4), (i == 5, parent.result5), (i == 6, parent.result6)); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAnyPromise - { - T0 result0; - T1 result1; - T2 result2; - T3 result3; - T4 result4; - T5 result5; - T6 result6; - T7 result7; - ExceptionDispatchInfo exception; - Action whenComplete; - int completeCount; - int winArgumentIndex; - - bool IsCompleted => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask task0, UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) - { - this.whenComplete = null; - this.exception = null; - this.completeCount = 0; - this.winArgumentIndex = -1; - this.result0 = default(T0); - this.result1 = default(T1); - this.result2 = default(T2); - this.result3 = default(T3); - this.result4 = default(T4); - this.result5 = default(T5); - this.result6 = default(T6); - this.result7 = default(T7); - - RunTask0(task0).Forget(); - RunTask1(task1).Forget(); - RunTask2(task2).Forget(); - RunTask3(task3).Forget(); - RunTask4(task4).Forget(); - RunTask5(task5).Forget(); - RunTask6(task6).Forget(); - RunTask7(task7).Forget(); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask0(UniTask task) - { - T0 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result0 = value; - Volatile.Write(ref winArgumentIndex, 0); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask1(UniTask task) - { - T1 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result1 = value; - Volatile.Write(ref winArgumentIndex, 1); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask2(UniTask task) - { - T2 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result2 = value; - Volatile.Write(ref winArgumentIndex, 2); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask3(UniTask task) - { - T3 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result3 = value; - Volatile.Write(ref winArgumentIndex, 3); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask4(UniTask task) - { - T4 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result4 = value; - Volatile.Write(ref winArgumentIndex, 4); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask5(UniTask task) - { - T5 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result5 = value; - Volatile.Write(ref winArgumentIndex, 5); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask6(UniTask task) - { - T6 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result6 = value; - Volatile.Write(ref winArgumentIndex, 6); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask7(UniTask task) - { - T7 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result7 = value; - Volatile.Write(ref winArgumentIndex, 7); - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsCompleted; - } - } - - public (int, (bool, T0), (bool, T1), (bool, T2), (bool, T3), (bool, T4), (bool, T5), (bool, T6), (bool, T7)) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - var i = parent.winArgumentIndex; - return (i, (i == 0, parent.result0), (i == 1, parent.result1), (i == 2, parent.result2), (i == 3, parent.result3), (i == 4, parent.result4), (i == 5, parent.result5), (i == 6, parent.result6), (i == 7, parent.result7)); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.Generated.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.Generated.cs.meta deleted file mode 100644 index 49a2c3f..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.Generated.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 13d604ac281570c4eac9962429f19ca9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.cs deleted file mode 100644 index 2c5049b..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.cs +++ /dev/null @@ -1,374 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.ExceptionServices; -using System.Threading; - -namespace UniRx.Async -{ - public partial struct UniTask - { - // UniTask - - public static async UniTask<(bool hasResultLeft, T0 result)> WhenAny(UniTask task0, UniTask task1) - { - return await new UnitWhenAnyPromise(task0, task1); - } - - public static async UniTask<(int winArgumentIndex, T result)> WhenAny(params UniTask[] tasks) - { - return await new WhenAnyPromise(tasks); - } - - /// Return value is winArgumentIndex - public static async UniTask WhenAny(params UniTask[] tasks) - { - return await new WhenAnyPromise(tasks); - } - - class UnitWhenAnyPromise - { - T0 result0; - ExceptionDispatchInfo exception; - Action whenComplete; - int completeCount; - int winArgumentIndex; - - bool IsCompleted => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public UnitWhenAnyPromise(UniTask task0, UniTask task1) - { - this.whenComplete = null; - this.exception = null; - this.completeCount = 0; - this.winArgumentIndex = -1; - this.result0 = default(T0); - - RunTask0(task0).Forget(); - RunTask1(task1).Forget(); - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - async UniTaskVoid RunTask0(UniTask task) - { - T0 value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result0 = value; - Volatile.Write(ref winArgumentIndex, 0); - TryCallContinuation(); - } - } - - async UniTaskVoid RunTask1(UniTask task) - { - try - { - await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - Volatile.Write(ref winArgumentIndex, 1); - TryCallContinuation(); - } - } - - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - UnitWhenAnyPromise parent; - - public Awaiter(UnitWhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsCompleted; - } - } - - public (bool, T0) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return (parent.winArgumentIndex == 0, parent.result0); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - - class WhenAnyPromise - { - T result; - int completeCount; - int winArgumentIndex; - Action whenComplete; - ExceptionDispatchInfo exception; - - public bool IsComplete => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask[] tasks) - { - this.completeCount = 0; - this.winArgumentIndex = -1; - this.whenComplete = null; - this.exception = null; - this.result = default(T); - - for (int i = 0; i < tasks.Length; i++) - { - RunTask(tasks[i], i).Forget(); - } - } - - async UniTaskVoid RunTask(UniTask task, int index) - { - T value; - try - { - value = await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - result = value; - Volatile.Write(ref winArgumentIndex, index); - TryCallContinuation(); - } - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsComplete; - } - } - - public (int, T) GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return (parent.winArgumentIndex, parent.result); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - - class WhenAnyPromise - { - int completeCount; - int winArgumentIndex; - Action whenComplete; - ExceptionDispatchInfo exception; - - public bool IsComplete => exception != null || Volatile.Read(ref winArgumentIndex) != -1; - - public WhenAnyPromise(UniTask[] tasks) - { - this.completeCount = 0; - this.winArgumentIndex = -1; - this.whenComplete = null; - this.exception = null; - - for (int i = 0; i < tasks.Length; i++) - { - RunTask(tasks[i], i).Forget(); - } - } - - async UniTaskVoid RunTask(UniTask task, int index) - { - try - { - await task; - } - catch (Exception ex) - { - exception = ExceptionDispatchInfo.Capture(ex); - TryCallContinuation(); - return; - } - - var count = Interlocked.Increment(ref completeCount); - if (count == 1) - { - Volatile.Write(ref winArgumentIndex, index); - TryCallContinuation(); - } - } - - void TryCallContinuation() - { - var action = Interlocked.Exchange(ref whenComplete, null); - if (action != null) - { - action.Invoke(); - } - } - - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - WhenAnyPromise parent; - - public Awaiter(WhenAnyPromise parent) - { - this.parent = parent; - } - - public bool IsCompleted - { - get - { - return parent.IsComplete; - } - } - - public int GetResult() - { - if (parent.exception != null) - { - parent.exception.Throw(); - } - - return parent.winArgumentIndex; - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - parent.whenComplete = continuation; - if (IsCompleted) - { - var action = Interlocked.Exchange(ref parent.whenComplete, null); - if (action != null) - { - action(); - } - } - } - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.cs.meta deleted file mode 100644 index c10f762..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.WhenAny.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c32578978c37eaf41bdd90e1b034637d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTask.cs deleted file mode 100644 index 25c533d..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.cs +++ /dev/null @@ -1,479 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using UniRx.Async.CompilerServices; -using UniRx.Async.Internal; - -namespace UniRx.Async -{ - /// - /// Lightweight unity specified task-like object. - /// - [AsyncMethodBuilder(typeof(AsyncUniTaskMethodBuilder))] - public partial struct UniTask : IEquatable - { - static readonly UniTask DefaultAsyncUnitTask = new UniTask(AsyncUnit.Default); - - readonly IAwaiter awaiter; - - [DebuggerHidden] - public UniTask(IAwaiter awaiter) - { - this.awaiter = awaiter; - } - - [DebuggerHidden] - public UniTask(Func factory) - { - this.awaiter = new LazyPromise(factory); - } - - [DebuggerHidden] - public AwaiterStatus Status - { - get - { - return awaiter == null ? AwaiterStatus.Succeeded : awaiter.Status; - } - } - - [DebuggerHidden] - public bool IsCompleted - { - get - { - return awaiter == null ? true : awaiter.IsCompleted; - } - } - - [DebuggerHidden] - public void GetResult() - { - if (awaiter != null) - { - awaiter.GetResult(); - } - } - - [DebuggerHidden] - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - /// - /// returns (bool IsCanceled) instead of throws OperationCanceledException. - /// - public UniTask SuppressCancellationThrow() - { - var status = Status; - if (status == AwaiterStatus.Succeeded) return CompletedTasks.False; - if (status == AwaiterStatus.Canceled) return CompletedTasks.True; - return new UniTask(new IsCanceledAwaiter(awaiter)); - } - - public bool Equals(UniTask other) - { - if (this.awaiter == null && other.awaiter == null) - { - return true; - } - else if (this.awaiter != null && other.awaiter != null) - { - return this.awaiter == other.awaiter; - } - else - { - return false; - } - } - - public override int GetHashCode() - { - if (this.awaiter == null) - { - return 0; - } - else - { - return this.awaiter.GetHashCode(); - } - } - - public override string ToString() - { - return (this.awaiter == null) ? "()" - : (this.awaiter.Status == AwaiterStatus.Succeeded) ? "()" - : "(" + this.awaiter.Status + ")"; - } - - public static implicit operator UniTask(UniTask task) - { - if (task.awaiter != null) - { - if (task.awaiter.IsCompleted) - { - return DefaultAsyncUnitTask; - } - else - { - // UniTask -> UniTask is free but UniTask -> UniTask requires wrapping cost. - return new UniTask(new AsyncUnitAwaiter(task.awaiter)); - } - } - else - { - return DefaultAsyncUnitTask; - } - } - - class AsyncUnitAwaiter : IAwaiter - { - readonly IAwaiter awaiter; - - public AsyncUnitAwaiter(IAwaiter awaiter) - { - this.awaiter = awaiter; - } - - public bool IsCompleted => awaiter.IsCompleted; - - public AwaiterStatus Status => awaiter.Status; - - public AsyncUnit GetResult() - { - awaiter.GetResult(); - return AsyncUnit.Default; - } - - public void OnCompleted(Action continuation) - { - awaiter.OnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - awaiter.UnsafeOnCompleted(continuation); - } - - void IAwaiter.GetResult() - { - awaiter.GetResult(); - } - } - - class IsCanceledAwaiter : IAwaiter - { - readonly IAwaiter awaiter; - - public IsCanceledAwaiter(IAwaiter awaiter) - { - this.awaiter = awaiter; - } - - public bool IsCompleted => awaiter.IsCompleted; - - public AwaiterStatus Status => awaiter.Status; - - public bool GetResult() - { - if (awaiter.Status == AwaiterStatus.Canceled) - { - return true; - } - awaiter.GetResult(); - return false; - } - - public void OnCompleted(Action continuation) - { - awaiter.OnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - awaiter.UnsafeOnCompleted(continuation); - } - - void IAwaiter.GetResult() - { - awaiter.GetResult(); - } - } - - public struct Awaiter : IAwaiter - { - readonly UniTask task; - - [DebuggerHidden] - public Awaiter(UniTask task) - { - this.task = task; - } - - [DebuggerHidden] - public bool IsCompleted => task.IsCompleted; - - [DebuggerHidden] - public AwaiterStatus Status => task.Status; - - [DebuggerHidden] - public void GetResult() => task.GetResult(); - - [DebuggerHidden] - public void OnCompleted(Action continuation) - { - if (task.awaiter != null) - { - task.awaiter.OnCompleted(continuation); - } - else - { - continuation(); - } - } - - [DebuggerHidden] - public void UnsafeOnCompleted(Action continuation) - { - if (task.awaiter != null) - { - task.awaiter.UnsafeOnCompleted(continuation); - } - else - { - continuation(); - } - } - } - } - - /// - /// Lightweight unity specified task-like object. - /// - [AsyncMethodBuilder(typeof(AsyncUniTaskMethodBuilder<>))] - public struct UniTask : IEquatable> - { - readonly T result; - readonly IAwaiter awaiter; - - [DebuggerHidden] - public UniTask(T result) - { - this.result = result; - this.awaiter = null; - } - - [DebuggerHidden] - public UniTask(IAwaiter awaiter) - { - this.result = default(T); - this.awaiter = awaiter; - } - - [DebuggerHidden] - public UniTask(Func> factory) - { - this.result = default(T); - this.awaiter = new LazyPromise(factory); - } - - [DebuggerHidden] - public AwaiterStatus Status - { - get - { - return awaiter == null ? AwaiterStatus.Succeeded : awaiter.Status; - } - } - - [DebuggerHidden] - public bool IsCompleted - { - get - { - return awaiter == null ? true : awaiter.IsCompleted; - } - } - - [DebuggerHidden] - public T Result - { - get - { - if (awaiter == null) - { - return result; - } - else - { - return awaiter.GetResult(); - } - } - } - - [DebuggerHidden] - public Awaiter GetAwaiter() - { - return new Awaiter(this); - } - - /// - /// returns (bool IsCanceled, T Result) instead of throws OperationCanceledException. - /// - public UniTask<(bool IsCanceled, T Result)> SuppressCancellationThrow() - { - var status = Status; - if (status == AwaiterStatus.Succeeded) - { - return new UniTask<(bool, T)>((false, Result)); - } - else if (status == AwaiterStatus.Canceled) - { - return new UniTask<(bool, T)>((true, default(T))); - } - return new UniTask<(bool, T)>(new IsCanceledAwaiter(awaiter)); - } - - public bool Equals(UniTask other) - { - if (this.awaiter == null && other.awaiter == null) - { - return EqualityComparer.Default.Equals(this.result, other.result); - } - else if (this.awaiter != null && other.awaiter != null) - { - return this.awaiter == other.awaiter; - } - else - { - return false; - } - } - - public override int GetHashCode() - { - if (this.awaiter == null) - { - if (result == null) return 0; - return result.GetHashCode(); - } - else - { - return this.awaiter.GetHashCode(); - } - } - - public override string ToString() - { - return (this.awaiter == null) ? result.ToString() - : (this.awaiter.Status == AwaiterStatus.Succeeded) ? this.awaiter.GetResult().ToString() - : "(" + this.awaiter.Status + ")"; - } - - public static implicit operator UniTask(UniTask task) - { - if (task.awaiter != null) - { - return new UniTask(task.awaiter); - } - else - { - return new UniTask(); - } - } - - class IsCanceledAwaiter : IAwaiter<(bool, T)> - { - readonly IAwaiter awaiter; - - public IsCanceledAwaiter(IAwaiter awaiter) - { - this.awaiter = awaiter; - } - - public bool IsCompleted => awaiter.IsCompleted; - - public AwaiterStatus Status => awaiter.Status; - - public (bool, T) GetResult() - { - if (awaiter.Status == AwaiterStatus.Canceled) - { - return (true, default(T)); - } - return (false, awaiter.GetResult()); - } - - public void OnCompleted(Action continuation) - { - awaiter.OnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - awaiter.UnsafeOnCompleted(continuation); - } - - void IAwaiter.GetResult() - { - awaiter.GetResult(); - } - } - - public struct Awaiter : IAwaiter - { - readonly UniTask task; - - [DebuggerHidden] - public Awaiter(UniTask task) - { - this.task = task; - } - - [DebuggerHidden] - public bool IsCompleted => task.IsCompleted; - - [DebuggerHidden] - public AwaiterStatus Status => task.Status; - - [DebuggerHidden] - void IAwaiter.GetResult() => GetResult(); - - [DebuggerHidden] - public T GetResult() => task.Result; - - [DebuggerHidden] - public void OnCompleted(Action continuation) - { - if (task.awaiter != null) - { - task.awaiter.OnCompleted(continuation); - } - else - { - continuation(); - } - } - - [DebuggerHidden] - public void UnsafeOnCompleted(Action continuation) - { - if (task.awaiter != null) - { - task.awaiter.UnsafeOnCompleted(continuation); - } - else - { - continuation(); - } - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTask.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTask.cs.meta deleted file mode 100644 index 04eb6b6..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTask.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8947adf23181ff04db73829df217ca94 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskCompletionSource.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTaskCompletionSource.cs deleted file mode 100644 index c9a148d..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskCompletionSource.cs +++ /dev/null @@ -1,413 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.ExceptionServices; -using System.Threading; -using UniRx.Async.Internal; - -namespace UniRx.Async -{ - internal class ExceptionHolder - { - ExceptionDispatchInfo exception; - bool calledGet = false; - - public ExceptionHolder(ExceptionDispatchInfo exception) - { - this.exception = exception; - } - - public ExceptionDispatchInfo GetException() - { - if (!calledGet) - { - calledGet = true; - GC.SuppressFinalize(this); - } - return exception; - } - - ~ExceptionHolder() - { - UniTaskScheduler.PublishUnobservedTaskException(exception.SourceException); - } - } - - public interface IResolvePromise - { - bool TrySetResult(); - } - - public interface IResolvePromise - { - bool TrySetResult(T value); - } - - public interface IRejectPromise - { - bool TrySetException(Exception exception); - } - - public interface ICancelPromise - { - bool TrySetCanceled(); - } - - public interface IPromise : IResolvePromise, IRejectPromise, ICancelPromise - { - } - - public interface IPromise : IResolvePromise, IRejectPromise, ICancelPromise - { - } - - public class UniTaskCompletionSource : IAwaiter, IPromise - { - // State(= AwaiterStatus) - const int Pending = 0; - const int Succeeded = 1; - const int Faulted = 2; - const int Canceled = 3; - - int state = 0; - bool handled = false; - ExceptionHolder exception; - object continuation; // action or list - - AwaiterStatus IAwaiter.Status => (AwaiterStatus)state; - - bool IAwaiter.IsCompleted => state != Pending; - - public UniTask Task => new UniTask(this); - - public UniTaskCompletionSource() - { - TaskTracker.TrackActiveTask(this, 2); - } - - [Conditional("UNITY_EDITOR")] - internal void MarkHandled() - { - if (!handled) - { - handled = true; - TaskTracker.RemoveTracking(this); - } - } - - void IAwaiter.GetResult() - { - MarkHandled(); - - if (state == Succeeded) - { - return; - } - else if (state == Faulted) - { - exception.GetException().Throw(); - } - else if (state == Canceled) - { - if (exception != null) - { - exception.GetException().Throw(); // guranteed operation canceled exception. - } - - throw new OperationCanceledException(); - } - else // Pending - { - throw new NotSupportedException("UniTask does not allow call GetResult directly when task not completed. Please use 'await'."); - } - } - - void ICriticalNotifyCompletion.UnsafeOnCompleted(Action action) - { - if (Interlocked.CompareExchange(ref continuation, (object)action, null) == null) - { - if (state != Pending) - { - TryInvokeContinuation(); - } - } - else - { - var c = continuation; - if (c is Action) - { - var list = new List(); - list.Add((Action)c); - list.Add(action); - if (Interlocked.CompareExchange(ref continuation, list, c) == c) - { - goto TRYINVOKE; - } - } - - var l = (List)continuation; - lock (l) - { - l.Add(action); - } - - TRYINVOKE: - if (state != Pending) - { - TryInvokeContinuation(); - } - } - } - - void TryInvokeContinuation() - { - var c = Interlocked.Exchange(ref continuation, null); - if (c != null) - { - if (c is Action) - { - ((Action)c).Invoke(); - } - else - { - var l = (List)c; - var cnt = l.Count; - for (int i = 0; i < cnt; i++) - { - l[i].Invoke(); - } - } - } - } - - public bool TrySetResult() - { - if (Interlocked.CompareExchange(ref state, Succeeded, Pending) == Pending) - { - TryInvokeContinuation(); - return true; - } - return false; - } - - public bool TrySetException(Exception exception) - { - if (Interlocked.CompareExchange(ref state, Faulted, Pending) == Pending) - { - this.exception = new ExceptionHolder(ExceptionDispatchInfo.Capture(exception)); - TryInvokeContinuation(); - return true; - } - return false; - } - - public bool TrySetCanceled() - { - if (Interlocked.CompareExchange(ref state, Canceled, Pending) == Pending) - { - TryInvokeContinuation(); - return true; - } - return false; - } - - public bool TrySetCanceled(OperationCanceledException exception) - { - if (Interlocked.CompareExchange(ref state, Canceled, Pending) == Pending) - { - this.exception = new ExceptionHolder(ExceptionDispatchInfo.Capture(exception)); - TryInvokeContinuation(); - return true; - } - return false; - } - - void INotifyCompletion.OnCompleted(Action continuation) - { - ((ICriticalNotifyCompletion)this).UnsafeOnCompleted(continuation); - } - } - - public class UniTaskCompletionSource : IAwaiter, IPromise - { - // State(= AwaiterStatus) - const int Pending = 0; - const int Succeeded = 1; - const int Faulted = 2; - const int Canceled = 3; - - int state = 0; - T value; - bool handled = false; - ExceptionHolder exception; - object continuation; // action or list - - bool IAwaiter.IsCompleted => state != Pending; - - public UniTask Task => new UniTask(this); - public UniTask UnitTask => new UniTask(this); - - AwaiterStatus IAwaiter.Status => (AwaiterStatus)state; - - public UniTaskCompletionSource() - { - TaskTracker.TrackActiveTask(this, 2); - } - - [Conditional("UNITY_EDITOR")] - internal void MarkHandled() - { - if (!handled) - { - handled = true; - TaskTracker.RemoveTracking(this); - } - } - - T IAwaiter.GetResult() - { - MarkHandled(); - - if (state == Succeeded) - { - return value; - } - else if (state == Faulted) - { - exception.GetException().Throw(); - } - else if (state == Canceled) - { - if (exception != null) - { - exception.GetException().Throw(); // guranteed operation canceled exception. - } - - throw new OperationCanceledException(); - } - else // Pending - { - throw new NotSupportedException("UniTask does not allow call GetResult directly when task not completed. Please use 'await'."); - } - - return default(T); - } - - void ICriticalNotifyCompletion.UnsafeOnCompleted(Action action) - { - if (Interlocked.CompareExchange(ref continuation, (object)action, null) == null) - { - if (state != Pending) - { - TryInvokeContinuation(); - } - } - else - { - var c = continuation; - if (c is Action) - { - var list = new List(); - list.Add((Action)c); - list.Add(action); - if (Interlocked.CompareExchange(ref continuation, list, c) == c) - { - goto TRYINVOKE; - } - } - - var l = (List)continuation; - lock (l) - { - l.Add(action); - } - - TRYINVOKE: - if (state != Pending) - { - TryInvokeContinuation(); - } - } - } - - void TryInvokeContinuation() - { - var c = Interlocked.Exchange(ref continuation, null); - if (c != null) - { - if (c is Action) - { - ((Action)c).Invoke(); - } - else - { - var l = (List)c; - var cnt = l.Count; - for (int i = 0; i < cnt; i++) - { - l[i].Invoke(); - } - } - } - } - - public bool TrySetResult(T value) - { - if (Interlocked.CompareExchange(ref state, Succeeded, Pending) == Pending) - { - this.value = value; - TryInvokeContinuation(); - return true; - } - return false; - } - - public bool TrySetException(Exception exception) - { - if (Interlocked.CompareExchange(ref state, Faulted, Pending) == Pending) - { - this.exception = new ExceptionHolder(ExceptionDispatchInfo.Capture(exception)); - TryInvokeContinuation(); - return true; - } - return false; - } - - public bool TrySetCanceled() - { - if (Interlocked.CompareExchange(ref state, Canceled, Pending) == Pending) - { - TryInvokeContinuation(); - return true; - } - return false; - } - - public bool TrySetCanceled(OperationCanceledException exception) - { - if (Interlocked.CompareExchange(ref state, Canceled, Pending) == Pending) - { - this.exception = new ExceptionHolder(ExceptionDispatchInfo.Capture(exception)); - TryInvokeContinuation(); - return true; - } - return false; - } - - void IAwaiter.GetResult() - { - ((IAwaiter)this).GetResult(); - } - - void INotifyCompletion.OnCompleted(Action continuation) - { - ((ICriticalNotifyCompletion)this).UnsafeOnCompleted(continuation); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskCompletionSource.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTaskCompletionSource.cs.meta deleted file mode 100644 index 2ae5ee3..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskCompletionSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ed03524d09e7eb24a9fb9137198feb84 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.Shorthand.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.Shorthand.cs deleted file mode 100644 index 235bcac..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.Shorthand.cs +++ /dev/null @@ -1,53 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System.Collections.Generic; - -namespace UniRx.Async -{ - public static partial class UniTaskExtensions - { - // shorthand of WhenAll - - public static UniTask.Awaiter GetAwaiter(this IEnumerable tasks) - { - return UniTask.WhenAll(tasks).GetAwaiter(); - } - - public static UniTask.Awaiter GetAwaiter(this IEnumerable> tasks) - { - return UniTask.WhenAll(tasks).GetAwaiter(); - } - - public static UniTask<(T1 result1, T2 result2)>.Awaiter GetAwaiter(this (UniTask task1, UniTask task2) tasks) - { - return UniTask.WhenAll(tasks.task1, tasks.task2).GetAwaiter(); - } - - public static UniTask<(T1 result1, T2 result2, T3 result3)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3) tasks) - { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3); - } - - public static UniTask<(T1 result1, T2 result2, T3 result3, T4 result4)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4) tasks) - { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3, tasks.task4); - } - - public static UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5) tasks) - { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3, tasks.task4, tasks.task5); - } - - public static UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6) tasks) - { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3, tasks.task4, tasks.task5, tasks.task6); - } - - public static UniTask<(T1 result1, T2 result2, T3 result3, T4 result4, T5 result5, T6 result6, T7 result7)> WhenAll(this (UniTask task1, UniTask task2, UniTask task3, UniTask task4, UniTask task5, UniTask task6, UniTask task7) tasks) - { - return UniTask.WhenAll(tasks.task1, tasks.task2, tasks.task3, tasks.task4, tasks.task5, tasks.task6, tasks.task7); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.Shorthand.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.Shorthand.cs.meta deleted file mode 100644 index e2dcc14..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.Shorthand.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4b4ff020f73dc6d4b8ebd4760d61fb43 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.cs deleted file mode 100644 index 0367d29..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.cs +++ /dev/null @@ -1,506 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Collections; -using System.Runtime.ExceptionServices; -using System.Threading; -using System.Threading.Tasks; -using UniRx.Async.Internal; - -namespace UniRx.Async -{ - public static partial class UniTaskExtensions - { - /// - /// Convert UniTask -> UniTask[AsyncUnit]. - /// - public static UniTask AsAsyncUnitUniTask(this UniTask task) - { - // use implicit conversion - return task; - } - - /// - /// Convert Task[T] -> UniTask[T]. - /// - public static UniTask AsUniTask(this Task task, bool useCurrentSynchronizationContext = true) - { - var promise = new UniTaskCompletionSource(); - - task.ContinueWith((x, state) => - { - var p = (UniTaskCompletionSource)state; - - switch (x.Status) - { - case TaskStatus.Canceled: - p.TrySetCanceled(); - break; - case TaskStatus.Faulted: - p.TrySetException(x.Exception); - break; - case TaskStatus.RanToCompletion: - p.TrySetResult(x.Result); - break; - default: - throw new NotSupportedException(); - } - }, promise, useCurrentSynchronizationContext ? TaskScheduler.FromCurrentSynchronizationContext() : TaskScheduler.Current); - - return new UniTask(promise); - } - - /// - /// Convert Task -> UniTask. - /// - public static UniTask AsUniTask(this Task task, bool useCurrentSynchronizationContext = true) - { - var promise = new UniTaskCompletionSource(); - - task.ContinueWith((x, state) => - { - var p = (UniTaskCompletionSource)state; - - switch (x.Status) - { - case TaskStatus.Canceled: - p.TrySetCanceled(); - break; - case TaskStatus.Faulted: - p.TrySetException(x.Exception); - break; - case TaskStatus.RanToCompletion: - p.TrySetResult(default(AsyncUnit)); - break; - default: - throw new NotSupportedException(); - } - }, promise, useCurrentSynchronizationContext ? TaskScheduler.FromCurrentSynchronizationContext() : TaskScheduler.Current); - - return new UniTask(promise); - } - - public static IEnumerator ToCoroutine(this UniTask task, Action resultHandler = null, Action exceptionHandler = null) - { - return new ToCoroutineEnumerator(task, resultHandler, exceptionHandler); - } - - public static IEnumerator ToCoroutine(this UniTask task, Action exceptionHandler = null) - { - return new ToCoroutineEnumerator(task, exceptionHandler); - } - -#if !UniRxLibrary - - public static UniTask Timeout(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) - { - return Timeout(task.AsAsyncUnitUniTask(), timeout, ignoreTimeScale, timeoutCheckTiming, taskCancellationTokenSource); - } - - public static async UniTask Timeout(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) - { - // left, right both suppress operation canceled exception. - - var delayCancellationTokenSource = new CancellationTokenSource(); - var timeoutTask = (UniTask)UniTask.Delay(timeout, ignoreTimeScale, timeoutCheckTiming).SuppressCancellationThrow(); - - var (hasValue, value) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask); - - if (!hasValue) - { - if (taskCancellationTokenSource != null) - { - taskCancellationTokenSource.Cancel(); - taskCancellationTokenSource.Dispose(); - } - - throw new TimeoutException("Exceed Timeout:" + timeout); - } - else - { - delayCancellationTokenSource.Cancel(); - delayCancellationTokenSource.Dispose(); - } - - if (value.IsCanceled) - { - Error.ThrowOperationCanceledException(); - } - - return value.Result; - } - - /// - /// Timeout with suppress OperationCanceledException. Returns (bool, IsCacneled). - /// - public static async UniTask TimeoutWithoutException(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) - { - var v = await TimeoutWithoutException(task.AsAsyncUnitUniTask(), timeout, ignoreTimeScale, timeoutCheckTiming, taskCancellationTokenSource); - return v.IsTimeout; - } - - - /// - /// Timeout with suppress OperationCanceledException. Returns (bool IsTimeout, T Result). - /// - public static async UniTask<(bool IsTimeout, T Result)> TimeoutWithoutException(this UniTask task, TimeSpan timeout, bool ignoreTimeScale = true, PlayerLoopTiming timeoutCheckTiming = PlayerLoopTiming.Update, CancellationTokenSource taskCancellationTokenSource = null) - { - // left, right both suppress operation canceled exception. - - var delayCancellationTokenSource = new CancellationTokenSource(); - var timeoutTask = (UniTask)UniTask.Delay(timeout, ignoreTimeScale, timeoutCheckTiming).SuppressCancellationThrow(); - - var (hasValue, value) = await UniTask.WhenAny(task.SuppressCancellationThrow(), timeoutTask); - - if (!hasValue) - { - if (taskCancellationTokenSource != null) - { - taskCancellationTokenSource.Cancel(); - taskCancellationTokenSource.Dispose(); - } - - return (true, default(T)); - } - else - { - delayCancellationTokenSource.Cancel(); - delayCancellationTokenSource.Dispose(); - } - - if (value.IsCanceled) - { - Error.ThrowOperationCanceledException(); - } - - return (false, value.Result); - } - -#endif - - public static void Forget(this UniTask task) - { - ForgetCore(task).Forget(); - } - - public static void Forget(this UniTask task, Action exceptionHandler, bool handleExceptionOnMainThread = true) - { - if (exceptionHandler == null) - { - ForgetCore(task).Forget(); - } - else - { - ForgetCoreWithCatch(task, exceptionHandler, handleExceptionOnMainThread).Forget(); - } - } - - // UniTask to UniTaskVoid - static async UniTaskVoid ForgetCore(UniTask task) - { - await task; - } - - static async UniTaskVoid ForgetCoreWithCatch(UniTask task, Action exceptionHandler, bool handleExceptionOnMainThread) - { - try - { - await task; - } - catch (Exception ex) - { - try - { -#if !UniRxLibrary - if (handleExceptionOnMainThread) - { - await UniTask.SwitchToMainThread(); - } -#endif - exceptionHandler(ex); - } - catch (Exception ex2) - { - UniTaskScheduler.PublishUnobservedTaskException(ex2); - } - } - } - - public static void Forget(this UniTask task) - { - ForgetCore(task).Forget(); - } - - public static void Forget(this UniTask task, Action exceptionHandler, bool handleExceptionOnMainThread = true) - { - if (exceptionHandler == null) - { - ForgetCore(task).Forget(); - } - else - { - ForgetCoreWithCatch(task, exceptionHandler, handleExceptionOnMainThread).Forget(); - } - } - - // UniTask to UniTaskVoid - static async UniTaskVoid ForgetCore(UniTask task) - { - await task; - } - - static async UniTaskVoid ForgetCoreWithCatch(UniTask task, Action exceptionHandler, bool handleExceptionOnMainThread) - { - try - { - await task; - } - catch (Exception ex) - { - try - { -#if !UniRxLibrary - if (handleExceptionOnMainThread) - { - await UniTask.SwitchToMainThread(); - } -#endif - exceptionHandler(ex); - } - catch (Exception ex2) - { - UniTaskScheduler.PublishUnobservedTaskException(ex2); - } - } - } - - public static async UniTask ContinueWith(this UniTask task, Action continuationFunction) - { - continuationFunction(await task); - } - - public static async UniTask ContinueWith(this UniTask task, Func continuationFunction) - { - await continuationFunction(await task); - } - - public static async UniTask ContinueWith(this UniTask task, Func continuationFunction) - { - return continuationFunction(await task); - } - - public static async UniTask ContinueWith(this UniTask task, Func> continuationFunction) - { - return await continuationFunction(await task); - } - - public static async UniTask ContinueWith(this UniTask task, Action continuationFunction) - { - await task; - continuationFunction(); - } - - public static async UniTask ContinueWith(this UniTask task, Func continuationFunction) - { - await task; - await continuationFunction(); - } - - public static async UniTask ContinueWith(this UniTask task, Func continuationFunction) - { - await task; - return continuationFunction(); - } - - public static async UniTask ContinueWith(this UniTask task, Func> continuationFunction) - { - await task; - return await continuationFunction(); - } - -#if !UniRxLibrary - - public static async UniTask ConfigureAwait(this Task task, PlayerLoopTiming timing) - { - await task.ConfigureAwait(false); - await UniTask.Yield(timing); - } - - public static async UniTask ConfigureAwait(this Task task, PlayerLoopTiming timing) - { - var v = await task.ConfigureAwait(false); - await UniTask.Yield(timing); - return v; - } - - public static async UniTask ConfigureAwait(this UniTask task, PlayerLoopTiming timing) - { - await task; - await UniTask.Yield(timing); - } - - public static async UniTask ConfigureAwait(this UniTask task, PlayerLoopTiming timing) - { - var v = await task; - await UniTask.Yield(timing); - return v; - } - -#endif - - public static async UniTask Unwrap(this UniTask> task) - { - return await await task; - } - - public static async UniTask Unwrap(this UniTask task) - { - await await task; - } - - class ToCoroutineEnumerator : IEnumerator - { - bool completed; - UniTask task; - Action exceptionHandler = null; - bool isStarted = false; - ExceptionDispatchInfo exception; - - public ToCoroutineEnumerator(UniTask task, Action exceptionHandler) - { - completed = false; - this.exceptionHandler = exceptionHandler; - this.task = task; - } - - async UniTaskVoid RunTask(UniTask task) - { - try - { - await task; - } - catch (Exception ex) - { - if (exceptionHandler != null) - { - exceptionHandler(ex); - } - else - { - this.exception = ExceptionDispatchInfo.Capture(ex); - } - } - finally - { - completed = true; - } - } - - public object Current => null; - - public bool MoveNext() - { - if (!isStarted) - { - isStarted = true; - RunTask(task).Forget(); - } - - if (exception != null) - { - // throw exception on iterator (main)thread. - // unfortunately unity test-runner can not handle throw exception on hand-write IEnumerator.MoveNext. -#if !UniRxLibrary - UnityEngine.Debug.LogException(exception.SourceException); -#else - exception.Throw(); -#endif - } - - return !completed; - } - - public void Reset() - { - } - } - - class ToCoroutineEnumerator : IEnumerator - { - bool completed; - Action resultHandler = null; - Action exceptionHandler = null; - bool isStarted = false; - UniTask task; - object current = null; - ExceptionDispatchInfo exception; - - public ToCoroutineEnumerator(UniTask task, Action resultHandler, Action exceptionHandler) - { - completed = false; - this.task = task; - this.resultHandler = resultHandler; - this.exceptionHandler = exceptionHandler; - } - - async UniTaskVoid RunTask(UniTask task) - { - try - { - var value = await task; - current = value; - if (resultHandler != null) - { - resultHandler(value); - } - } - catch (Exception ex) - { - if (exceptionHandler != null) - { - exceptionHandler(ex); - } - else - { - this.exception = ExceptionDispatchInfo.Capture(ex); - } - } - finally - { - completed = true; - } - } - - public object Current => current; - - public bool MoveNext() - { - if (isStarted) - { - isStarted = true; - RunTask(task).Forget(); - } - - if (exception != null) - { - // throw exception on iterator (main)thread. - // unfortunately unity test-runner can not handle throw exception on hand-write IEnumerator.MoveNext. -#if !UniRxLibrary - UnityEngine.Debug.LogException(exception.SourceException); -#else - exception.Throw(); -#endif - } - - return !completed; - } - - public void Reset() - { - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.cs.meta deleted file mode 100644 index 0d22946..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 05460c617dae1e440861a7438535389f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskScheduler.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTaskScheduler.cs deleted file mode 100644 index 9331e24..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskScheduler.cs +++ /dev/null @@ -1,106 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; - -namespace UniRx.Async -{ - // UniTask has no scheduler like TaskScheduler. - // Only handle unobserved exception. - - public static class UniTaskScheduler - { - public static event Action UnobservedTaskException; - - /// - /// Propagate OperationCanceledException to UnobservedTaskException when true. Default is false. - /// - public static bool PropagateOperationCanceledException = false; - -#if !UniRxLibrary - - /// - /// Write log type when catch unobserved exception and not registered UnobservedTaskException. Default is Warning. - /// - public static UnityEngine.LogType UnobservedExceptionWriteLogType = UnityEngine.LogType.Warning; - -#endif - - /// - /// Dispatch exception event to Unity MainThread. - /// - public static bool DispatchUnityMainThread = true; - - // cache delegate. - static readonly SendOrPostCallback handleExceptionInvoke = InvokeUnobservedTaskException; - - internal static void PublishUnobservedTaskException(Exception ex) - { - if (ex != null) - { - if (!PropagateOperationCanceledException && ex is OperationCanceledException) - { - return; - } - - if (UnobservedTaskException != null) - { -#if !UniRxLibrary - if (Thread.CurrentThread.ManagedThreadId == PlayerLoopHelper.MainThreadId) - { - // allows inlining call. - UnobservedTaskException.Invoke(ex); - } - else - { - // Post to MainThread. - PlayerLoopHelper.UnitySynchronizationContext.Post(handleExceptionInvoke, ex); - } -#else - UnobservedTaskException.Invoke(ex); -#endif - } - else - { -#if !UniRxLibrary - string msg = null; - if (UnobservedExceptionWriteLogType != UnityEngine.LogType.Exception) - { - msg = "UnobservedTaskException:" + ex.ToString(); - } - switch (UnobservedExceptionWriteLogType) - { - case UnityEngine.LogType.Error: - UnityEngine.Debug.LogError(msg); - break; - case UnityEngine.LogType.Assert: - UnityEngine.Debug.LogAssertion(msg); - break; - case UnityEngine.LogType.Warning: - UnityEngine.Debug.LogWarning(msg); - break; - case UnityEngine.LogType.Log: - UnityEngine.Debug.Log(msg); - break; - case UnityEngine.LogType.Exception: - UnityEngine.Debug.LogException(ex); - break; - default: - break; - } -#else - Console.WriteLine("UnobservedTaskException:" + ex.ToString()); -#endif - } - } - } - - static void InvokeUnobservedTaskException(object state) - { - UnobservedTaskException((Exception)state); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskScheduler.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTaskScheduler.cs.meta deleted file mode 100644 index 5e29191..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskScheduler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d6cad69921702d5488d96b5ef30df1b0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskVoid.cs b/Assets/Plugins/UniRx/Scripts/Async/UniTaskVoid.cs deleted file mode 100644 index f74de6c..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskVoid.cs +++ /dev/null @@ -1,52 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 - -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using UniRx.Async.CompilerServices; - -namespace UniRx.Async -{ - [AsyncMethodBuilder(typeof(AsyncUniTaskVoidMethodBuilder))] - public struct UniTaskVoid - { - public void Forget() - { - } - - [DebuggerHidden] - public Awaiter GetAwaiter() - { - return new Awaiter(); - } - - public struct Awaiter : ICriticalNotifyCompletion - { - [DebuggerHidden] - public bool IsCompleted => true; - - [DebuggerHidden] - public void GetResult() - { -#if !UniRxLibrary - UnityEngine.Debug.LogWarning("UniTaskVoid can't await, always fire-and-forget. use Forget instead of await."); -#else - Console.WriteLine("UniTask can't await, always fire-and-forget. use Forget instead of await."); -#endif - } - - [DebuggerHidden] - public void OnCompleted(Action continuation) - { - } - - [DebuggerHidden] - public void UnsafeOnCompleted(Action continuation) - { - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UniTaskVoid.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UniTaskVoid.cs.meta deleted file mode 100644 index 01f7156..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UniTaskVoid.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e9f28cd922179634d863011548f89ae7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.Jobs.cs b/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.Jobs.cs deleted file mode 100644 index 01185e3..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.Jobs.cs +++ /dev/null @@ -1,140 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) && ENABLE_MANAGED_JOBS -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; -using UniRx.Async.Internal; -using Unity.Jobs; - -namespace UniRx.Async -{ - public static partial class UnityAsyncExtensions - { - public static IAwaiter GetAwaiter(this JobHandle jobHandle) - { - var awaiter = new JobHandleAwaiter(jobHandle, CancellationToken.None); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.EarlyUpdate, awaiter); - PlayerLoopHelper.AddAction(PlayerLoopTiming.PreUpdate, awaiter); - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, awaiter); - PlayerLoopHelper.AddAction(PlayerLoopTiming.PreLateUpdate, awaiter); - PlayerLoopHelper.AddAction(PlayerLoopTiming.PostLateUpdate, awaiter); - } - return awaiter; - } - - public static UniTask ToUniTask(this JobHandle jobHandle, CancellationToken cancellation = default(CancellationToken)) - { - var awaiter = new JobHandleAwaiter(jobHandle, cancellation); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.EarlyUpdate, awaiter); - PlayerLoopHelper.AddAction(PlayerLoopTiming.PreUpdate, awaiter); - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, awaiter); - PlayerLoopHelper.AddAction(PlayerLoopTiming.PreLateUpdate, awaiter); - PlayerLoopHelper.AddAction(PlayerLoopTiming.PostLateUpdate, awaiter); - } - return new UniTask(awaiter); - } - - public static UniTask ConfigureAwait(this JobHandle jobHandle, PlayerLoopTiming waitTiming, CancellationToken cancellation = default(CancellationToken)) - { - var awaiter = new JobHandleAwaiter(jobHandle, cancellation); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(waitTiming, awaiter); - } - return new UniTask(awaiter); - } - - class JobHandleAwaiter : IAwaiter, IPlayerLoopItem - { - JobHandle jobHandle; - CancellationToken cancellationToken; - AwaiterStatus status; - Action continuation; - - public JobHandleAwaiter(JobHandle jobHandle, CancellationToken cancellationToken, int skipFrame = 2) - { - this.status = cancellationToken.IsCancellationRequested ? AwaiterStatus.Canceled - : jobHandle.IsCompleted ? AwaiterStatus.Succeeded - : AwaiterStatus.Pending; - - if (this.status.IsCompleted()) return; - - this.jobHandle = jobHandle; - this.cancellationToken = cancellationToken; - this.status = AwaiterStatus.Pending; - this.continuation = null; - - TaskTracker.TrackActiveTask(this, skipFrame); - } - - public bool IsCompleted => status.IsCompleted(); - - public AwaiterStatus Status => status; - - public void GetResult() - { - if (status == AwaiterStatus.Succeeded) - { - return; - } - else if (status == AwaiterStatus.Canceled) - { - Error.ThrowOperationCanceledException(); - } - - Error.ThrowNotYetCompleted(); - } - - public bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - // Call jobHandle.Complete after finished. - PlayerLoopHelper.AddAction(PlayerLoopTiming.EarlyUpdate, new JobHandleAwaiter(jobHandle, CancellationToken.None, 1)); - InvokeContinuation(AwaiterStatus.Canceled); - return false; - } - - if (jobHandle.IsCompleted) - { - jobHandle.Complete(); - InvokeContinuation(AwaiterStatus.Succeeded); - return false; - } - - return true; - } - - void InvokeContinuation(AwaiterStatus status) - { - this.status = status; - var cont = this.continuation; - - // cleanup - TaskTracker.RemoveTracking(this); - this.continuation = null; - this.cancellationToken = CancellationToken.None; - this.jobHandle = default(JobHandle); - - if (cont != null) cont.Invoke(); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = continuation; - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.Jobs.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.Jobs.cs.meta deleted file mode 100644 index c07df0b..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.Jobs.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 30979a768fbd4b94f8694eee8a305c99 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.cs b/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.cs deleted file mode 100644 index 0005ca7..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.cs +++ /dev/null @@ -1,702 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; -using UniRx.Async.Internal; -using UnityEngine; -using UnityEngine.Networking; - -namespace UniRx.Async -{ - public static partial class UnityAsyncExtensions - { - public static AsyncOperationAwaiter GetAwaiter(this AsyncOperation asyncOperation) - { - Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation)); - return new AsyncOperationAwaiter(asyncOperation); - } - - public static UniTask ToUniTask(this AsyncOperation asyncOperation) - { - Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation)); - return new UniTask(new AsyncOperationAwaiter(asyncOperation)); - } - - public static UniTask ConfigureAwait(this AsyncOperation asyncOperation, IProgress progress = null, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellation = default(CancellationToken)) - { - Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation)); - - var awaiter = new AsyncOperationConfiguredAwaiter(asyncOperation, progress, cancellation); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(timing, awaiter); - } - return new UniTask(awaiter); - } - - public static ResourceRequestAwaiter GetAwaiter(this ResourceRequest resourceRequest) - { - Error.ThrowArgumentNullException(resourceRequest, nameof(resourceRequest)); - return new ResourceRequestAwaiter(resourceRequest); - } - - public static UniTask ToUniTask(this ResourceRequest resourceRequest) - { - Error.ThrowArgumentNullException(resourceRequest, nameof(resourceRequest)); - return new UniTask(new ResourceRequestAwaiter(resourceRequest)); - } - - public static UniTask ConfigureAwait(this ResourceRequest resourceRequest, IProgress progress = null, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellation = default(CancellationToken)) - { - Error.ThrowArgumentNullException(resourceRequest, nameof(resourceRequest)); - - var awaiter = new ResourceRequestConfiguredAwaiter(resourceRequest, progress, cancellation); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(timing, awaiter); - } - return new UniTask(awaiter); - } - -#if ENABLE_WWW - -#if UNITY_2018_3_OR_NEWER -#pragma warning disable CS0618 -#endif - - public static IAwaiter GetAwaiter(this WWW www) - { - Error.ThrowArgumentNullException(www, nameof(www)); - - var awaiter = new WWWConfiguredAwaiter(www, null, CancellationToken.None); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, awaiter); - } - return awaiter; - } - - public static UniTask ToUniTask(this WWW www) - { - Error.ThrowArgumentNullException(www, nameof(www)); - - var awaiter = new WWWConfiguredAwaiter(www, null, CancellationToken.None); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, awaiter); - } - return new UniTask(awaiter); - } - - public static UniTask ConfigureAwait(this WWW www, IProgress progress = null, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellation = default(CancellationToken)) - { - Error.ThrowArgumentNullException(www, nameof(www)); - - var awaiter = new WWWConfiguredAwaiter(www, progress, cancellation); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(timing, awaiter); - } - return new UniTask(awaiter); - } - -#if UNITY_2018_3_OR_NEWER -#pragma warning restore CS0618 -#endif - -#endif - -#if ENABLE_UNITYWEBREQUEST - - public static UnityWebRequestAsyncOperationAwaiter GetAwaiter(this UnityWebRequestAsyncOperation asyncOperation) - { - Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation)); - return new UnityWebRequestAsyncOperationAwaiter(asyncOperation); - } - - public static UniTask ToUniTask(this UnityWebRequestAsyncOperation asyncOperation) - { - Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation)); - return new UniTask(new UnityWebRequestAsyncOperationAwaiter(asyncOperation)); - } - - public static UniTask ConfigureAwait(this UnityWebRequestAsyncOperation asyncOperation, IProgress progress = null, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellation = default(CancellationToken)) - { - Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation)); - - var awaiter = new UnityWebRequestAsyncOperationConfiguredAwaiter(asyncOperation, progress, cancellation); - if (!awaiter.IsCompleted) - { - PlayerLoopHelper.AddAction(timing, awaiter); - } - return new UniTask(awaiter); - } - -#endif - - public struct AsyncOperationAwaiter : IAwaiter - { - AsyncOperation asyncOperation; - Action continuationAction; - AwaiterStatus status; - - public AsyncOperationAwaiter(AsyncOperation asyncOperation) - { - this.status = asyncOperation.isDone ? AwaiterStatus.Succeeded : AwaiterStatus.Pending; - this.asyncOperation = (this.status.IsCompleted()) ? null : asyncOperation; - this.continuationAction = null; - } - - public bool IsCompleted => status.IsCompleted(); - public AwaiterStatus Status => status; - - public void GetResult() - { - if (status == AwaiterStatus.Succeeded) return; - - if (status == AwaiterStatus.Pending) - { - // first timing of call - if (asyncOperation.isDone) - { - status = AwaiterStatus.Succeeded; - } - else - { - Error.ThrowNotYetCompleted(); - } - } - - asyncOperation = null; // remove reference. - - if (continuationAction != null) - { - asyncOperation.completed -= continuationAction; - continuationAction = null; - } - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(continuationAction); - continuationAction = continuation.AsFuncOfT(); - asyncOperation.completed += continuationAction; - } - } - - class AsyncOperationConfiguredAwaiter : IAwaiter, IPlayerLoopItem - { - AsyncOperation asyncOperation; - IProgress progress; - CancellationToken cancellationToken; - AwaiterStatus status; - Action continuation; - - public AsyncOperationConfiguredAwaiter(AsyncOperation asyncOperation, IProgress progress, CancellationToken cancellationToken) - { - this.status = cancellationToken.IsCancellationRequested ? AwaiterStatus.Canceled - : asyncOperation.isDone ? AwaiterStatus.Succeeded - : AwaiterStatus.Pending; - - if (this.status.IsCompleted()) return; - - this.asyncOperation = asyncOperation; - this.progress = progress; - this.cancellationToken = cancellationToken; - this.continuation = null; - - TaskTracker.TrackActiveTask(this, 2); - } - - public bool IsCompleted => status.IsCompleted(); - public AwaiterStatus Status => status; - - public void GetResult() - { - if (status == AwaiterStatus.Succeeded) - { - return; - } - else if (status == AwaiterStatus.Canceled) - { - Error.ThrowOperationCanceledException(); - } - - Error.ThrowNotYetCompleted(); - } - - public bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - InvokeContinuation(AwaiterStatus.Canceled); - return false; - } - - if (progress != null) - { - progress.Report(asyncOperation.progress); - } - - if (asyncOperation.isDone) - { - InvokeContinuation(AwaiterStatus.Succeeded); - return false; - } - - return true; - } - - void InvokeContinuation(AwaiterStatus status) - { - this.status = status; - var cont = this.continuation; - - // cleanup - TaskTracker.RemoveTracking(this); - this.continuation = null; - this.cancellationToken = CancellationToken.None; - this.progress = null; - this.asyncOperation = null; - - if (cont != null) cont.Invoke(); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = continuation; - } - } - - public struct ResourceRequestAwaiter : IAwaiter - { - ResourceRequest asyncOperation; - Action continuationAction; - AwaiterStatus status; - UnityEngine.Object result; - - public ResourceRequestAwaiter(ResourceRequest asyncOperation) - { - this.status = asyncOperation.isDone ? AwaiterStatus.Succeeded : AwaiterStatus.Pending; - this.asyncOperation = (this.status.IsCompleted()) ? null : asyncOperation; - this.result = (this.status.IsCompletedSuccessfully()) ? asyncOperation.asset : null; - this.continuationAction = null; - } - - public bool IsCompleted => status.IsCompleted(); - public AwaiterStatus Status => status; - - public UnityEngine.Object GetResult() - { - if (status == AwaiterStatus.Succeeded) return this.result; - - if (status == AwaiterStatus.Pending) - { - // first timing of call - if (asyncOperation.isDone) - { - status = AwaiterStatus.Succeeded; - } - else - { - Error.ThrowNotYetCompleted(); - } - } - - this.result = asyncOperation.asset; - asyncOperation = null; // remove reference. - - if (continuationAction != null) - { - asyncOperation.completed -= continuationAction; - continuationAction = null; - } - - return this.result; - } - - void IAwaiter.GetResult() => GetResult(); - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(continuationAction); - continuationAction = continuation.AsFuncOfT(); - asyncOperation.completed += continuationAction; - } - } - - class ResourceRequestConfiguredAwaiter : IAwaiter, IPlayerLoopItem - { - ResourceRequest asyncOperation; - IProgress progress; - CancellationToken cancellationToken; - AwaiterStatus status; - Action continuation; - UnityEngine.Object result; - - public ResourceRequestConfiguredAwaiter(ResourceRequest asyncOperation, IProgress progress, CancellationToken cancellationToken) - { - this.status = cancellationToken.IsCancellationRequested ? AwaiterStatus.Canceled - : asyncOperation.isDone ? AwaiterStatus.Succeeded - : AwaiterStatus.Pending; - - if (this.status.IsCompletedSuccessfully()) this.result = asyncOperation.asset; - if (this.status.IsCompleted()) return; - - this.asyncOperation = asyncOperation; - this.progress = progress; - this.cancellationToken = cancellationToken; - this.continuation = null; - this.result = null; - - TaskTracker.TrackActiveTask(this, 2); - } - - public bool IsCompleted => status.IsCompleted(); - public AwaiterStatus Status => status; - void IAwaiter.GetResult() => GetResult(); - - public UnityEngine.Object GetResult() - { - if (status == AwaiterStatus.Succeeded) return this.result; - - if (status == AwaiterStatus.Canceled) - { - Error.ThrowOperationCanceledException(); - } - - return Error.ThrowNotYetCompleted(); - } - - public bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - InvokeContinuation(AwaiterStatus.Canceled); - return false; - } - - if (progress != null) - { - progress.Report(asyncOperation.progress); - } - - if (asyncOperation.isDone) - { - this.result = asyncOperation.asset; - InvokeContinuation(AwaiterStatus.Succeeded); - return false; - } - - return true; - } - - void InvokeContinuation(AwaiterStatus status) - { - this.status = status; - var cont = this.continuation; - - // cleanup - TaskTracker.RemoveTracking(this); - this.continuation = null; - this.cancellationToken = CancellationToken.None; - this.progress = null; - this.asyncOperation = null; - - if (cont != null) cont.Invoke(); - } - - public void OnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = continuation; - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = continuation; - } - } - -#if ENABLE_WWW - -#if UNITY_2018_3_OR_NEWER -#pragma warning disable CS0618 -#endif - - class WWWConfiguredAwaiter : IAwaiter, IPlayerLoopItem - { - WWW asyncOperation; - IProgress progress; - CancellationToken cancellationToken; - AwaiterStatus status; - Action continuation; - - public WWWConfiguredAwaiter(WWW asyncOperation, IProgress progress, CancellationToken cancellationToken) - { - this.status = cancellationToken.IsCancellationRequested ? AwaiterStatus.Canceled - : asyncOperation.isDone ? AwaiterStatus.Succeeded - : AwaiterStatus.Pending; - - if (this.status.IsCompleted()) return; - - this.asyncOperation = asyncOperation; - this.progress = progress; - this.cancellationToken = cancellationToken; - this.continuation = null; - - TaskTracker.TrackActiveTask(this, 2); - } - - public bool IsCompleted => status.IsCompleted(); - public AwaiterStatus Status => status; - - public void GetResult() - { - if (status == AwaiterStatus.Succeeded) - { - return; - } - else if (status == AwaiterStatus.Canceled) - { - Error.ThrowOperationCanceledException(); - } - - Error.ThrowNotYetCompleted(); - } - - public bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - InvokeContinuation(AwaiterStatus.Canceled); - return false; - } - - if (progress != null) - { - progress.Report(asyncOperation.progress); - } - - if (asyncOperation.isDone) - { - InvokeContinuation(AwaiterStatus.Succeeded); - return false; - } - - return true; - } - - void InvokeContinuation(AwaiterStatus status) - { - this.status = status; - var cont = this.continuation; - - // cleanup - TaskTracker.RemoveTracking(this); - this.continuation = null; - this.cancellationToken = CancellationToken.None; - this.progress = null; - this.asyncOperation = null; - - if (cont != null) cont.Invoke(); - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = continuation; - } - } - -#if UNITY_2018_3_OR_NEWER -#pragma warning restore CS0618 -#endif - -#endif - -#if ENABLE_UNITYWEBREQUEST - - public struct UnityWebRequestAsyncOperationAwaiter : IAwaiter - { - UnityWebRequestAsyncOperation asyncOperation; - Action continuationAction; - AwaiterStatus status; - UnityWebRequest result; - - public UnityWebRequestAsyncOperationAwaiter(UnityWebRequestAsyncOperation asyncOperation) - { - this.status = asyncOperation.isDone ? AwaiterStatus.Succeeded : AwaiterStatus.Pending; - this.asyncOperation = (this.status.IsCompleted()) ? null : asyncOperation; - this.result = (this.status.IsCompletedSuccessfully()) ? asyncOperation.webRequest : null; - this.continuationAction = null; - } - - public bool IsCompleted => status.IsCompleted(); - public AwaiterStatus Status => status; - - public UnityWebRequest GetResult() - { - if (status == AwaiterStatus.Succeeded) return this.result; - - if (status == AwaiterStatus.Pending) - { - // first timing of call - if (asyncOperation.isDone) - { - status = AwaiterStatus.Succeeded; - } - else - { - Error.ThrowNotYetCompleted(); - } - } - - this.result = asyncOperation.webRequest; - asyncOperation = null; // remove reference. - - if (continuationAction != null) - { - asyncOperation.completed -= continuationAction; - continuationAction = null; - } - - return this.result; - } - - void IAwaiter.GetResult() => GetResult(); - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(continuationAction); - continuationAction = continuation.AsFuncOfT(); - asyncOperation.completed += continuationAction; - } - } - - class UnityWebRequestAsyncOperationConfiguredAwaiter : IAwaiter, IPlayerLoopItem - { - UnityWebRequestAsyncOperation asyncOperation; - IProgress progress; - CancellationToken cancellationToken; - AwaiterStatus status; - Action continuation; - UnityWebRequest result; - - public UnityWebRequestAsyncOperationConfiguredAwaiter(UnityWebRequestAsyncOperation asyncOperation, IProgress progress, CancellationToken cancellationToken) - { - this.status = cancellationToken.IsCancellationRequested ? AwaiterStatus.Canceled - : asyncOperation.isDone ? AwaiterStatus.Succeeded - : AwaiterStatus.Pending; - - if (this.status.IsCompletedSuccessfully()) this.result = asyncOperation.webRequest; - if (this.status.IsCompleted()) return; - - this.asyncOperation = asyncOperation; - this.progress = progress; - this.cancellationToken = cancellationToken; - this.continuation = null; - this.result = null; - - TaskTracker.TrackActiveTask(this, 2); - } - - public bool IsCompleted => status.IsCompleted(); - public AwaiterStatus Status => status; - void IAwaiter.GetResult() => GetResult(); - - public UnityWebRequest GetResult() - { - if (status == AwaiterStatus.Succeeded) return this.result; - - if (status == AwaiterStatus.Canceled) - { - Error.ThrowOperationCanceledException(); - } - - return Error.ThrowNotYetCompleted(); - } - - public bool MoveNext() - { - if (cancellationToken.IsCancellationRequested) - { - InvokeContinuation(AwaiterStatus.Canceled); - return false; - } - - if (progress != null) - { - progress.Report(asyncOperation.progress); - } - - if (asyncOperation.isDone) - { - this.result = asyncOperation.webRequest; - InvokeContinuation(AwaiterStatus.Succeeded); - return false; - } - - return true; - } - - void InvokeContinuation(AwaiterStatus status) - { - this.status = status; - var cont = this.continuation; - - // cleanup - TaskTracker.RemoveTracking(this); - this.continuation = null; - this.cancellationToken = CancellationToken.None; - this.progress = null; - this.asyncOperation = null; - - if (cont != null) cont.Invoke(); - } - - public void OnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = continuation; - } - - public void UnsafeOnCompleted(Action continuation) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = continuation; - } - } - -#endif - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.cs.meta deleted file mode 100644 index 6dfab81..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8cc7fd65dd1433e419be4764aeb51391 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.uGUI.cs b/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.uGUI.cs deleted file mode 100644 index b0effcb..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.uGUI.cs +++ /dev/null @@ -1,434 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Runtime.CompilerServices; -using System.Threading; -using UniRx.Async.Internal; -using UnityEngine; -using UnityEngine.Events; -using UnityEngine.UI; -using UniRx.Async.Triggers; - -namespace UniRx.Async -{ - public static partial class UnityAsyncExtensions - { - public static AsyncUnityEventHandler GetAsyncEventHandler(this UnityEvent unityEvent, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(unityEvent, cancellationToken, false); - } - - public static UniTask OnInvokeAsync(this UnityEvent unityEvent, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(unityEvent, cancellationToken, true).OnInvokeAsync(); - } - - public static IAsyncClickEventHandler GetAsyncClickEventHandler(this Button button) - { - return new AsyncUnityEventHandler(button.onClick, button.GetCancellationTokenOnDestroy(), false); - } - - public static IAsyncClickEventHandler GetAsyncClickEventHandler(this Button button, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(button.onClick, cancellationToken, false); - } - - public static UniTask OnClickAsync(this Button button) - { - return new AsyncUnityEventHandler(button.onClick, button.GetCancellationTokenOnDestroy(), true).OnInvokeAsync(); - } - - public static UniTask OnClickAsync(this Button button, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(button.onClick, cancellationToken, true).OnInvokeAsync(); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this Toggle toggle) - { - return new AsyncUnityEventHandler(toggle.onValueChanged, toggle.GetCancellationTokenOnDestroy(), false); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this Toggle toggle, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(toggle.onValueChanged, cancellationToken, false); - } - - public static UniTask OnValueChangedAsync(this Toggle toggle) - { - return new AsyncUnityEventHandler(toggle.onValueChanged, toggle.GetCancellationTokenOnDestroy(), true).OnInvokeAsync(); - } - - public static UniTask OnValueChangedAsync(this Toggle toggle, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(toggle.onValueChanged, cancellationToken, true).OnInvokeAsync(); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this Scrollbar scrollbar) - { - return new AsyncUnityEventHandler(scrollbar.onValueChanged, scrollbar.GetCancellationTokenOnDestroy(), false); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this Scrollbar scrollbar, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(scrollbar.onValueChanged, cancellationToken, false); - } - - public static UniTask OnValueChangedAsync(this Scrollbar scrollbar) - { - return new AsyncUnityEventHandler(scrollbar.onValueChanged, scrollbar.GetCancellationTokenOnDestroy(), true).OnInvokeAsync(); - } - - public static UniTask OnValueChangedAsync(this Scrollbar scrollbar, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(scrollbar.onValueChanged, cancellationToken, true).OnInvokeAsync(); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this ScrollRect scrollRect) - { - return new AsyncUnityEventHandler(scrollRect.onValueChanged, scrollRect.GetCancellationTokenOnDestroy(), false); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this ScrollRect scrollRect, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(scrollRect.onValueChanged, cancellationToken, false); - } - - public static UniTask OnValueChangedAsync(this ScrollRect scrollRect) - { - return new AsyncUnityEventHandler(scrollRect.onValueChanged, scrollRect.GetCancellationTokenOnDestroy(), true).OnInvokeAsync(); - } - - public static UniTask OnValueChangedAsync(this ScrollRect scrollRect, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(scrollRect.onValueChanged, cancellationToken, true).OnInvokeAsync(); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this Slider slider) - { - return new AsyncUnityEventHandler(slider.onValueChanged, slider.GetCancellationTokenOnDestroy(), false); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this Slider slider, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(slider.onValueChanged, cancellationToken, false); - } - - public static UniTask OnValueChangedAsync(this Slider slider) - { - return new AsyncUnityEventHandler(slider.onValueChanged, slider.GetCancellationTokenOnDestroy(), true).OnInvokeAsync(); - } - - public static UniTask OnValueChangedAsync(this Slider slider, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(slider.onValueChanged, cancellationToken, true).OnInvokeAsync(); - } - - public static IAsyncEndEditEventHandler GetAsyncEndEditEventHandler(this InputField inputField) - { - return new AsyncUnityEventHandler(inputField.onEndEdit, inputField.GetCancellationTokenOnDestroy(), false); - } - - public static IAsyncEndEditEventHandler GetAsyncEndEditEventHandler(this InputField inputField, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(inputField.onEndEdit, cancellationToken, false); - } - - public static UniTask OnEndEditAsync(this InputField inputField) - { - return new AsyncUnityEventHandler(inputField.onEndEdit, inputField.GetCancellationTokenOnDestroy(), true).OnInvokeAsync(); - } - - public static UniTask OnEndEditAsync(this InputField inputField, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(inputField.onEndEdit, cancellationToken, true).OnInvokeAsync(); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this Dropdown dropdown) - { - return new AsyncUnityEventHandler(dropdown.onValueChanged, dropdown.GetCancellationTokenOnDestroy(), false); - } - - public static IAsyncValueChangedEventHandler GetAsyncValueChangedEventHandler(this Dropdown dropdown, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(dropdown.onValueChanged, cancellationToken, false); - } - - public static UniTask OnValueChanged(this Dropdown dropdown) - { - return new AsyncUnityEventHandler(dropdown.onValueChanged, dropdown.GetCancellationTokenOnDestroy(), true).OnInvokeAsync(); - } - - public static UniTask OnValueChanged(this Dropdown dropdown, CancellationToken cancellationToken) - { - return new AsyncUnityEventHandler(dropdown.onValueChanged, cancellationToken, true).OnInvokeAsync(); - } - } - - public interface IAsyncClickEventHandler : IDisposable - { - UniTask OnClickAsync(); - UniTask OnClickAsyncSuppressCancellationThrow(); - } - - public interface IAsyncValueChangedEventHandler : IDisposable - { - UniTask OnValueChangedAsync(); - UniTask<(bool IsCanceled, T Result)> OnValueChangedAsyncSuppressCancellationThrow(); - } - - public interface IAsyncEndEditEventHandler : IDisposable - { - UniTask OnEndEditAsync(); - UniTask<(bool IsCanceled, T Result)> OnEndEditAsyncSuppressCancellationThrow(); - } - - // event handler is reusable when callOnce = false. - public class AsyncUnityEventHandler : IAwaiter, IDisposable, IAsyncClickEventHandler - { - static Action cancellationCallback = CancellationCallback; - - readonly UnityAction action; - readonly UnityEvent unityEvent; - Action continuation; - CancellationTokenRegistration registration; - bool isDisposed; - bool callOnce; - UniTask? suppressCancellationThrowTask; - - public AsyncUnityEventHandler(UnityEvent unityEvent, CancellationToken cancellationToken, bool callOnce) - { - this.callOnce = callOnce; - - if (cancellationToken.IsCancellationRequested) - { - isDisposed = true; - return; - } - - action = Invoke; - unityEvent.AddListener(action); - this.unityEvent = unityEvent; - - if (cancellationToken.CanBeCanceled) - { - registration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, this); - } - - TaskTracker.TrackActiveTask(this, 3); - } - - public UniTask OnInvokeAsync() - { - // zero allocation wait handler. - return new UniTask(this); - } - - public UniTask OnInvokeAsyncSuppressCancellationThrow() - { - if (suppressCancellationThrowTask == null) - { - suppressCancellationThrowTask = OnInvokeAsync().SuppressCancellationThrow(); - } - return suppressCancellationThrowTask.Value; - } - - void Invoke() - { - var c = continuation; - continuation = null; - if (c != null) - { - c.Invoke(); - } - } - - static void CancellationCallback(object state) - { - var self = (AsyncUnityEventHandler)state; - self.Dispose(); - self.Invoke(); // call continuation if exists yet(GetResult -> throw OperationCanceledException). - } - - public void Dispose() - { - if (!isDisposed) - { - isDisposed = true; - TaskTracker.RemoveTracking(this); - registration.Dispose(); - if (unityEvent != null) - { - unityEvent.RemoveListener(action); - } - } - } - - bool IAwaiter.IsCompleted => isDisposed ? true : false; - AwaiterStatus IAwaiter.Status => isDisposed ? AwaiterStatus.Canceled : AwaiterStatus.Pending; - void IAwaiter.GetResult() - { - if (isDisposed) throw new OperationCanceledException(); - if (callOnce) Dispose(); - } - - void INotifyCompletion.OnCompleted(Action action) - { - ((ICriticalNotifyCompletion)this).UnsafeOnCompleted(action); - } - - void ICriticalNotifyCompletion.UnsafeOnCompleted(Action action) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = action; - } - - // Interface events. - - UniTask IAsyncClickEventHandler.OnClickAsync() - { - return OnInvokeAsync(); - } - - UniTask IAsyncClickEventHandler.OnClickAsyncSuppressCancellationThrow() - { - return OnInvokeAsyncSuppressCancellationThrow(); - } - } - - // event handler is reusable when callOnce = false. - public class AsyncUnityEventHandler : IAwaiter, IDisposable, IAsyncValueChangedEventHandler, IAsyncEndEditEventHandler - { - static Action cancellationCallback = CancellationCallback; - - readonly UnityAction action; - readonly UnityEvent unityEvent; - Action continuation; - CancellationTokenRegistration registration; - bool isDisposed; - T eventValue; - bool callOnce; - UniTask<(bool, T)>? suppressCancellationThrowTask; - - public AsyncUnityEventHandler(UnityEvent unityEvent, CancellationToken cancellationToken, bool callOnce) - { - this.callOnce = callOnce; - - if (cancellationToken.IsCancellationRequested) - { - isDisposed = true; - return; - } - - action = Invoke; - unityEvent.AddListener(action); - this.unityEvent = unityEvent; - - if (cancellationToken.CanBeCanceled) - { - registration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, this); - } - - TaskTracker.TrackActiveTask(this, 3); - } - - public UniTask OnInvokeAsync() - { - // zero allocation wait handler. - return new UniTask(this); - } - - public UniTask<(bool IsCanceled, T Result)> OnInvokeAsyncSuppressCancellationThrow() - { - if (suppressCancellationThrowTask == null) - { - suppressCancellationThrowTask = OnInvokeAsync().SuppressCancellationThrow(); - } - return suppressCancellationThrowTask.Value; - } - - void Invoke(T value) - { - this.eventValue = value; - - var c = continuation; - continuation = null; - if (c != null) - { - c.Invoke(); - } - } - - static void CancellationCallback(object state) - { - var self = (AsyncUnityEventHandler)state; - self.Dispose(); - self.Invoke(default(T)); // call continuation if exists yet(GetResult -> throw OperationCanceledException). - } - - public void Dispose() - { - if (!isDisposed) - { - isDisposed = true; - TaskTracker.RemoveTracking(this); - registration.Dispose(); - if (unityEvent != null) - { - unityEvent.RemoveListener(action); - } - } - } - - bool IAwaiter.IsCompleted => isDisposed ? true : false; - AwaiterStatus IAwaiter.Status => isDisposed ? AwaiterStatus.Canceled : AwaiterStatus.Pending; - - T IAwaiter.GetResult() - { - if (isDisposed) throw new OperationCanceledException(); - if (callOnce) Dispose(); - return eventValue; - } - - void IAwaiter.GetResult() - { - if (isDisposed) throw new OperationCanceledException(); - if (callOnce) Dispose(); - } - - void INotifyCompletion.OnCompleted(Action action) - { - ((ICriticalNotifyCompletion)this).UnsafeOnCompleted(action); - } - - void ICriticalNotifyCompletion.UnsafeOnCompleted(Action action) - { - Error.ThrowWhenContinuationIsAlreadyRegistered(this.continuation); - this.continuation = action; - } - - // Interface events. - - UniTask IAsyncValueChangedEventHandler.OnValueChangedAsync() - { - return OnInvokeAsync(); - } - - UniTask<(bool IsCanceled, T Result)> IAsyncValueChangedEventHandler.OnValueChangedAsyncSuppressCancellationThrow() - { - return OnInvokeAsyncSuppressCancellationThrow(); - } - - UniTask IAsyncEndEditEventHandler.OnEndEditAsync() - { - return OnInvokeAsync(); - } - - UniTask<(bool IsCanceled, T Result)> IAsyncEndEditEventHandler.OnEndEditAsyncSuppressCancellationThrow() - { - return OnInvokeAsyncSuppressCancellationThrow(); - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.uGUI.cs.meta b/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.uGUI.cs.meta deleted file mode 100644 index 90c5d51..0000000 --- a/Assets/Plugins/UniRx/Scripts/Async/UnityAsyncExtensions.uGUI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6804799fba2376d4099561d176101aff -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Asynchronous.meta b/Assets/Plugins/UniRx/Scripts/Asynchronous.meta index 4de28ae..41660a7 100644 --- a/Assets/Plugins/UniRx/Scripts/Asynchronous.meta +++ b/Assets/Plugins/UniRx/Scripts/Asynchronous.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 683bdf552f52d19428a6f664d9f37bd2 +guid: c490b3110ff2a524ea963382652a378f folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Disposables.meta b/Assets/Plugins/UniRx/Scripts/Disposables.meta index f0479a7..4070ff2 100644 --- a/Assets/Plugins/UniRx/Scripts/Disposables.meta +++ b/Assets/Plugins/UniRx/Scripts/Disposables.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 77ca67bba7f57874586fd7e17790b52b +guid: d061218ef48281148bb1a996d971bdbe folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/InternalUtil.meta b/Assets/Plugins/UniRx/Scripts/InternalUtil.meta index d12b789..c363e39 100644 --- a/Assets/Plugins/UniRx/Scripts/InternalUtil.meta +++ b/Assets/Plugins/UniRx/Scripts/InternalUtil.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 76ea4c3d60485a64ba51ea44ee237ef9 +guid: 7147cf40e45d9b7468957f2d28b1f2f0 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/InternalUtil/CancellableTaskCompletionSource.cs b/Assets/Plugins/UniRx/Scripts/InternalUtil/CancellableTaskCompletionSource.cs new file mode 100644 index 0000000..7e1e686 --- /dev/null +++ b/Assets/Plugins/UniRx/Scripts/InternalUtil/CancellableTaskCompletionSource.cs @@ -0,0 +1,23 @@ +#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace UniRx.InternalUtil +{ + internal interface ICancellableTaskCompletionSource + { + bool TrySetException(Exception exception); + bool TrySetCanceled(); + } + + internal class CancellableTaskCompletionSource : TaskCompletionSource, ICancellableTaskCompletionSource + { + + } +} + +#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/AsyncUnit.cs.meta b/Assets/Plugins/UniRx/Scripts/InternalUtil/CancellableTaskCompletionSource.cs.meta similarity index 83% rename from Assets/Plugins/UniRx/Scripts/Async/AsyncUnit.cs.meta rename to Assets/Plugins/UniRx/Scripts/InternalUtil/CancellableTaskCompletionSource.cs.meta index e0ee132..a856963 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/AsyncUnit.cs.meta +++ b/Assets/Plugins/UniRx/Scripts/InternalUtil/CancellableTaskCompletionSource.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4f95ac245430d304bb5128d13b6becc8 +guid: 622c7ba8630c25b4c911cd1612ee0887 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Plugins/UniRx/Scripts/InternalUtil/PromiseHelper.cs b/Assets/Plugins/UniRx/Scripts/InternalUtil/PromiseHelper.cs new file mode 100644 index 0000000..9662f29 --- /dev/null +++ b/Assets/Plugins/UniRx/Scripts/InternalUtil/PromiseHelper.cs @@ -0,0 +1,26 @@ +#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace UniRx.InternalUtil +{ + internal static class PromiseHelper + { + internal static void TrySetResultAll(IEnumerable> source, T value) + { + var rentArray = source.ToArray(); // better to use Arraypool. + var array = rentArray; + var len = rentArray.Length; + for (int i = 0; i < len; i++) + { + array[i].TrySetResult(value); + array[i] = null; + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Internal/PromiseHelper.cs.meta b/Assets/Plugins/UniRx/Scripts/InternalUtil/PromiseHelper.cs.meta similarity index 83% rename from Assets/Plugins/UniRx/Scripts/Async/Internal/PromiseHelper.cs.meta rename to Assets/Plugins/UniRx/Scripts/InternalUtil/PromiseHelper.cs.meta index dfc1c50..6d7ba4f 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/Internal/PromiseHelper.cs.meta +++ b/Assets/Plugins/UniRx/Scripts/InternalUtil/PromiseHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 173f9b763911bf847b7dfbf31ee87fc4 +guid: daa7aa90cece0fe40920a35e79f526dd MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Plugins/UniRx/Scripts/Async/UnityEqualityComparer.cs b/Assets/Plugins/UniRx/Scripts/InternalUtil/UnityEqualityComparer.cs similarity index 98% rename from Assets/Plugins/UniRx/Scripts/Async/UnityEqualityComparer.cs rename to Assets/Plugins/UniRx/Scripts/InternalUtil/UnityEqualityComparer.cs index d69bf09..98abdf1 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/UnityEqualityComparer.cs +++ b/Assets/Plugins/UniRx/Scripts/InternalUtil/UnityEqualityComparer.cs @@ -4,17 +4,12 @@ using System; using System.Collections.Generic; -#if !UniRxLibrary using UnityEngine; -#endif - -// share between UniRx and UniRx.Async -namespace UniRx +namespace UniRx.InternalUtil { - public static class UnityEqualityComparer + internal static class UnityEqualityComparer { -#if !UniRxLibrary public static readonly IEqualityComparer Vector2 = new Vector2EqualityComparer(); public static readonly IEqualityComparer Vector3 = new Vector3EqualityComparer(); public static readonly IEqualityComparer Vector4 = new Vector4EqualityComparer(); @@ -32,7 +27,6 @@ public static class UnityEqualityComparer static readonly RuntimeTypeHandle rectType = typeof(Rect).TypeHandle; static readonly RuntimeTypeHandle boundsType = typeof(Bounds).TypeHandle; static readonly RuntimeTypeHandle quaternionType = typeof(Quaternion).TypeHandle; -#endif #if UNITY_2017_2_OR_NEWER @@ -77,7 +71,6 @@ static object GetDefaultHelper(Type type) { var t = type.TypeHandle; -#if !UniRxLibrary if (t.Equals(vector2Type)) return (object)UnityEqualityComparer.Vector2; if (t.Equals(vector3Type)) return (object)UnityEqualityComparer.Vector3; if (t.Equals(vector4Type)) return (object)UnityEqualityComparer.Vector4; @@ -86,7 +79,6 @@ static object GetDefaultHelper(Type type) if (t.Equals(rectType)) return (object)UnityEqualityComparer.Rect; if (t.Equals(boundsType)) return (object)UnityEqualityComparer.Bounds; if (t.Equals(quaternionType)) return (object)UnityEqualityComparer.Quaternion; -#endif #if UNITY_2017_2_OR_NEWER @@ -100,8 +92,6 @@ static object GetDefaultHelper(Type type) return null; } - #if !UniRxLibrary - sealed class Vector2EqualityComparer : IEqualityComparer { public bool Equals(Vector2 self, Vector2 vector) @@ -206,8 +196,6 @@ public int GetHashCode(Color32 obj) } } -#endif - #if UNITY_2017_2_OR_NEWER sealed class Vector2IntEqualityComparer : IEqualityComparer diff --git a/Assets/Plugins/UniRx/Scripts/Async/UnityEqualityComparer.cs.meta b/Assets/Plugins/UniRx/Scripts/InternalUtil/UnityEqualityComparer.cs.meta similarity index 83% rename from Assets/Plugins/UniRx/Scripts/Async/UnityEqualityComparer.cs.meta rename to Assets/Plugins/UniRx/Scripts/InternalUtil/UnityEqualityComparer.cs.meta index 190dfac..3550ec5 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/UnityEqualityComparer.cs.meta +++ b/Assets/Plugins/UniRx/Scripts/InternalUtil/UnityEqualityComparer.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5fa41dc096a805641ae7f58112ddb3cf +guid: 626a410137515ac45bb59d1ca91d8f3f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Plugins/UniRx/Scripts/Notifiers.meta b/Assets/Plugins/UniRx/Scripts/Notifiers.meta index 10b7079..0202f53 100644 --- a/Assets/Plugins/UniRx/Scripts/Notifiers.meta +++ b/Assets/Plugins/UniRx/Scripts/Notifiers.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 2223439371f910b40901d01f22f92481 +guid: 63388f4f94a67e34590e2167d45e4046 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Observable.Paging.cs b/Assets/Plugins/UniRx/Scripts/Observable.Paging.cs index 03b5c3d..36f8e16 100644 --- a/Assets/Plugins/UniRx/Scripts/Observable.Paging.cs +++ b/Assets/Plugins/UniRx/Scripts/Observable.Paging.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using UniRx.InternalUtil; using UniRx.Operators; namespace UniRx diff --git a/Assets/Plugins/UniRx/Scripts/Observable.cs b/Assets/Plugins/UniRx/Scripts/Observable.cs index 3740b03..1f5d10a 100644 --- a/Assets/Plugins/UniRx/Scripts/Observable.cs +++ b/Assets/Plugins/UniRx/Scripts/Observable.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Threading; +using UniRx.InternalUtil; using UniRx.Operators; namespace UniRx diff --git a/Assets/Plugins/UniRx/Scripts/Operators.meta b/Assets/Plugins/UniRx/Scripts/Operators.meta index 1fec0b6..4e9bd91 100644 --- a/Assets/Plugins/UniRx/Scripts/Operators.meta +++ b/Assets/Plugins/UniRx/Scripts/Operators.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: d51c184ac8c7a7a47815d18038fc4600 +guid: b37ab723fc6829344bcb6a5991a4e2a1 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Schedulers.meta b/Assets/Plugins/UniRx/Scripts/Schedulers.meta index 984bc16..01beb91 100644 --- a/Assets/Plugins/UniRx/Scripts/Schedulers.meta +++ b/Assets/Plugins/UniRx/Scripts/Schedulers.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: db7122db40f3d67459767aec6aaf271c +guid: ca4cbb2e99a69854d93ad929ef72117b folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Subjects.meta b/Assets/Plugins/UniRx/Scripts/Subjects.meta index 8aa7801..fca8e76 100644 --- a/Assets/Plugins/UniRx/Scripts/Subjects.meta +++ b/Assets/Plugins/UniRx/Scripts/Subjects.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: a498f16648e620f4099a0add31f6af8d +guid: 660d85cac8b3db241b8e6e333d493d38 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/System.meta b/Assets/Plugins/UniRx/Scripts/System.meta index 9ee2ad7..2a9a64f 100644 --- a/Assets/Plugins/UniRx/Scripts/System.meta +++ b/Assets/Plugins/UniRx/Scripts/System.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: a9082dba9e572004eacba691cbc4568a +guid: e38b8fd0fa968d0438280dbb22012b81 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Tasks.meta b/Assets/Plugins/UniRx/Scripts/Tasks.meta index 2ad881d..67db7d4 100644 --- a/Assets/Plugins/UniRx/Scripts/Tasks.meta +++ b/Assets/Plugins/UniRx/Scripts/Tasks.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 5e4e30d9ac0617842a01698194f50290 +guid: f4389552ae1b4f54fb6d931c0a6efd08 folderAsset: yes +timeCreated: 1475139656 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/Tasks/UniTaskObservableExtensions.cs b/Assets/Plugins/UniRx/Scripts/Tasks/UniTaskObservableExtensions.cs deleted file mode 100644 index d937dc9..0000000 --- a/Assets/Plugins/UniRx/Scripts/Tasks/UniTaskObservableExtensions.cs +++ /dev/null @@ -1,246 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - -using System; -using System.Threading; -using UniRx.Async; - -namespace UniRx -{ - public static class UniTaskObservableExtensions - { - public static UniTask ToUniTask(this IObservable source, CancellationToken cancellationToken = default(CancellationToken), bool useFirstValue = false) - { - var promise = new UniTaskCompletionSource(); - var disposable = new SingleAssignmentDisposable(); - - var observer = useFirstValue - ? (IObserver)new FirstValueToUniTaskObserver(promise, disposable, cancellationToken) - : (IObserver)new ToUniTaskObserver(promise, disposable, cancellationToken); - - try - { - disposable.Disposable = source.Subscribe(observer); - } - catch (Exception ex) - { - promise.TrySetException(ex); - } - - return promise.Task; - } - - public static IObservable ToObservable(this UniTask task) - { - if (task.IsCompleted) - { - try - { - return Observable.Return(task.GetAwaiter().GetResult()); - } - catch (Exception ex) - { - return Observable.Throw(ex); - } - } - - var subject = new AsyncSubject(); - Fire(subject, task).Forget(); - return subject; - } - - public static IObservable ToObservable(this UniTask task) - { - if (task.IsCompleted) - { - try - { - return Observable.ReturnUnit(); - } - catch (Exception ex) - { - return Observable.Throw(ex); - } - } - - var subject = new AsyncSubject(); - Fire(subject, task).Forget(); - return subject; - } - - static async UniTaskVoid Fire(AsyncSubject subject, UniTask task) - { - try - { - var value = await task; - subject.OnNext(value); - subject.OnCompleted(); - } - catch (Exception ex) - { - subject.OnError(ex); - } - } - - static async UniTaskVoid Fire(AsyncSubject subject, UniTask task) - { - try - { - await task; - subject.OnNext(Unit.Default); - subject.OnCompleted(); - } - catch (Exception ex) - { - subject.OnError(ex); - } - } - - class ToUniTaskObserver : IObserver - { - static readonly Action callback = OnCanceled; - - readonly UniTaskCompletionSource promise; - readonly SingleAssignmentDisposable disposable; - readonly CancellationToken cancellationToken; - readonly CancellationTokenRegistration registration; - - bool hasValue; - T latestValue; - - public ToUniTaskObserver(UniTaskCompletionSource promise, SingleAssignmentDisposable disposable, CancellationToken cancellationToken) - { - this.promise = promise; - this.disposable = disposable; - this.cancellationToken = cancellationToken; - - if (this.cancellationToken.CanBeCanceled) - { - this.registration = this.cancellationToken.RegisterWithoutCaptureExecutionContext(callback, this); - } - } - - static void OnCanceled(object state) - { - var self = (ToUniTaskObserver)state; - self.disposable.Dispose(); - self.promise.TrySetCanceled(); - } - - public void OnNext(T value) - { - hasValue = true; - latestValue = value; - } - - public void OnError(Exception error) - { - try - { - promise.TrySetException(error); - } - finally - { - registration.Dispose(); - disposable.Dispose(); - } - } - - public void OnCompleted() - { - try - { - if (hasValue) - { - promise.TrySetResult(latestValue); - } - else - { - promise.TrySetException(new InvalidOperationException("Sequence has no elements")); - } - } - finally - { - registration.Dispose(); - disposable.Dispose(); - } - } - } - - class FirstValueToUniTaskObserver : IObserver - { - static readonly Action callback = OnCanceled; - - readonly UniTaskCompletionSource promise; - readonly SingleAssignmentDisposable disposable; - readonly CancellationToken cancellationToken; - readonly CancellationTokenRegistration registration; - - bool hasValue; - - public FirstValueToUniTaskObserver(UniTaskCompletionSource promise, SingleAssignmentDisposable disposable, CancellationToken cancellationToken) - { - this.promise = promise; - this.disposable = disposable; - this.cancellationToken = cancellationToken; - - if (this.cancellationToken.CanBeCanceled) - { - this.registration = this.cancellationToken.RegisterWithoutCaptureExecutionContext(callback, this); - } - } - - static void OnCanceled(object state) - { - var self = (FirstValueToUniTaskObserver)state; - self.disposable.Dispose(); - self.promise.TrySetCanceled(); - } - - public void OnNext(T value) - { - hasValue = true; - try - { - promise.TrySetResult(value); - } - finally - { - registration.Dispose(); - disposable.Dispose(); - } - } - - public void OnError(Exception error) - { - try - { - promise.TrySetException(error); - } - finally - { - registration.Dispose(); - disposable.Dispose(); - } - } - - public void OnCompleted() - { - try - { - if (!hasValue) - { - promise.TrySetException(new InvalidOperationException("Sequence has no elements")); - } - } - finally - { - registration.Dispose(); - disposable.Dispose(); - } - } - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Tasks/UniTaskObservableExtensions.cs.meta b/Assets/Plugins/UniRx/Scripts/Tasks/UniTaskObservableExtensions.cs.meta deleted file mode 100644 index 0bb1eba..0000000 --- a/Assets/Plugins/UniRx/Scripts/Tasks/UniTaskObservableExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1ca394e8fa201840afc3d7af2917014 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/UniRx.asmdef b/Assets/Plugins/UniRx/Scripts/UniRx.asmdef index 91fdcd9..2339898 100644 --- a/Assets/Plugins/UniRx/Scripts/UniRx.asmdef +++ b/Assets/Plugins/UniRx/Scripts/UniRx.asmdef @@ -1,10 +1,12 @@ { "name": "UniRx", - "references": [ - "UniRx.Async" - ], - "optionalUnityReferences": [], + "references": [], "includePlatforms": [], "excludePlatforms": [], - "allowUnsafeCode": false + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [] } \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge.meta b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge.meta index f32a923..e0e2d7b 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge.meta +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 33caec847c56d5b47ae6ba89d27a18a4 +guid: c6fa31db6d33195438d3a9c49effc512 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Diagnostics.meta b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Diagnostics.meta index cf18141..852204b 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Diagnostics.meta +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Diagnostics.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: a2e9fc22f60bc9d49bd3e964610fa541 +guid: 125ca82be137b8544a2b65f7150ee2d4 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/InspectableReactiveProperty.cs b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/InspectableReactiveProperty.cs index fdc163f..ac54988 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/InspectableReactiveProperty.cs +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/InspectableReactiveProperty.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using UniRx.InternalUtil; using UnityEngine; namespace UniRx diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ObserveExtensions.cs b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ObserveExtensions.cs index 6bc9d09..a272623 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ObserveExtensions.cs +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ObserveExtensions.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Threading; +using UniRx.InternalUtil; using UniRx.Triggers; #if !UniRxLibrary diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Operators.meta b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Operators.meta index 38f26d7..d7a89eb 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Operators.meta +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Operators.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 55fb4e5dac4d23c4d824ea04d8722fdb +guid: 4d126dc4a05228e418759d57f7661329 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactiveCommand.cs b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactiveCommand.cs index 25c619d..18471bf 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactiveCommand.cs +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactiveCommand.cs @@ -1,21 +1,17 @@ using System; using System.Collections.Generic; using System.Threading; + #if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -using UniRx.Async; -using UniRx.Async.Internal; +using System.Threading.Tasks; +using UniRx.InternalUtil; #endif - namespace UniRx { public interface IReactiveCommand : IObservable { IReadOnlyReactiveProperty CanExecute { get; } bool Execute(T parameter); - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - UniTask WaitUntilExecuteAsync(CancellationToken cancellationToken); -#endif } public interface IAsyncReactiveCommand @@ -23,10 +19,6 @@ public interface IAsyncReactiveCommand IReadOnlyReactiveProperty CanExecute { get; } IDisposable Execute(T parameter); IDisposable Subscribe(Func> asyncAction); - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - UniTask WaitUntilExecuteAsync(CancellationToken cancellationToken); -#endif } /// @@ -104,15 +96,6 @@ public bool Execute(T parameter) if (canExecute.Value) { trigger.OnNext(parameter); - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.InvokeContinuation(ref parameter); - if (removablePromises != null) - { - PromiseHelper.TrySetResultAll(removablePromises.Values, parameter); - } -#endif - return true; } else @@ -145,65 +128,7 @@ public void Dispose() trigger.OnCompleted(); trigger.Dispose(); canExecuteSubscription.Dispose(); - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.SetCanceled(); - commonPromise = null; - if (removablePromises != null) - { - foreach (var item in removablePromises) - { - item.Value.SetCanceled(); - } - removablePromises = null; - } -#endif } - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - - static readonly Action Callback = CancelCallback; - ReactivePropertyReusablePromise commonPromise; - Dictionary> removablePromises; - - public UniTask WaitUntilExecuteAsync(CancellationToken cancellationToken) - { - if (IsDisposed) throw new ObjectDisposedException("ReadOnlyReactiveProperty"); - - if (!cancellationToken.CanBeCanceled) - { - if (commonPromise != null) return commonPromise.Task; - commonPromise = new ReactivePropertyReusablePromise(CancellationToken.None); - return commonPromise.Task; - } - - if (removablePromises == null) - { - removablePromises = new Dictionary>(CancellationTokenEqualityComparer.Default); - } - - if (removablePromises.TryGetValue(cancellationToken, out var newPromise)) - { - return newPromise.Task; - } - - newPromise = new ReactivePropertyReusablePromise(cancellationToken); - removablePromises.Add(cancellationToken, newPromise); - cancellationToken.RegisterWithoutCaptureExecutionContext(Callback, Tuple.Create(this, newPromise)); - - return newPromise.Task; - } - - static void CancelCallback(object state) - { - var tuple = (Tuple, ReactivePropertyReusablePromise>)state; - if (tuple.Item1.IsDisposed) return; - - tuple.Item2.SetCanceled(); - tuple.Item1.removablePromises.Remove(tuple.Item2.RegisteredCancelationToken); - } - -#endif } /// @@ -279,7 +204,7 @@ public AsyncReactiveCommand() public AsyncReactiveCommand(IObservable canExecuteSource) { this.canExecuteSource = new ReactiveProperty(true); - this.canExecute = canExecute.CombineLatest(canExecuteSource, (x, y) => x && y).ToReactiveProperty(); + this.canExecute = this.canExecuteSource.CombineLatest(canExecuteSource, (x, y) => x && y).ToReactiveProperty(); } /// @@ -303,14 +228,6 @@ public IDisposable Execute(T parameter) { try { -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.InvokeContinuation(ref parameter); - if (removablePromises != null) - { - PromiseHelper.TrySetResultAll(removablePromises.Values, parameter); - } -#endif - var asyncState = a[0].Invoke(parameter) ?? Observable.ReturnUnit(); return asyncState.Finally(() => canExecuteSource.Value = true).Subscribe(); } @@ -325,14 +242,6 @@ public IDisposable Execute(T parameter) var xs = new IObservable[a.Length]; try { -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.InvokeContinuation(ref parameter); - if (removablePromises != null) - { - PromiseHelper.TrySetResultAll(removablePromises.Values, parameter); - } -#endif - for (int i = 0; i < a.Length; i++) { xs[i] = a[i].Invoke(parameter) ?? Observable.ReturnUnit(); @@ -373,66 +282,7 @@ public void Dispose() IsDisposed = true; asyncActions = UniRx.InternalUtil.ImmutableList>>.Empty; - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.SetCanceled(); - commonPromise = null; - if (removablePromises != null) - { - foreach (var item in removablePromises) - { - item.Value.SetCanceled(); - } - removablePromises = null; - } -#endif - } - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - - static readonly Action Callback = CancelCallback; - ReactivePropertyReusablePromise commonPromise; - Dictionary> removablePromises; - - public UniTask WaitUntilExecuteAsync(CancellationToken cancellationToken) - { - if (IsDisposed) throw new ObjectDisposedException("ReadOnlyReactiveProperty"); - - if (!cancellationToken.CanBeCanceled) - { - if (commonPromise != null) return commonPromise.Task; - commonPromise = new ReactivePropertyReusablePromise(CancellationToken.None); - return commonPromise.Task; - } - - if (removablePromises == null) - { - removablePromises = new Dictionary>(CancellationTokenEqualityComparer.Default); - } - - if (removablePromises.TryGetValue(cancellationToken, out var newPromise)) - { - return newPromise.Task; - } - - newPromise = new ReactivePropertyReusablePromise(cancellationToken); - removablePromises.Add(cancellationToken, newPromise); - cancellationToken.RegisterWithoutCaptureExecutionContext(Callback, Tuple.Create(this, newPromise)); - - return newPromise.Task; - } - - static void CancelCallback(object state) - { - var tuple = (Tuple, ReactivePropertyReusablePromise>)state; - if (tuple.Item1.IsDisposed) return; - - tuple.Item2.SetCanceled(); - tuple.Item1.removablePromises.Remove(tuple.Item2.RegisteredCancelationToken); } - -#endif - class Subscription : IDisposable { readonly AsyncReactiveCommand parent; @@ -474,7 +324,32 @@ public static ReactiveCommand ToReactiveCommand(this IObservable can #if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - public static UniTask.Awaiter GetAwaiter(this IReactiveCommand command) + static readonly Action Callback = CancelCallback; + + static void CancelCallback(object state) + { + var tuple = (Tuple)state; + tuple.Item2.Dispose(); + tuple.Item1.TrySetCanceled(); + } + + public static Task WaitUntilExecuteAsync(this IReactiveCommand source, CancellationToken cancellationToken = default(CancellationToken)) + { + var tcs = new CancellableTaskCompletionSource(); + + var disposable = new SingleAssignmentDisposable(); + disposable.Disposable = source.Subscribe(x => + { + disposable.Dispose(); // finish subscription. + tcs.TrySetResult(x); + }, ex => tcs.TrySetException(ex), () => tcs.TrySetCanceled()); + + cancellationToken.Register(Callback, Tuple.Create(tcs, disposable.Disposable), false); + + return tcs.Task; + } + + public static System.Runtime.CompilerServices.TaskAwaiter GetAwaiter(this IReactiveCommand command) { return command.WaitUntilExecuteAsync(CancellationToken.None).GetAwaiter(); } @@ -535,13 +410,33 @@ public static AsyncReactiveCommand ToAsyncReactiveCommand(this IReactivePr #if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - public static UniTask.Awaiter GetAwaiter(this IAsyncReactiveCommand command) + static readonly Action Callback = CancelCallback; + + static void CancelCallback(object state) + { + var tuple = (Tuple)state; + tuple.Item2.Dispose(); + tuple.Item1.TrySetCanceled(); + } + + public static Task WaitUntilExecuteAsync(this IAsyncReactiveCommand source, CancellationToken cancellationToken = default(CancellationToken)) + { + var tcs = new CancellableTaskCompletionSource(); + + var subscription = source.Subscribe(x => { tcs.TrySetResult(x); return Observable.ReturnUnit(); }); + cancellationToken.Register(Callback, Tuple.Create(tcs, subscription), false); + + return tcs.Task; + } + + public static System.Runtime.CompilerServices.TaskAwaiter GetAwaiter(this IAsyncReactiveCommand command) { return command.WaitUntilExecuteAsync(CancellationToken.None).GetAwaiter(); } #endif + #if !UniRxLibrary // for uGUI(from 4.6) diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactiveProperty.cs b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactiveProperty.cs index 3f0b482..d67a81e 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactiveProperty.cs +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactiveProperty.cs @@ -5,12 +5,12 @@ using System; using System.Collections.Generic; using System.Threading; +using UniRx.InternalUtil; #if !UniRxLibrary using UnityEngine; #endif #if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) -using UniRx.Async; -using UniRx.Async.Internal; +using System.Threading.Tasks; #endif namespace UniRx @@ -19,10 +19,6 @@ public interface IReadOnlyReactiveProperty : IObservable { T Value { get; } bool HasValue { get; } - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - UniTask WaitUntilValueChangedAsync(CancellationToken cancellationToken); -#endif } public interface IReactiveProperty : IReadOnlyReactiveProperty @@ -156,14 +152,6 @@ void RaiseOnNext(ref T value) node.OnNext(value); node = node.Next; } - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.InvokeContinuation(ref value); - if (removablePromises != null) - { - PromiseHelper.TrySetResultAll(removablePromises.Values, value); - } -#endif } protected virtual void SetValue(T value) @@ -246,19 +234,6 @@ protected virtual void Dispose(bool disposing) node.OnCompleted(); node = node.Next; } -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.SetCanceled(); - commonPromise = null; - if (removablePromises != null) - { - foreach (var item in removablePromises) - { - item.Value.SetCanceled(); - } - removablePromises = null; - } -#endif - } public override string ToString() @@ -270,52 +245,6 @@ public bool IsRequiredSubscribeOnCurrentThread() { return false; } - - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - - static readonly Action Callback = CancelCallback; - ReactivePropertyReusablePromise commonPromise; - Dictionary> removablePromises; - - public UniTask WaitUntilValueChangedAsync(CancellationToken cancellationToken) - { - if (isDisposed) throw new ObjectDisposedException("ReactiveProperty"); - - if (!cancellationToken.CanBeCanceled) - { - if (commonPromise != null) return commonPromise.Task; - commonPromise = new ReactivePropertyReusablePromise(CancellationToken.None); - return commonPromise.Task; - } - - if (removablePromises == null) - { - removablePromises = new Dictionary>(CancellationTokenEqualityComparer.Default); - } - - if (removablePromises.TryGetValue(cancellationToken, out var newPromise)) - { - return newPromise.Task; - } - - newPromise = new ReactivePropertyReusablePromise(cancellationToken); - removablePromises.Add(cancellationToken, newPromise); - cancellationToken.RegisterWithoutCaptureExecutionContext(Callback, Tuple.Create(this, newPromise)); - - return newPromise.Task; - } - - static void CancelCallback(object state) - { - var tuple = (Tuple, ReactivePropertyReusablePromise>)state; - if (tuple.Item1.isDisposed) return; - - tuple.Item2.SetCanceled(); - tuple.Item1.removablePromises.Remove(tuple.Item2.RegisteredCancelationToken); - } - -#endif } /// @@ -461,19 +390,6 @@ protected virtual void Dispose(bool disposing) node.OnCompleted(); node = node.Next; } - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.SetCanceled(); - commonPromise = null; - if (removablePromises != null) - { - foreach (var item in removablePromises) - { - item.Value.SetCanceled(); - } - removablePromises = null; - } -#endif } void IObserverLinkedList.UnsubscribeNode(ObserverNode node) @@ -521,14 +437,6 @@ void IObserver.OnNext(T value) node.OnNext(value); node = node.Next; } - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - commonPromise?.InvokeContinuation(ref value); - if (removablePromises != null) - { - PromiseHelper.TrySetResultAll(removablePromises.Values, value); - } -#endif } void IObserver.OnError(Exception error) @@ -538,7 +446,7 @@ void IObserver.OnError(Exception error) // call source.OnError var node = root; while (node != null) - { + { node.OnError(error); node = node.Next; } @@ -561,51 +469,6 @@ public bool IsRequiredSubscribeOnCurrentThread() { return false; } - -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - - static readonly Action Callback = CancelCallback; - ReactivePropertyReusablePromise commonPromise; - Dictionary> removablePromises; - - public UniTask WaitUntilValueChangedAsync(CancellationToken cancellationToken) - { - if (isDisposed) throw new ObjectDisposedException("ReadOnlyReactiveProperty"); - - if (!cancellationToken.CanBeCanceled) - { - if (commonPromise != null) return commonPromise.Task; - commonPromise = new ReactivePropertyReusablePromise(CancellationToken.None); - return commonPromise.Task; - } - - if (removablePromises == null) - { - removablePromises = new Dictionary>(CancellationTokenEqualityComparer.Default); - } - - if (removablePromises.TryGetValue(cancellationToken, out var newPromise)) - { - return newPromise.Task; - } - - newPromise = new ReactivePropertyReusablePromise(cancellationToken); - removablePromises.Add(cancellationToken, newPromise); - cancellationToken.RegisterWithoutCaptureExecutionContext(Callback, Tuple.Create(this, newPromise)); - - return newPromise.Task; - } - - static void CancelCallback(object state) - { - var tuple = (Tuple, ReactivePropertyReusablePromise>)state; - if (tuple.Item1.isDisposed) return; - - tuple.Item2.SetCanceled(); - tuple.Item1.removablePromises.Remove(tuple.Item2.RegisteredCancelationToken); - } - -#endif } /// @@ -630,14 +493,59 @@ public static ReadOnlyReactiveProperty ToReadOnlyReactiveProperty(this IOb #if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - public static UniTask.Awaiter GetAwaiter(this IReadOnlyReactiveProperty source) + static readonly Action Callback = CancelCallback; + + static void CancelCallback(object state) + { + var tuple = (Tuple)state; + tuple.Item2.Dispose(); + tuple.Item1.TrySetCanceled(); + } + + public static Task WaitUntilValueChangedAsync(this IReadOnlyReactiveProperty source, CancellationToken cancellationToken = default(CancellationToken)) + { + var tcs = new CancellableTaskCompletionSource(); + + var disposable = new SingleAssignmentDisposable(); + if (source.HasValue) + { + // Skip first value + var isFirstValue = true; + disposable.Disposable = source.Subscribe(x => + { + if (isFirstValue) + { + isFirstValue = false; + return; + } + else + { + disposable.Dispose(); // finish subscription. + tcs.TrySetResult(x); + } + }, ex => tcs.TrySetException(ex), () => tcs.TrySetCanceled()); + } + else + { + disposable.Disposable = source.Subscribe(x => + { + disposable.Dispose(); // finish subscription. + tcs.TrySetResult(x); + }, ex => tcs.TrySetException(ex), () => tcs.TrySetCanceled()); + } + + cancellationToken.Register(Callback, Tuple.Create(tcs, disposable.Disposable), false); + + return tcs.Task; + } + + public static System.Runtime.CompilerServices.TaskAwaiter GetAwaiter(this IReadOnlyReactiveProperty source) { return source.WaitUntilValueChangedAsync(CancellationToken.None).GetAwaiter(); } #endif - /// /// Create ReadOnlyReactiveProperty with distinctUntilChanged: false. /// diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactivePropertyReusablePromise.cs b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactivePropertyReusablePromise.cs deleted file mode 100644 index e6af87d..0000000 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactivePropertyReusablePromise.cs +++ /dev/null @@ -1,140 +0,0 @@ -#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) - -#pragma warning disable CS1591 - -using System; -using System.Threading; -using UniRx.Async; -using UniRx.Async.Internal; - -namespace UniRx -{ - internal class ReactivePropertyReusablePromise : IAwaiter, IResolvePromise - { - T result; - object continuation; // Action or Queue - MinimumQueue<(int, T)> queueValues; - bool running; - int waitingContinuationCount; - AwaiterStatus status; - - internal readonly CancellationToken RegisteredCancelationToken; - - public bool IsCompleted => status.IsCompleted(); - public UniTask Task => new UniTask(this); - public AwaiterStatus Status => status; - - public ReactivePropertyReusablePromise(CancellationToken cancellationToken) - { - this.RegisteredCancelationToken = cancellationToken; - this.status = AwaiterStatus.Pending; - - TaskTracker.TrackActiveTask(this, 3); - } - - public T GetResult() - { - if (status == AwaiterStatus.Canceled) throw new OperationCanceledException(); - return result; - } - - void IAwaiter.GetResult() - { - GetResult(); - } - - public void SetCanceled() - { - status = AwaiterStatus.Canceled; - // run rest continuation. - TaskTracker.RemoveTracking(this); - - result = default(T); - InvokeContinuation(ref result); - // clear - continuation = null; - queueValues = null; - } - - public void InvokeContinuation(ref T value) - { - if (continuation == null) return; - - if (continuation is Action act) - { - this.result = value; - continuation = null; - act(); - } - else - { - if (waitingContinuationCount == 0) return; - - var q = (MinimumQueue)continuation; - if (queueValues == null) queueValues = new MinimumQueue<(int, T)>(4); - queueValues.Enqueue((waitingContinuationCount, value)); - waitingContinuationCount = 0; - - if (!running) - { - running = true; - try - { - while (queueValues.Count != 0) - { - var (runCount, v) = queueValues.Dequeue(); - this.result = v; - for (int i = 0; i < runCount; i++) - { - q.Dequeue().Invoke(); - } - } - } - finally - { - running = false; - } - } - } - } - - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - public void UnsafeOnCompleted(Action action) - { - if (continuation == null) - { - continuation = action; - return; - } - else - { - if (continuation is Action act) - { - var q = new MinimumQueue(4); - q.Enqueue(act); - q.Enqueue(action); - continuation = q; - waitingContinuationCount = 2; - return; - } - else - { - ((MinimumQueue)continuation).Enqueue(action); - waitingContinuationCount++; - } - } - } - - bool IResolvePromise.TrySetResult(T value) - { - InvokeContinuation(ref value); - return true; - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactivePropertyReusablePromise.cs.meta b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactivePropertyReusablePromise.cs.meta deleted file mode 100644 index 428890b..0000000 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/ReactivePropertyReusablePromise.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4c3ce1729c826c047afbd8ae1e85a3ab -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Toolkit.meta b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Toolkit.meta index a290e81..029446b 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Toolkit.meta +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Toolkit.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 87f9d8f6c8b0b584a87f87878621769f +guid: 726595c7d6d85824887a77691e3ca50a folderAsset: yes +timeCreated: 1468655394 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Triggers.meta b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Triggers.meta index bde02c6..6565449 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Triggers.meta +++ b/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/Triggers.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 32cf3f2e2edea8b4cb7505281befe757 +guid: 5380144628ecdc74ab6778f80d103d51 folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Scripts/UnityWinRTBridge.meta b/Assets/Plugins/UniRx/Scripts/UnityWinRTBridge.meta index 086e5ec..33c919c 100644 --- a/Assets/Plugins/UniRx/Scripts/UnityWinRTBridge.meta +++ b/Assets/Plugins/UniRx/Scripts/UnityWinRTBridge.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 383c6945ed8402f4dac000cefd6f173e +guid: 2c03c70869bcd0240b96959097acc29d folderAsset: yes +timeCreated: 1455373896 +licenseType: Store DefaultImporter: - externalObjects: {} userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Plugins/UniRx/Examples/UniRx.Examples.asmdef.meta b/Assets/Scripts.meta similarity index 57% rename from Assets/Plugins/UniRx/Examples/UniRx.Examples.asmdef.meta rename to Assets/Scripts.meta index 0380f9f..a7ce218 100644 --- a/Assets/Plugins/UniRx/Examples/UniRx.Examples.asmdef.meta +++ b/Assets/Scripts.meta @@ -1,6 +1,7 @@ fileFormatVersion: 2 -guid: 71799519d12379b49b6b53aea974bea5 -AssemblyDefinitionImporter: +guid: 8d59f85923db03f46b29cece04303b81 +folderAsset: yes +DefaultImporter: externalObjects: {} userData: assetBundleName: diff --git a/Assets/Visual Behavior Tree/Scripts/AI.meta b/Assets/Scripts/AI.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI.meta rename to Assets/Scripts/AI.meta index 501e3d3..48a5a06 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI.meta +++ b/Assets/Scripts/AI.meta @@ -1,10 +1,10 @@ -fileFormatVersion: 2 -guid: 581b7f319f546074e858a826dbf8c5ca -folderAsset: yes -timeCreated: 1519367469 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 581b7f319f546074e858a826dbf8c5ca +folderAsset: yes +timeCreated: 1519367469 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger.meta b/Assets/Scripts/AI/Behavior Logger.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger.meta rename to Assets/Scripts/AI/Behavior Logger.meta index 84271ab..d4fc7b3 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger.meta +++ b/Assets/Scripts/AI/Behavior Logger.meta @@ -1,10 +1,10 @@ -fileFormatVersion: 2 -guid: fd95b8ef1325b85439d13b53209cfcd0 -folderAsset: yes -timeCreated: 1522736380 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: fd95b8ef1325b85439d13b53209cfcd0 +folderAsset: yes +timeCreated: 1522736380 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs b/Assets/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs similarity index 96% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs rename to Assets/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs index ae63e39..e51c5e3 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs +++ b/Assets/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs @@ -1,22 +1,22 @@ -using System; -using UniRx; - -namespace Assets.Scripts.AI.Behavior_Logger -{ - public static class BehaviorDebugExtensions - { - public static IObservable Debug(this IObservable source, BehaviorLogger logger) - { -#if DEBUG - return source.Materialize() - .Do(x => logger.Debug(x.ToString())) - .Dematerialize() - .DoOnCancel(() => logger.Debug("OnCancel")) - .DoOnSubscribe(() => logger.Debug("OnSubscribe")); -#else - return source; -#endif - } - - } -} +using System; +using UniRx; + +namespace Assets.Scripts.AI.Behavior_Logger +{ + public static class BehaviorDebugExtensions + { + public static IObservable Debug(this IObservable source, BehaviorLogger logger) + { +#if DEBUG + return source.Materialize() + .Do(x => logger.Debug(x.ToString())) + .Dematerialize() + .DoOnCancel(() => logger.Debug("OnCancel")) + .DoOnSubscribe(() => logger.Debug("OnSubscribe")); +#else + return source; +#endif + } + + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs.meta b/Assets/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs.meta rename to Assets/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs.meta index 2565df1..d58fe05 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs.meta +++ b/Assets/Scripts/AI/Behavior Logger/BehaviorDebugExtensions.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 4b66684c79dce4a4aac13d3657a78ab7 -timeCreated: 1522812431 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 4b66684c79dce4a4aac13d3657a78ab7 +timeCreated: 1522812431 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs b/Assets/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs similarity index 97% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs rename to Assets/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs index b0b9cd5..8fdb43c 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs +++ b/Assets/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs @@ -1,66 +1,66 @@ -using System; -using UnityEngine; - -namespace Assets.Scripts.AI.Behavior_Logger -{ - [Serializable] - public class BehaviorLogEntry - { - // requires - public string LoggerName { get; private set; } - public LogType LogType { get; private set; } - public string Message { get; private set; } - public DateTime Timestamp { get; private set; } - - // options - /// - /// [Optional] Used to keep track of frames for debugging. - /// - public long TickNumber { get; private set; } - - public BehaviorState NewState { get; private set; } - - public int BehaviorID { get; private set; } - - /// [Optional] - public UnityEngine.Object Context { get; private set; } - /// [Optional] - public Exception Exception { get; private set; } - /// [Optional] - public string StackTrace { get; private set; } - /// [Optional] - public BehaviorTreeElement State { get; private set; } - - public BehaviorLogEntry(string loggerName, LogType logType, DateTime timestamp, string message, int behaviorID = -2, - BehaviorState newState = BehaviorState.Null, long ticknum = -1, - UnityEngine.Object context = null, Exception exception = null, - string stackTrace = null, BehaviorTreeElement state = null) - { - this.LoggerName = loggerName; - this.LogType = logType; - this.Timestamp = timestamp; - this.Message = message; - this.BehaviorID = behaviorID; - this.NewState = newState; - this.TickNumber = ticknum; - this.Context = context; - this.Exception = exception; - this.StackTrace = stackTrace; - this.State = state; - } - - public override string ToString() - { - var plusEx = (Exception != null) ? (Environment.NewLine + Exception.ToString()) : ""; - return - "[" + LoggerName + "]" + Environment.NewLine - + "[ID:" + BehaviorID + "]" + Environment.NewLine - + "[" + Timestamp.ToString() + "]" + Environment.NewLine - + "[" + TickNumber + "]" + Environment.NewLine - //+ "[" + LogType.ToString() + "]" - + "[" + NewState + "]" + Environment.NewLine - + Message - + plusEx + Environment.NewLine; - } - } -} +using System; +using UnityEngine; + +namespace Assets.Scripts.AI.Behavior_Logger +{ + [Serializable] + public class BehaviorLogEntry + { + // requires + public string LoggerName { get; private set; } + public LogType LogType { get; private set; } + public string Message { get; private set; } + public DateTime Timestamp { get; private set; } + + // options + /// + /// [Optional] Used to keep track of frames for debugging. + /// + public long TickNumber { get; private set; } + + public BehaviorState NewState { get; private set; } + + public int BehaviorID { get; private set; } + + /// [Optional] + public UnityEngine.Object Context { get; private set; } + /// [Optional] + public Exception Exception { get; private set; } + /// [Optional] + public string StackTrace { get; private set; } + /// [Optional] + public BehaviorTreeElement State { get; private set; } + + public BehaviorLogEntry(string loggerName, LogType logType, DateTime timestamp, string message, int behaviorID = -2, + BehaviorState newState = BehaviorState.Null, long ticknum = -1, + UnityEngine.Object context = null, Exception exception = null, + string stackTrace = null, BehaviorTreeElement state = null) + { + this.LoggerName = loggerName; + this.LogType = logType; + this.Timestamp = timestamp; + this.Message = message; + this.BehaviorID = behaviorID; + this.NewState = newState; + this.TickNumber = ticknum; + this.Context = context; + this.Exception = exception; + this.StackTrace = stackTrace; + this.State = state; + } + + public override string ToString() + { + var plusEx = (Exception != null) ? (Environment.NewLine + Exception.ToString()) : ""; + return + "[" + LoggerName + "]" + Environment.NewLine + + "[ID:" + BehaviorID + "]" + Environment.NewLine + + "[" + Timestamp.ToString() + "]" + Environment.NewLine + + "[" + TickNumber + "]" + Environment.NewLine + //+ "[" + LogType.ToString() + "]" + + "[" + NewState + "]" + Environment.NewLine + + Message + + plusEx + Environment.NewLine; + } + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs.meta b/Assets/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs.meta rename to Assets/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs.meta index c6eed10..6457d1a 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs.meta +++ b/Assets/Scripts/AI/Behavior Logger/BehaviorLogEntry.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 5f695ffe72055774a8ccbfb9e33c1280 -timeCreated: 1522736382 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 5f695ffe72055774a8ccbfb9e33c1280 +timeCreated: 1522736382 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogger.cs b/Assets/Scripts/AI/Behavior Logger/BehaviorLogger.cs similarity index 97% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogger.cs rename to Assets/Scripts/AI/Behavior Logger/BehaviorLogger.cs index 33eb6e3..b036ee4 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogger.cs +++ b/Assets/Scripts/AI/Behavior Logger/BehaviorLogger.cs @@ -1,137 +1,137 @@ -using System; -using UnityEngine; - -namespace Assets.Scripts.AI.Behavior_Logger -{ - public partial class BehaviorLogger - { - static bool isInitialized = false; - static bool isDebugBuild = false; - - public string Name { get; private set; } - protected readonly Action logPublisher; - - public BehaviorLogger(string loggerName) - { - this.Name = loggerName; - this.logPublisher = ObservableBehaviorLogger.RegisterLogger(this); - } - - /// Output LogType.Log but only enabled if isDebugBuild - public virtual void Debug(object message, UnityEngine.Object context = null) - { - if (!isInitialized) - { - isInitialized = true; - isDebugBuild = UnityEngine.Debug.isDebugBuild; - } - - if (isDebugBuild) - { - logPublisher(new BehaviorLogEntry( - message: (message != null) ? message.ToString() : "", - logType: LogType.Log, - timestamp: DateTime.Now, - loggerName: Name, - context: context)); - } - } - - /// Output LogType.Log but only enables isDebugBuild - public virtual void DebugFormat(string format, params object[] args) - { - if (!isInitialized) - { - isInitialized = true; - isDebugBuild = UnityEngine.Debug.isDebugBuild; - } - - if (isDebugBuild) - { - logPublisher(new BehaviorLogEntry( - message: (format != null) ? string.Format(format, args) : "", - logType: LogType.Log, - timestamp: DateTime.Now, - loggerName: Name, - context: null)); - } - } - - public virtual void Log(object message, UnityEngine.Object context = null) - { - logPublisher(new BehaviorLogEntry( - message: (message != null) ? message.ToString() : "", - logType: LogType.Log, - timestamp: DateTime.Now, - loggerName: Name, - context: context)); - } - - public virtual void LogFormat(string format, params object[] args) - { - logPublisher(new BehaviorLogEntry( - message: (format != null) ? string.Format(format, args) : "", - logType: LogType.Log, - timestamp: DateTime.Now, - loggerName: Name, - context: null)); - } - - public virtual void Warning(object message, UnityEngine.Object context = null) - { - logPublisher(new BehaviorLogEntry( - message: (message != null) ? message.ToString() : "", - logType: LogType.Warning, - timestamp: DateTime.Now, - loggerName: Name, - context: context)); - } - - public virtual void WarningFormat(string format, params object[] args) - { - logPublisher(new BehaviorLogEntry( - message: (format != null) ? string.Format(format, args) : "", - logType: LogType.Warning, - timestamp: DateTime.Now, - loggerName: Name, - context: null)); - } - - public virtual void Error(object message, UnityEngine.Object context = null) - { - logPublisher(new BehaviorLogEntry( - message: (message != null) ? message.ToString() : "", - logType: LogType.Error, - timestamp: DateTime.Now, - loggerName: Name, - context: context)); - } - - public virtual void ErrorFormat(string format, params object[] args) - { - logPublisher(new BehaviorLogEntry( - message: (format != null) ? string.Format(format, args) : "", - logType: LogType.Error, - timestamp: DateTime.Now, - loggerName: Name, - context: null)); - } - - public virtual void Exception(Exception exception, UnityEngine.Object context = null) - { - logPublisher(new BehaviorLogEntry( - message: (exception != null) ? exception.ToString() : "", - exception: exception, - logType: LogType.Exception, - timestamp: DateTime.Now, - loggerName: Name, - context: context)); - } - - /// Publish raw LogEntry. - public virtual void Raw(BehaviorLogEntry logEntry) - { - logPublisher(logEntry); - } - } +using System; +using UnityEngine; + +namespace Assets.Scripts.AI.Behavior_Logger +{ + public partial class BehaviorLogger + { + static bool isInitialized = false; + static bool isDebugBuild = false; + + public string Name { get; private set; } + protected readonly Action logPublisher; + + public BehaviorLogger(string loggerName) + { + this.Name = loggerName; + this.logPublisher = ObservableBehaviorLogger.RegisterLogger(this); + } + + /// Output LogType.Log but only enabled if isDebugBuild + public virtual void Debug(object message, UnityEngine.Object context = null) + { + if (!isInitialized) + { + isInitialized = true; + isDebugBuild = UnityEngine.Debug.isDebugBuild; + } + + if (isDebugBuild) + { + logPublisher(new BehaviorLogEntry( + message: (message != null) ? message.ToString() : "", + logType: LogType.Log, + timestamp: DateTime.Now, + loggerName: Name, + context: context)); + } + } + + /// Output LogType.Log but only enables isDebugBuild + public virtual void DebugFormat(string format, params object[] args) + { + if (!isInitialized) + { + isInitialized = true; + isDebugBuild = UnityEngine.Debug.isDebugBuild; + } + + if (isDebugBuild) + { + logPublisher(new BehaviorLogEntry( + message: (format != null) ? string.Format(format, args) : "", + logType: LogType.Log, + timestamp: DateTime.Now, + loggerName: Name, + context: null)); + } + } + + public virtual void Log(object message, UnityEngine.Object context = null) + { + logPublisher(new BehaviorLogEntry( + message: (message != null) ? message.ToString() : "", + logType: LogType.Log, + timestamp: DateTime.Now, + loggerName: Name, + context: context)); + } + + public virtual void LogFormat(string format, params object[] args) + { + logPublisher(new BehaviorLogEntry( + message: (format != null) ? string.Format(format, args) : "", + logType: LogType.Log, + timestamp: DateTime.Now, + loggerName: Name, + context: null)); + } + + public virtual void Warning(object message, UnityEngine.Object context = null) + { + logPublisher(new BehaviorLogEntry( + message: (message != null) ? message.ToString() : "", + logType: LogType.Warning, + timestamp: DateTime.Now, + loggerName: Name, + context: context)); + } + + public virtual void WarningFormat(string format, params object[] args) + { + logPublisher(new BehaviorLogEntry( + message: (format != null) ? string.Format(format, args) : "", + logType: LogType.Warning, + timestamp: DateTime.Now, + loggerName: Name, + context: null)); + } + + public virtual void Error(object message, UnityEngine.Object context = null) + { + logPublisher(new BehaviorLogEntry( + message: (message != null) ? message.ToString() : "", + logType: LogType.Error, + timestamp: DateTime.Now, + loggerName: Name, + context: context)); + } + + public virtual void ErrorFormat(string format, params object[] args) + { + logPublisher(new BehaviorLogEntry( + message: (format != null) ? string.Format(format, args) : "", + logType: LogType.Error, + timestamp: DateTime.Now, + loggerName: Name, + context: null)); + } + + public virtual void Exception(Exception exception, UnityEngine.Object context = null) + { + logPublisher(new BehaviorLogEntry( + message: (exception != null) ? exception.ToString() : "", + exception: exception, + logType: LogType.Exception, + timestamp: DateTime.Now, + loggerName: Name, + context: context)); + } + + /// Publish raw LogEntry. + public virtual void Raw(BehaviorLogEntry logEntry) + { + logPublisher(logEntry); + } + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogger.cs.meta b/Assets/Scripts/AI/Behavior Logger/BehaviorLogger.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogger.cs.meta rename to Assets/Scripts/AI/Behavior Logger/BehaviorLogger.cs.meta index 84d53e6..5465b42 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/BehaviorLogger.cs.meta +++ b/Assets/Scripts/AI/Behavior Logger/BehaviorLogger.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 06592c43911849341b408d8d16e715b7 -timeCreated: 1522736380 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 06592c43911849341b408d8d16e715b7 +timeCreated: 1522736380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs b/Assets/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs similarity index 96% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs rename to Assets/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs index 1586ddf..3f1141b 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs +++ b/Assets/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs @@ -1,27 +1,27 @@ -using System; -using UniRx; - -namespace Assets.Scripts.AI.Behavior_Logger -{ - public class ObservableBehaviorLogger : IObservable - { - static readonly Subject logPublisher = new Subject(); - - public static readonly ObservableBehaviorLogger Listener = new ObservableBehaviorLogger(); - - private ObservableBehaviorLogger() - { } - - public static Action RegisterLogger(BehaviorLogger logger) - { - if (logger.Name == null) throw new ArgumentNullException("logger.Name is null"); - - return logPublisher.OnNext; - } - - public IDisposable Subscribe(IObserver observer) - { - return logPublisher.Subscribe(observer); - } - } +using System; +using UniRx; + +namespace Assets.Scripts.AI.Behavior_Logger +{ + public class ObservableBehaviorLogger : IObservable + { + static readonly Subject logPublisher = new Subject(); + + public static readonly ObservableBehaviorLogger Listener = new ObservableBehaviorLogger(); + + private ObservableBehaviorLogger() + { } + + public static Action RegisterLogger(BehaviorLogger logger) + { + if (logger.Name == null) throw new ArgumentNullException("logger.Name is null"); + + return logPublisher.OnNext; + } + + public IDisposable Subscribe(IObserver observer) + { + return logPublisher.Subscribe(observer); + } + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs.meta b/Assets/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs.meta rename to Assets/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs.meta index 2e5abb9..3befca1 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs.meta +++ b/Assets/Scripts/AI/Behavior Logger/ObservableBehaviorLogger.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: bb7b4389cc29fff418225c1ce967a103 -timeCreated: 1522736382 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: bb7b4389cc29fff418225c1ce967a103 +timeCreated: 1522736382 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AI/BehaviorManager.cs b/Assets/Scripts/AI/BehaviorManager.cs new file mode 100644 index 0000000..af0179f --- /dev/null +++ b/Assets/Scripts/AI/BehaviorManager.cs @@ -0,0 +1,128 @@ +using Assets.Scripts.AI.Behavior_Logger; +using Assets.Scripts.AI.Components; +using Assets.Visual_Behavior_Tree.Scripts; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI +{ + public class BehaviorManager : MonoBehaviour, IDisposable + { + private BehaviorLogger behaviorLogger; + public BehaviorLogger BehaviorLogger + { + get + { + if(behaviorLogger == null) + { + behaviorLogger = new BehaviorLogger(gameObject.name + ": " + BehaviorTreeFiles.Count + " Trees"); + } + return behaviorLogger; + } + + private set + { + behaviorLogger = value; + } + } + + public List> Debuggers; + + /// + /// The file to actually save/load to/from. + /// + [JsonIgnore] + [Description("The currently loaded tree assets that will be run concurrently.")] + public List BehaviorTreeFiles; + + public BehaviorTreeElement Runner { get; set; } + + /// + /// Seconds between every tick. At "0" this will tick every frame (basically an update loop) + /// + [SerializeField] + [Description("Milliseconds between every tick. At 0 this will tick every frame")] + public double MilliSecondsBetweenTicks = 100; + + /// + /// Number of times to tick the full tree. Set to a negative number to make an infinitely running behavior tree. + /// + [SerializeField] + [Description("Times to tick this tree before stopping. Negative values indicate infinitely running behavior.")] + public int TimesToTick = 10; + + private bool initialized = false; + + public void InitIfNeeded() + { + if (initialized == false) + { + Reinitialize(); + } + } + + public Subject TreeSubject { get; private set; } + public Dictionary rootList = new Dictionary(); + public void Reinitialize() + { + //TODO: Change to runner extension + + if (BehaviorTreeFiles.Count > 1) + { + Runner = ScriptableObject.CreateInstance(); + Runner.Depth = -1; + Runner.ID = -1; + foreach (var asset in BehaviorTreeFiles) + { + var childRoot = asset.LoadRoot(); + Debug.Log("child root: " + childRoot); + ((Merge)Runner).AddChild(childRoot); + rootList.Add(childRoot, asset); + } + } + else + { + var treeFile = BehaviorTreeFiles.First(); + Runner = treeFile.LoadRoot(); + rootList.Add(Runner, treeFile); + } + + var logStream = ObservableBehaviorLogger.Listener.Subscribe(log => Debug.Log("Manager: " + log)); + + Runner.Manager = this; + Runner.Initialize(); + + initialized = true; + } + + /// + /// Ticks on the aggregate ParallelRunner then continues ticking for as long as the runner is in running state + /// + /// + //TODO: CHANGE TO Zip() instead of loop + void Start() + { + InitIfNeeded(); + + var timeStep = Observable.Interval(TimeSpan.FromMilliseconds(MilliSecondsBetweenTicks)) + .TakeWhile((_) => TimesToTick != 0) + .Do(cx => + { + if (TimesToTick > 0) --TimesToTick; + Runner.Start().Subscribe(); + }) + .Subscribe() + .AddTo(this); + } + + public void Dispose() + { + Runner.Dispose(); + } + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorManager.cs.meta b/Assets/Scripts/AI/BehaviorManager.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/BehaviorManager.cs.meta rename to Assets/Scripts/AI/BehaviorManager.cs.meta index c2891a2..b7fffa3 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorManager.cs.meta +++ b/Assets/Scripts/AI/BehaviorManager.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: 73bc91841bad4424992751c051af5030 -timeCreated: 1510630398 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 73bc91841bad4424992751c051af5030 +timeCreated: 1510630398 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorState.cs b/Assets/Scripts/AI/BehaviorState.cs similarity index 96% rename from Assets/Visual Behavior Tree/Scripts/AI/BehaviorState.cs rename to Assets/Scripts/AI/BehaviorState.cs index c2723ea..0dc5649 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorState.cs +++ b/Assets/Scripts/AI/BehaviorState.cs @@ -1,15 +1,15 @@ -namespace Assets.Scripts.AI -{ - //TODO: Error state? Needed? Useful? - /// - /// Null usually means this behavior has not started or is in an error state. - /// Fail, Success, and Running are for checking the current state from the parent object. - /// - public enum BehaviorState - { - Null = 0, - Fail, - Success, - Running - } +namespace Assets.Scripts.AI +{ + //TODO: Error state? Needed? Useful? + /// + /// Null usually means this behavior has not started or is in an error state. + /// Fail, Success, and Running are for checking the current state from the parent object. + /// + public enum BehaviorState + { + Null = 0, + Fail, + Success, + Running + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorState.cs.meta b/Assets/Scripts/AI/BehaviorState.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/BehaviorState.cs.meta rename to Assets/Scripts/AI/BehaviorState.cs.meta index 6f3598f..6aef72c 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorState.cs.meta +++ b/Assets/Scripts/AI/BehaviorState.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: a0f8f6209976b6e44b7475b5706d2509 -timeCreated: 1510007420 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: a0f8f6209976b6e44b7475b5706d2509 +timeCreated: 1510007420 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorTreeElement.cs b/Assets/Scripts/AI/BehaviorTreeElement.cs similarity index 58% rename from Assets/Visual Behavior Tree/Scripts/AI/BehaviorTreeElement.cs rename to Assets/Scripts/AI/BehaviorTreeElement.cs index e4cd208..3c4d918 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorTreeElement.cs +++ b/Assets/Scripts/AI/BehaviorTreeElement.cs @@ -1,114 +1,145 @@ -using Assets.Scripts.AI.Tree; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UniRx; -using UnityEngine; - -namespace Assets.Scripts.AI -{ - [Serializable] - public abstract class BehaviorTreeElement : TreeElement, IDisposable - { - //is this needed? - public LongReactiveProperty NumberOfTicksReceived { get; private set; } - - //used for reflection upon JSON loading - public string ElementType { get; set; } - - public BehaviorTreeElement(string name, int depth, int id) - : base(name, depth, id) - { - NumberOfTicksReceived = new LongReactiveProperty(0); - ElementType = this.GetType().ToString(); - CurrentState = (BehaviorState.Null); - Children = new List(); - } - - [Newtonsoft.Json.JsonIgnore] - public BehaviorState CurrentState; - - public bool Initialized = false; - - /// - /// The primary method of action - /// - /// observable stream of states from this behavior - public abstract IObservable Start(); - - public virtual void Initialize() - { - if (Initialized) return; - var allChildrenToRun = from x in Children - select x as BehaviorTreeElement; - - foreach(var ch in allChildrenToRun) - { - ch.ObserveEveryValueChanged(x => x.CurrentState) - .Subscribe() - .AddTo(Disposables); - } - - Initialized = true; - } - - public override string ToString() - { - var depthPad = ""; - for (int d = 0; d < this.Depth +1; ++d) - { - depthPad += " "; - } - var retString = depthPad + "ID: " + ID + "\n" + - depthPad + "Name: " + this.Name + "\n" + - depthPad + "Depth: " + Depth + "\n" + - depthPad + "Type: " + ElementType.ToString() + "\n" + - depthPad + "NumChildren: " + (HasChildren ? Children.Count : 0) + "\n"; - - if (Children != null) - { - retString += depthPad + "Children: \n"; - foreach (var child in Children) - { - retString += child.ToString(); - } - } - return retString; - - } - - #region IDisposable Support - - // CompositeDisposable is similar with List, manage multiple IDisposable - [NonSerialized] - protected CompositeDisposable Disposables = new CompositeDisposable(); // field - private bool disposedValue = false; // To detect redundant calls - - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) - { - if (disposing) - { - Disposables.Clear(); - } - - // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. - // TODO: set large fields to null. - Children.Clear(); - Children = null; - - disposedValue = true; - } - } - - // This code added to correctly implement the disposable pattern. - public void Dispose() - { - // Do not change this code. Put cleanup code in Dispose(bool disposing) above. - Dispose(true); - } - #endregion - } +using Assets.Scripts.AI.Behavior_Logger; +using Assets.Scripts.AI.Tree; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI +{ + [Serializable] + public abstract class BehaviorTreeElement : TreeElement, IDisposable + { + //used for JSON saving/loading + public string ElementType { get; set; } + + [Newtonsoft.Json.JsonIgnore] + public virtual bool CanHaveChildren { get => true; } + + [Newtonsoft.Json.JsonIgnore] + public MonoBehaviour Manager { get; set; } + + [Newtonsoft.Json.JsonIgnore] + public BehaviorLogger DebugLogger { get; protected set; } + + [Newtonsoft.Json.JsonIgnore] + private BehaviorState _currentState; + [Newtonsoft.Json.JsonIgnore] + public BehaviorState CurrentState { get => _currentState; set => _currentState = value; } + + [Newtonsoft.Json.JsonIgnore] + protected bool Initialized = false; + + public BehaviorTreeElement(string name,int depth, int id) + : base(name, depth, id) + { + ElementType = this.GetType().ToString(); + CurrentState = BehaviorState.Null; + if(CanHaveChildren) + Children = new List(); + } + + protected Action DebugLogAction; + + /// + /// The primary method of action + /// + /// observable stream of states from this behavior + public abstract IObservable Start(); + + public virtual void Initialize() + { + Debug.Log("Initializing " + this.ElementType); + + DebugLogger = new BehaviorLogger(Manager.name + " | " + Name); + + if (Initialized) return; + if(CanHaveChildren) + { + var allChildrenToRun = from x in Children + select x as BehaviorTreeElement; + + foreach (var ch in allChildrenToRun) + { + ch.Manager = this.Manager; + ch.Initialize(); + } + } + + DebugLogAction = (debugState) => + { + var logEntry = new BehaviorLogEntry( + loggerName: DebugLogger.Name, + logType: LogType.Log, + timestamp: DateTime.Now, + message: "Ticked!", + behaviorID: this.ID, + newState: debugState, + context: this); + DebugLogger.Raw(logEntry); + }; + + Initialized = true; + } + + public override string ToString() + { + var depthPad = ""; + for (int d = 0; d < this.Depth +1; ++d) + { + depthPad += " "; + } + var retString = depthPad + "ID: " + ID + "\n" + + depthPad + "Name: " + this.Name + "\n" + + depthPad + "Depth: " + Depth + "\n" + + depthPad + "Type: " + ElementType.ToString() + "\n" + + depthPad + "NumChildren: " + (HasChildren ? Children.Count : 0) + "\n"; + + if (Children != null) + { + retString += depthPad + "Children: \n"; + foreach (var child in Children) + { + retString += child.ToString(); + } + } + return retString; + + } + + #region IDisposable Support + + // CompositeDisposable is similar with List, manage multiple IDisposable + [NonSerialized] + protected CompositeDisposable Disposables = new CompositeDisposable(); // field + private bool disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + Disposables.Clear(); + } + + // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. + // TODO: set large fields to null. + Children.Clear(); + Children = null; + + disposedValue = true; + } + } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(true); + } + #endregion + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorTreeElement.cs.meta b/Assets/Scripts/AI/BehaviorTreeElement.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/BehaviorTreeElement.cs.meta rename to Assets/Scripts/AI/BehaviorTreeElement.cs.meta index a0c602b..ecdf494 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/BehaviorTreeElement.cs.meta +++ b/Assets/Scripts/AI/BehaviorTreeElement.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: decd6968705c12e4e85cdfe07281ce9a -timeCreated: 1510006706 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: decd6968705c12e4e85cdfe07281ce9a +timeCreated: 1510006706 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AI/BehaviorTreeElement.cs~HEAD b/Assets/Scripts/AI/BehaviorTreeElement.cs~HEAD new file mode 100644 index 0000000..e00cc9e --- /dev/null +++ b/Assets/Scripts/AI/BehaviorTreeElement.cs~HEAD @@ -0,0 +1,261 @@ +<<<<<<< HEAD:Assets/Scripts/AI/BehaviorTreeElement.cs +using Assets.Scripts.AI.Behavior_Logger; +using Assets.Scripts.AI.Tree; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI +{ + [Serializable] + public abstract class BehaviorTreeElement : TreeElement, IDisposable + { + //used for JSON saving/loading + public string ElementType { get; set; } + + [Newtonsoft.Json.JsonIgnore] + public virtual bool CanHaveChildren { get => true; } + + [Newtonsoft.Json.JsonIgnore] + public MonoBehaviour Manager { get; set; } + + [Newtonsoft.Json.JsonIgnore] + public BehaviorLogger DebugLogger { get; protected set; } + + [Newtonsoft.Json.JsonIgnore] + private BehaviorState _currentState; + [Newtonsoft.Json.JsonIgnore] + public BehaviorState CurrentState { get => _currentState; set => _currentState = value; } + + [Newtonsoft.Json.JsonIgnore] + protected bool Initialized = false; + + public BehaviorTreeElement(string name,int depth, int id) + : base(name, depth, id) + { + ElementType = this.GetType().ToString(); + CurrentState = BehaviorState.Null; + if(CanHaveChildren) + Children = new List(); + } + + protected Action DebugLogAction; + + /// + /// The primary method of action + /// + /// observable stream of states from this behavior + public abstract IObservable Start(); + + public virtual void Initialize() + { + Debug.Log("Initializing " + this.ElementType); + + DebugLogger = new BehaviorLogger(Manager.name + " | " + Name); + + if (Initialized) return; + if(CanHaveChildren) + { + var allChildrenToRun = from x in Children + select x as BehaviorTreeElement; + + foreach (var ch in allChildrenToRun) + { + ch.Manager = this.Manager; + ch.Initialize(); + } + } + + DebugLogAction = (debugState) => + { + var logEntry = new BehaviorLogEntry( + loggerName: DebugLogger.Name, + logType: LogType.Log, + timestamp: DateTime.Now, + message: "Ticked!", + behaviorID: this.ID, + newState: debugState, + context: this); + DebugLogger.Raw(logEntry); + }; + + Initialized = true; + } + + public override string ToString() + { + var depthPad = ""; + for (int d = 0; d < this.Depth +1; ++d) + { + depthPad += " "; + } + var retString = depthPad + "ID: " + ID + "\n" + + depthPad + "Name: " + this.Name + "\n" + + depthPad + "Depth: " + Depth + "\n" + + depthPad + "Type: " + ElementType.ToString() + "\n" + + depthPad + "NumChildren: " + (HasChildren ? Children.Count : 0) + "\n"; + + if (Children != null) + { + retString += depthPad + "Children: \n"; + foreach (var child in Children) + { + retString += child.ToString(); + } + } + return retString; + + } + + #region IDisposable Support + + // CompositeDisposable is similar with List, manage multiple IDisposable + [NonSerialized] + protected CompositeDisposable Disposables = new CompositeDisposable(); // field + private bool disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + Disposables.Clear(); + } + + // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. + // TODO: set large fields to null. + Children.Clear(); + Children = null; + + disposedValue = true; + } + } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(true); + } + #endregion + } +======= +using Assets.Scripts.AI.Tree; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI +{ + [Serializable] + public abstract class BehaviorTreeElement : TreeElement, IDisposable + { + //is this needed? + public LongReactiveProperty NumberOfTicksReceived { get; private set; } + + //used for reflection upon JSON loading + public string ElementType { get; set; } + + public BehaviorTreeElement(string name, int depth, int id) + : base(name, depth, id) + { + NumberOfTicksReceived = new LongReactiveProperty(0); + ElementType = this.GetType().ToString(); + CurrentState = (BehaviorState.Null); + Children = new List(); + } + + [Newtonsoft.Json.JsonIgnore] + public BehaviorState CurrentState; + + public bool Initialized = false; + + /// + /// The primary method of action + /// + /// observable stream of states from this behavior + public abstract IObservable Start(); + + public virtual void Initialize() + { + if (Initialized) return; + var allChildrenToRun = from x in Children + select x as BehaviorTreeElement; + + foreach(var ch in allChildrenToRun) + { + ch.ObserveEveryValueChanged(x => x.CurrentState) + .Subscribe() + .AddTo(Disposables); + } + + Initialized = true; + } + + public override string ToString() + { + var depthPad = ""; + for (int d = 0; d < this.Depth +1; ++d) + { + depthPad += " "; + } + var retString = depthPad + "ID: " + ID + "\n" + + depthPad + "Name: " + this.Name + "\n" + + depthPad + "Depth: " + Depth + "\n" + + depthPad + "Type: " + ElementType.ToString() + "\n" + + depthPad + "NumChildren: " + (HasChildren ? Children.Count : 0) + "\n"; + + if (Children != null) + { + retString += depthPad + "Children: \n"; + foreach (var child in Children) + { + retString += child.ToString(); + } + } + return retString; + + } + + #region IDisposable Support + + // CompositeDisposable is similar with List, manage multiple IDisposable + [NonSerialized] + protected CompositeDisposable Disposables = new CompositeDisposable(); // field + private bool disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + Disposables.Clear(); + } + + // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. + // TODO: set large fields to null. + Children.Clear(); + Children = null; + + disposedValue = true; + } + } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(true); + } + #endregion + } +>>>>>>> 6a384864ba7731c73b85c374e962ced28f3d4f26:Assets/Visual Behavior Tree/Scripts/AI/BehaviorTreeElement.cs +} \ No newline at end of file diff --git a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniRx.Async.Editor.asmdef.meta b/Assets/Scripts/AI/BehaviorTreeElement.cs~HEAD.meta similarity index 59% rename from Assets/Plugins/UniRx/Scripts/Async/Editor/UniRx.Async.Editor.asmdef.meta rename to Assets/Scripts/AI/BehaviorTreeElement.cs~HEAD.meta index 821b87b..0c59e60 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/Editor/UniRx.Async.Editor.asmdef.meta +++ b/Assets/Scripts/AI/BehaviorTreeElement.cs~HEAD.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 4129704b5a1a13841ba16f230bf24a57 -AssemblyDefinitionImporter: +guid: 14f4ff8f88a93a947854748866662317 +DefaultImporter: externalObjects: {} userData: assetBundleName: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components.meta b/Assets/Scripts/AI/Components.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Components.meta rename to Assets/Scripts/AI/Components.meta index 3fc47f1..71d36a8 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Components.meta +++ b/Assets/Scripts/AI/Components.meta @@ -1,10 +1,10 @@ -fileFormatVersion: 2 -guid: cfbfc64efdfd2eb4e9a91b969190497a -folderAsset: yes -timeCreated: 1510203379 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: cfbfc64efdfd2eb4e9a91b969190497a +folderAsset: yes +timeCreated: 1510203379 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components/BehaviorComponent.cs b/Assets/Scripts/AI/Components/BehaviorComponent.cs similarity index 88% rename from Assets/Visual Behavior Tree/Scripts/AI/Components/BehaviorComponent.cs rename to Assets/Scripts/AI/Components/BehaviorComponent.cs index 7626fe5..109633a 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Components/BehaviorComponent.cs +++ b/Assets/Scripts/AI/Components/BehaviorComponent.cs @@ -1,29 +1,31 @@ -using System.Collections; -using System.Collections.Generic; -using UniRx; -using UnityEngine; - -namespace Assets.Scripts.AI.Components -{ - [System.Serializable] - public abstract class BehaviorComponent : BehaviorTreeElement - { - public BehaviorComponent(string name, int depth, int id) - : base(name, depth, id) - { - Children = new List(); - } - - public virtual void AddChild(BehaviorTreeElement element) - { - element.Parent = this; - Children.Add(element); - } - - public override System.IObservable Start() - { - return Observable.Empty(); - } - - } -} +using System.Collections; +using System.Collections.Generic; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI.Components +{ + [System.Serializable] + public abstract class BehaviorComponent : BehaviorTreeElement + { + public override bool CanHaveChildren { get => true; } + + public BehaviorComponent(string name, int depth, int id) + : base(name, depth, id) + { + Children = new List(); + } + + public virtual void AddChild(BehaviorTreeElement element) + { + element.Parent = this; + Children.Add(element); + } + + public override System.IObservable Start() + { + return Observable.Empty(); + } + + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components/BehaviorComponent.cs.meta b/Assets/Scripts/AI/Components/BehaviorComponent.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Components/BehaviorComponent.cs.meta rename to Assets/Scripts/AI/Components/BehaviorComponent.cs.meta index 91fdbab..9668eae 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Components/BehaviorComponent.cs.meta +++ b/Assets/Scripts/AI/Components/BehaviorComponent.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: be0a6d932da64f24c98048a4061faf8b -timeCreated: 1510001735 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: be0a6d932da64f24c98048a4061faf8b +timeCreated: 1510001735 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components/Merge.cs b/Assets/Scripts/AI/Components/Merge.cs similarity index 77% rename from Assets/Visual Behavior Tree/Scripts/AI/Components/Merge.cs rename to Assets/Scripts/AI/Components/Merge.cs index bf6280f..cdeae3e 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Components/Merge.cs +++ b/Assets/Scripts/AI/Components/Merge.cs @@ -1,54 +1,56 @@ -using System; -using System.Collections; -using System.ComponentModel; -using System.Linq; -using UniRx; -using UnityEngine; -using Assets.Visual_Behavior_Tree.Scripts; - -namespace Assets.Scripts.AI.Components -{ - [Serializable] - [Description("Runs all children at same time. Fails early if NumFailures are >0 and total children failed reach that number. Succeeds otherwise.")] - public class Merge : BehaviorComponent - { - [Range(0, 100)] - [SerializeField] - public float SucceedFailPercentForSucceess = 51; - - public Merge(string name, int depth, int id) - : base(name, depth, id) { } - - public override IObservable Start() - { - if (Children == null || Children.Count == 0) - { - Debug.LogWarning("Children Null in parallel runner"); - return Observable.Return(BehaviorState.Fail); - } - - var source = Children.ToObservable() - .SelectMany(child => - ((BehaviorTreeElement)child).Start() - .Where(st => st != BehaviorState.Running)); - - - //should take all streams and publish running until last stream finishes... - //once last stream finishes, must emit "success" or "fail" based on set ratio... - return source.Publish(src => - src.Aggregate(new { total = 0, succeeded = 0 }, (acc, childResult) => - { - return childResult == BehaviorState.Success ? - new { total = acc.total + 1, succeeded = acc.succeeded + 1 } : - new { total = acc.total + 1, acc.succeeded }; - }) - .Select(a => 100 * ((float)a.succeeded / a.total)) - .Select(ratio => ratio >= SucceedFailPercentForSucceess ? - BehaviorState.Success : BehaviorState.Fail) - .Publish(srcLast => - src.Select(s => BehaviorState.Running) - .TakeUntil(srcLast).Merge(srcLast))); - } - - } -} +using System; +using System.Collections; +using System.ComponentModel; +using System.Linq; +using UniRx; +using UnityEngine; +using Assets.Visual_Behavior_Tree.Scripts; +using Assets.Scripts.AI.Behavior_Logger; + +namespace Assets.Scripts.AI.Components +{ + [Serializable] + [Description("Runs all children at same time. Fails early if NumFailures are >0 and total children failed reach that number. Succeeds otherwise.")] + public class Merge : BehaviorComponent + { + [Range(0, 100)] + [SerializeField] + public float SucceedPercent = 51; + + public Merge(string name, int depth, int id) + : base(name, depth, id) { } + + public override IObservable Start() + { + if (Children == null || Children.Count == 0) + { + Debug.LogWarning("Children Null in merge component"); + return Observable.Return(BehaviorState.Fail); + } + + var source = Children.ToObservable() + .SelectMany(child => + ((BehaviorTreeElement)child).Start() + .Where(st => st != BehaviorState.Running)); + + + //takes all children streams and publishes running until last stream finishes. + //once last stream finishes, emits "success" or "fail" based on set success ratio. + return source.Publish(src => + src.Aggregate(new { total = 0, succeeded = 0 }, (acc, childResult) => + { + return childResult == BehaviorState.Success ? + new { total = acc.total + 1, succeeded = acc.succeeded + 1 } : + new { total = acc.total + 1, acc.succeeded }; + }) + .Select(a => 100 * ((float)a.succeeded / a.total)) + .Select(ratio => ratio >= SucceedPercent ? + BehaviorState.Success : BehaviorState.Fail) + + .Publish(srcLast => + src.Select(s => BehaviorState.Running) + .TakeUntil(srcLast).Merge(srcLast))) + .Do(state => DebugLogAction(state)); + } + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components/Merge.cs.meta b/Assets/Scripts/AI/Components/Merge.cs.meta similarity index 100% rename from Assets/Visual Behavior Tree/Scripts/AI/Components/Merge.cs.meta rename to Assets/Scripts/AI/Components/Merge.cs.meta diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components/Selector.cs b/Assets/Scripts/AI/Components/Selector.cs similarity index 97% rename from Assets/Visual Behavior Tree/Scripts/AI/Components/Selector.cs rename to Assets/Scripts/AI/Components/Selector.cs index 6f16aa6..9a1284c 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Components/Selector.cs +++ b/Assets/Scripts/AI/Components/Selector.cs @@ -1,47 +1,45 @@ -using Assets.Visual_Behavior_Tree.Scripts; -using System; -using System.Collections; -using System.ComponentModel; -using System.Linq; -using UniRx; -using UnityEngine; - -namespace Assets.Scripts.AI.Components -{ - /// - /// runs all sub behaviors until a behavior returns success. - /// Returns success if a child was successful, otherwise returns fail - /// - [Serializable] - [Description("Runs children in order. Succeeds on first child that succeeds. Fails if no children succeed.")] - public class Selector : BehaviorComponent - { - public Selector(string name, int depth, int id) - : base(name, depth, id) - { } - - public override IObservable Start() - { - if (Children == null || Children.Count == 0) - { - Debug.LogWarning("Children Null in " + this.Name); - return Observable.Return(BehaviorState.Fail); - } - - var sourceConcat = Children.ToObservable() - .Select(child => - ((BehaviorTreeElement)child).Start() - .Where(st => st != BehaviorState.Running)) - .Concat(); //Sequentially run children and select the final value (should be fail/succeed/error) - - // - return sourceConcat.Publish(src => - src.Any(e => e == BehaviorState.Success) //true if any succeed, false if none succeed - .Select(e => e ? BehaviorState.Success : BehaviorState.Fail) //Success if any succeed, fail if all fail - .Publish(srcLast => - src.Where(e => e == BehaviorState.Fail) - .Select(e => BehaviorState.Running) - .TakeUntil(srcLast).Merge(srcLast))); - } - } +using Assets.Visual_Behavior_Tree.Scripts; +using System; +using System.Collections; +using System.ComponentModel; +using System.Linq; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI.Components +{ + /// + /// runs all sub behaviors until a behavior returns success. + /// Returns success if a child was successful, otherwise returns fail + /// + [Serializable] + [Description("Runs children in order. Succeeds on first child that succeeds. Fails if no children succeed.")] + public class Selector : BehaviorComponent + { + public Selector(string name, int depth, int id) + : base(name, depth, id) + { } + + public override IObservable Start() + { + if (Children == null || Children.Count == 0) + { + Debug.LogWarning("Children Null in " + this.Name); + return Observable.Return(BehaviorState.Fail); + } + var sourceConcat = Children.ToObservable() + .Select(child => + ((BehaviorTreeElement)child).Start() + .Where(st => st != BehaviorState.Running)) + .Concat(); //Sequentially run children and select the final value (should be fail/succeed/error) + + return sourceConcat.Publish(src => + src.Any(e => e == BehaviorState.Success) //true if any succeed, false if none succeed + .Select(e => e ? BehaviorState.Success : BehaviorState.Fail) //Success if any succeed, fail if all fail + .Publish(srcLast => + src.Where(e => e == BehaviorState.Fail) + .Select(e => BehaviorState.Running) + .TakeUntil(srcLast).Merge(srcLast))); + } + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components/Selector.cs.meta b/Assets/Scripts/AI/Components/Selector.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Components/Selector.cs.meta rename to Assets/Scripts/AI/Components/Selector.cs.meta index 94d5d3f..71ded6c 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Components/Selector.cs.meta +++ b/Assets/Scripts/AI/Components/Selector.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 0722c5f25b262a34c993139ca5a5d29c -timeCreated: 1510204858 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 0722c5f25b262a34c993139ca5a5d29c +timeCreated: 1510204858 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components/Sequencer.cs b/Assets/Scripts/AI/Components/Sequencer.cs similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Components/Sequencer.cs rename to Assets/Scripts/AI/Components/Sequencer.cs index 9b6ab28..3db61ea 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Components/Sequencer.cs +++ b/Assets/Scripts/AI/Components/Sequencer.cs @@ -1,44 +1,44 @@ -using Assets.Visual_Behavior_Tree.Scripts; -using System; -using System.Collections; -using System.ComponentModel; -using UniRx; -using UnityEngine; - -namespace Assets.Scripts.AI.Components -{ - /// - /// Runs until a child returns in a fail state - /// - [System.Serializable] - [Description("runs children in sequence until a child fails. Succeeds if no children fail. Fails if any child fails.")] - public class Sequencer : BehaviorComponent - { - public Sequencer(string name, int depth, int id) - : base(name, depth, id) - {} - - public override IObservable Start() - { - if (Children == null || Children.Count == 0) - { - Debug.LogWarning("Children Null in " + this.Name); - return Observable.Return(BehaviorState.Fail); - } - - var sourceConcat = Children.ToObservable() - .Select(child => - ((BehaviorTreeElement)child).Start() - .Where(st => st != BehaviorState.Running)) - .Concat(); //Sequentially run children and select the final value (should be fail/succeed/error) - - return sourceConcat.Publish(src => - src.Any(e => e == BehaviorState.Fail) //true if any fail, false if none fail - .Select(e => e ? BehaviorState.Fail : BehaviorState.Success) //fail if any fail, succeed if all succeed - .Publish(srcLast => - src.Where(e => e == BehaviorState.Success) //success should keep running - .Select(e => BehaviorState.Running) //so return running to show this - .TakeUntil(srcLast).Merge(srcLast))); - } - } + using Assets.Visual_Behavior_Tree.Scripts; +using System; +using System.Collections; +using System.ComponentModel; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI.Components +{ + /// + /// Runs until a child returns in a fail state + /// + [System.Serializable] + [Description("runs children in sequence until a child fails. Succeeds if no children fail. Fails if any child fails.")] + public class Sequencer : BehaviorComponent + { + public Sequencer(string name, int depth, int id) + : base(name, depth, id) + {} + + public override IObservable Start() + { + if (Children == null || Children.Count == 0) + { + Debug.LogWarning("Children Null in " + this.Name); + return Observable.Return(BehaviorState.Fail); + } + + var sourceConcat = Children.ToObservable() + .Select(child => + ((BehaviorTreeElement)child).Start() + .Where(st => st != BehaviorState.Running)) + .Concat(); //Sequentially run children and select the final value (should be fail/succeed/error) + + return sourceConcat.Publish(src => + src.Any(e => e == BehaviorState.Fail) //true if any fail, false if none fail + .Select(e => e ? BehaviorState.Fail : BehaviorState.Success) //fail if any fail, succeed if all succeed + .Publish(srcLast => + src.Where(e => e == BehaviorState.Success) //success should keep running + .Select(e => BehaviorState.Running) //so return running to show this + .TakeUntil(srcLast).Merge(srcLast))); + } + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Components/Sequencer.cs.meta b/Assets/Scripts/AI/Components/Sequencer.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Components/Sequencer.cs.meta rename to Assets/Scripts/AI/Components/Sequencer.cs.meta index 2406e5d..dd430ef 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Components/Sequencer.cs.meta +++ b/Assets/Scripts/AI/Components/Sequencer.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 09119a885ebfa4c4cbb06415188c4c13 -timeCreated: 1510204010 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 09119a885ebfa4c4cbb06415188c4c13 +timeCreated: 1510204010 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Decorators.meta b/Assets/Scripts/AI/Decorators.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Decorators.meta rename to Assets/Scripts/AI/Decorators.meta index cc3b49d..8eaa31a 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Decorators.meta +++ b/Assets/Scripts/AI/Decorators.meta @@ -1,10 +1,10 @@ -fileFormatVersion: 2 -guid: 340608a4cbadc724a8d7d6fb6a26711a -folderAsset: yes -timeCreated: 1510203379 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 340608a4cbadc724a8d7d6fb6a26711a +folderAsset: yes +timeCreated: 1510203379 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Decorators/BehaviorDecorator.cs b/Assets/Scripts/AI/Decorators/BehaviorDecorator.cs similarity index 83% rename from Assets/Visual Behavior Tree/Scripts/AI/Decorators/BehaviorDecorator.cs rename to Assets/Scripts/AI/Decorators/BehaviorDecorator.cs index c9169b6..690bf97 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Decorators/BehaviorDecorator.cs +++ b/Assets/Scripts/AI/Decorators/BehaviorDecorator.cs @@ -1,15 +1,17 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Assets.Scripts.AI.Decorators -{ - public abstract class BehaviorDecorator : BehaviorTreeElement - { - public BehaviorDecorator(string name, int depth, int id) - : base(name, depth, id) - { - Children = new List(); - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Assets.Scripts.AI.Decorators +{ + public abstract class BehaviorDecorator : BehaviorTreeElement + { + public BehaviorDecorator(string name, int depth, int id) + : base(name, depth, id) + { + Children = new List(); + } + + public override bool CanHaveChildren => true; + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Decorators/BehaviorDecorator.cs.meta b/Assets/Scripts/AI/Decorators/BehaviorDecorator.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Decorators/BehaviorDecorator.cs.meta rename to Assets/Scripts/AI/Decorators/BehaviorDecorator.cs.meta index 8664596..a94bf43 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Decorators/BehaviorDecorator.cs.meta +++ b/Assets/Scripts/AI/Decorators/BehaviorDecorator.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 4c1fcae49d4a83548bf07dafe517cc6c -timeCreated: 1510203379 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 4c1fcae49d4a83548bf07dafe517cc6c +timeCreated: 1510203379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Decorators/Inverter.cs b/Assets/Scripts/AI/Decorators/Inverter.cs similarity index 91% rename from Assets/Visual Behavior Tree/Scripts/AI/Decorators/Inverter.cs rename to Assets/Scripts/AI/Decorators/Inverter.cs index 41abcc7..0133404 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Decorators/Inverter.cs +++ b/Assets/Scripts/AI/Decorators/Inverter.cs @@ -1,30 +1,32 @@ -using System; -using System.Collections; -using UniRx; -using UnityEngine; - -namespace Assets.Scripts.AI.Decorators -{ - [System.Serializable] - public class Inverter : BehaviorDecorator - { - public Inverter(string name, int depth, int id) - : base(name, depth, id) - { } - - public override IObservable Start() - { - if (Children == null || Children.Count == 0) - { - Debug.LogWarning("Children Null in " + this.Name); - return Observable.Return(BehaviorState.Fail); - } - - var sourceConcat = - Children.ToObservable().Select(child => ((BehaviorTreeElement)child).Start().Where(state => state != BehaviorState.Running)) - .Concat(); - - return sourceConcat.Select(state => state == BehaviorState.Fail ? BehaviorState.Success : BehaviorState.Fail); - } - } +using System; +using System.Collections; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI.Decorators +{ + [System.Serializable] + public class Inverter : BehaviorDecorator + { + public Inverter(string name, int depth, int id) + : base(name, depth, id) + { } + + public override bool CanHaveChildren { get => true; } + + public override IObservable Start() + { + if (Children == null || Children.Count == 0) + { + Debug.LogWarning("Children Null in " + this.Name); + return Observable.Return(BehaviorState.Fail); + } + + var sourceConcat = + Children.ToObservable().Select(child => ((BehaviorTreeElement)child).Start().Where(state => state != BehaviorState.Running)) + .Concat(); + + return sourceConcat.Select(state => state == BehaviorState.Fail ? BehaviorState.Success : BehaviorState.Fail); + } + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Decorators/Inverter.cs.meta b/Assets/Scripts/AI/Decorators/Inverter.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Decorators/Inverter.cs.meta rename to Assets/Scripts/AI/Decorators/Inverter.cs.meta index 5708c80..01094f1 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Decorators/Inverter.cs.meta +++ b/Assets/Scripts/AI/Decorators/Inverter.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 7f9e397ff49da7840978a9776a23e6bd -timeCreated: 1510335218 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 7f9e397ff49da7840978a9776a23e6bd +timeCreated: 1510335218 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Nodes.meta b/Assets/Scripts/AI/Nodes.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Nodes.meta rename to Assets/Scripts/AI/Nodes.meta index 5a2092f..6dda69d 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Nodes.meta +++ b/Assets/Scripts/AI/Nodes.meta @@ -1,10 +1,10 @@ -fileFormatVersion: 2 -guid: 649445d98a7c4054eb1a2fd1e9b84423 -folderAsset: yes -timeCreated: 1510203379 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 649445d98a7c4054eb1a2fd1e9b84423 +folderAsset: yes +timeCreated: 1510203379 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Nodes/BehaviorNode.cs b/Assets/Scripts/AI/Nodes/BehaviorNode.cs similarity index 76% rename from Assets/Visual Behavior Tree/Scripts/AI/Nodes/BehaviorNode.cs rename to Assets/Scripts/AI/Nodes/BehaviorNode.cs index 4684ee4..b33b075 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Nodes/BehaviorNode.cs +++ b/Assets/Scripts/AI/Nodes/BehaviorNode.cs @@ -1,11 +1,13 @@ -using System.Collections; -using UnityEngine; - -namespace Assets.Scripts.AI.Nodes -{ - public abstract class BehaviorNode : BehaviorTreeElement - { - public BehaviorNode(string name, int depth, int id) : base(name, depth, id) - {} - } +using System.Collections; +using UnityEngine; + +namespace Assets.Scripts.AI.Nodes +{ + public abstract class BehaviorNode : BehaviorTreeElement + { + public BehaviorNode(string name, int depth, int id) : base(name, depth, id) + {} + + public override bool CanHaveChildren { get => false; } + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Nodes/BehaviorNode.cs.meta b/Assets/Scripts/AI/Nodes/BehaviorNode.cs.meta similarity index 85% rename from Assets/Visual Behavior Tree/Scripts/AI/Nodes/BehaviorNode.cs.meta rename to Assets/Scripts/AI/Nodes/BehaviorNode.cs.meta index c5da3bd..9cdf6de 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Nodes/BehaviorNode.cs.meta +++ b/Assets/Scripts/AI/Nodes/BehaviorNode.cs.meta @@ -1,7 +1,5 @@ fileFormatVersion: 2 guid: bac4dc3c25eb67e4a8d433e466c15feb -timeCreated: 1510203462 -licenseType: Free MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Nodes/DebugOutNode.cs b/Assets/Scripts/AI/Nodes/DebugOutNode.cs similarity index 68% rename from Assets/Visual Behavior Tree/Scripts/AI/Nodes/DebugOutNode.cs rename to Assets/Scripts/AI/Nodes/DebugOutNode.cs index b1695b3..c180fdb 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Nodes/DebugOutNode.cs +++ b/Assets/Scripts/AI/Nodes/DebugOutNode.cs @@ -1,28 +1,29 @@ -using System; -using System.Collections; -using UniRx; -using UnityEngine; - -namespace Assets.Scripts.AI.Nodes -{ - [Serializable] - public class DebugOutNode : BehaviorNode - { - public DebugOutNode(string name, int depth, int id) - : base(name, depth, id) - { } - - - public override IObservable Start() - { - base.Initialize(); - - CurrentState = BehaviorState.Running; //Forces an update on the state between succeeds. - //DO STUFF HERE - Debug.Log("Debug Out Node " + Name + " Doing stuff"); - //DO MORE STUFF?! - - return Observable.Return(BehaviorState.Success); - } - } -} +using System; +using System.Collections; +using UniRx; +using UnityEngine; + +namespace Assets.Scripts.AI.Nodes +{ + [Serializable] + public class DebugOutNode : BehaviorNode + { + public string logMessage; + + public DebugOutNode(string name, int depth, int id) + : base(name, depth, id) + { } + + public override IObservable Start() + { + //base.Initialize(); + + CurrentState = BehaviorState.Null; //Forces an update on the state between succeeds. + //DO STUFF HERE + Debug.Log(logMessage); + //DO MORE STUFF?! + + return Observable.Return(BehaviorState.Success); + } + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Nodes/DebugOutNode.cs.meta b/Assets/Scripts/AI/Nodes/DebugOutNode.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Nodes/DebugOutNode.cs.meta rename to Assets/Scripts/AI/Nodes/DebugOutNode.cs.meta index 5e8c086..a6b062e 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Nodes/DebugOutNode.cs.meta +++ b/Assets/Scripts/AI/Nodes/DebugOutNode.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 67a24dd4e390091488917da92d44c3b8 -timeCreated: 1518461313 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 67a24dd4e390091488917da92d44c3b8 +timeCreated: 1518461313 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AI/Nodes/MoveToNode.cs b/Assets/Scripts/AI/Nodes/MoveToNode.cs new file mode 100644 index 0000000..5602d68 --- /dev/null +++ b/Assets/Scripts/AI/Nodes/MoveToNode.cs @@ -0,0 +1,68 @@ +using Assets.Scripts.AI; +using Assets.Scripts.AI.Nodes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UniRx; +using UnityEngine; +using UnityEngine.AI; + +namespace Assets.Visual_Behavior_Tree.Scripts.AI.Nodes +{ + public class MoveToNode : BehaviorNode + { + public int TimeBetweenChecks; + + [Newtonsoft.Json.JsonIgnore] + private Transform moveToPoint; + + [Newtonsoft.Json.JsonIgnore] + private NavMeshAgent agent; + + private Vector3 lastDestination; + + public float destReachedThreshold; + + public MoveToNode(string name, int depth, int id) : base(name, depth, id) + {} + + public override void Initialize() + { + base.Initialize(); + agent = this.Manager.GetComponent(); + moveToPoint = GameObject.FindGameObjectWithTag("Player").transform; + } + + public override IObservable Start() + { + agent.SetDestination(moveToPoint.position); + return Observable + .Interval(TimeSpan.FromMilliseconds(TimeBetweenChecks)) + .TakeWhile(_ => !IsDestinationReached()) + .Select(x => + { + if (agent == null) + { + Debug.LogWarning("Unable to find agent in " + Name); + return Observable.Return(BehaviorState.Fail); + } + if (moveToPoint.position != lastDestination) + { + agent.SetDestination(moveToPoint.position); + lastDestination = moveToPoint.position; + } + return Observable.Return(BehaviorState.Running); + }) + .TakeLast(1) + .Select(x => BehaviorState.Success) + .Do(state => DebugLogAction(state)); + } + + bool IsDestinationReached() + { + return agent.remainingDistance <= destReachedThreshold; + } + } +} diff --git a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenEqualityComparer.cs.meta b/Assets/Scripts/AI/Nodes/MoveToNode.cs.meta similarity index 83% rename from Assets/Plugins/UniRx/Scripts/Async/CancellationTokenEqualityComparer.cs.meta rename to Assets/Scripts/AI/Nodes/MoveToNode.cs.meta index a4fe3fd..ce6c485 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenEqualityComparer.cs.meta +++ b/Assets/Scripts/AI/Nodes/MoveToNode.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7d739f510b125b74fa7290ac4335e46e +guid: 3039216464fbca94c862a91613378198 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Tree.meta b/Assets/Scripts/AI/Tree.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Tree.meta rename to Assets/Scripts/AI/Tree.meta index 4d10a58..4dcc80a 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Tree.meta +++ b/Assets/Scripts/AI/Tree.meta @@ -1,10 +1,10 @@ -fileFormatVersion: 2 -guid: f7b347696765a604987c3d6043bc5fd4 -folderAsset: yes -timeCreated: 1511756114 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: f7b347696765a604987c3d6043bc5fd4 +folderAsset: yes +timeCreated: 1511756114 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElement.cs b/Assets/Scripts/AI/Tree/TreeElement.cs similarity index 76% rename from Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElement.cs rename to Assets/Scripts/AI/Tree/TreeElement.cs index d5be763..09cdc5c 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElement.cs +++ b/Assets/Scripts/AI/Tree/TreeElement.cs @@ -1,63 +1,58 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace Assets.Scripts.AI.Tree -{ - [Serializable] - public class TreeElement - { - [SerializeField] int _ID; - [SerializeField] string _Name; - [SerializeField] int _Depth; - [NonSerialized] TreeElement _Parent; - [NonSerialized] List _Children; - - public int Depth - { - get { return _Depth; } - set { _Depth = value; } - } - - [JsonIgnore] - public TreeElement Parent - { - get { return _Parent; } - set { _Parent = value; } - } - - [JsonIgnore] - public List Children - { - get { return _Children; } - set { _Children = value; } - } - - public bool HasChildren - { - get { return Children != null && Children.Count > 0; } - } - - public string Name - { - get { return _Name; } set { _Name = value; } - } - - public int ID - { - get { return _ID; } set { _ID = value; } - } - - public TreeElement () - { - } - - public TreeElement (string name, int depth, int id) - { - _Name = name; - _ID = id; - _Depth = depth; - } - } -} +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Assets.Scripts.AI.Tree +{ + [Serializable] + public class TreeElement : ScriptableObject + { + [SerializeField] int _ID; + [SerializeField] string _Name; + [SerializeField] int _Depth; + [NonSerialized] TreeElement _Parent; + [NonSerialized] List _Children; + + [JsonIgnore] + public TreeElement Parent + { + get { return _Parent; } + set { _Parent = value; } + } + + [JsonIgnore] + public List Children + { + get { return _Children; } + set { _Children = value; } + } + + public bool HasChildren + { + get { return Children != null && Children.Count > 0; } + } + + public string Name + { + get { return _Name; } set { _Name = value; } + } + + public int ID + { + get { return _ID; } set { _ID = value; } + } + + public int Depth { get => _Depth; set => _Depth = value; } + + public TreeElement () + {} + + public TreeElement (string name, int depth, int id) + { + _Name = name; + _ID = id; + _Depth = depth; + } + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElement.cs.meta b/Assets/Scripts/AI/Tree/TreeElement.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElement.cs.meta rename to Assets/Scripts/AI/Tree/TreeElement.cs.meta index 05b01d6..fef8d17 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElement.cs.meta +++ b/Assets/Scripts/AI/Tree/TreeElement.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: 69be32fe4d27dde489209c5885c1e5dc -timeCreated: 1472024155 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 69be32fe4d27dde489209c5885c1e5dc +timeCreated: 1472024155 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElementUtility.cs b/Assets/Scripts/AI/Tree/TreeElementUtility.cs similarity index 96% rename from Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElementUtility.cs rename to Assets/Scripts/AI/Tree/TreeElementUtility.cs index 91901bc..9e24c11 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElementUtility.cs +++ b/Assets/Scripts/AI/Tree/TreeElementUtility.cs @@ -1,167 +1,167 @@ -using System; -using System.Collections.Generic; - -namespace Assets.Scripts.AI.Tree -{ - // TreeElementUtility and TreeElement are useful helper classes for backend tree data structures. - // See tests at the bottom for examples of how to use. - - public static class TreeElementUtility - { - public static void TreeToList(T root, IList result) where T : TreeElement - { - if (result == null) - throw new NullReferenceException("The input 'IList result' list is null"); - result.Clear(); - - Stack stack = new Stack(); - stack.Push(root); - - while (stack.Count > 0) - { - T current = stack.Pop(); - result.Add(current); - - if (current.Children != null) - { - for (int i = current.Children.Count - 1; i >= 0; i--) - { - stack.Push((T)current.Children[i]); - } - } - } - } - - // Returns the root of the tree parsed from the list (always the first element). - // Important: the first item is required to have a depth value of -1. - // The rest of the items should have depth >= 0. - public static T ListToTree(IList list) where T : TreeElement - { - // Validate input - ValidateDepthValues (list); - - // Clear old states - foreach (var element in list) - { - element.Parent = null; - element.Children = null; - } - - // Set child and parent references using depth info - for (int parentIndex = 0; parentIndex < list.Count; parentIndex++) - { - var parent = list[parentIndex]; - bool alreadyHasValidChildren = parent.Children != null; - if (alreadyHasValidChildren) - continue; - - int parentDepth = parent.Depth; - int childCount = 0; - - // Count children based depth value, we are looking at children until it's the same depth as this object - for (int i = parentIndex + 1; i < list.Count; i++) - { - if (list[i].Depth == parentDepth + 1) - childCount++; - if (list[i].Depth <= parentDepth) - break; - } - - // Fill child array - List childList = null; - if (childCount != 0) - { - childList = new List(childCount); // Allocate once - childCount = 0; - for (int i = parentIndex + 1; i < list.Count; i++) - { - if (list[i].Depth == parentDepth + 1) - { - list[i].Parent = parent; - childList.Add(list[i]); - childCount++; - } - - if (list[i].Depth <= parentDepth) - break; - } - } - parent.Children = childList; - } - return list[0]; - } - - // Check state of input list - public static void ValidateDepthValues(IList list) where T : TreeElement - { - if (list.Count == 0) - throw new ArgumentException("list should have items, count is 0, check before calling ValidateDepthValues", "list"); - - if (list[0].Depth != -1) - throw new ArgumentException("list item at index 0 should have a depth of -1 (since this should be the hidden root of the tree). Depth is: " + list[0].Depth, "list"); - - for (int i = 0; i < list.Count - 1; i++) - { - int depth = list[i].Depth; - int nextDepth = list[i + 1].Depth; - if (nextDepth > depth && nextDepth - depth > 1) - throw new ArgumentException(string.Format("Invalid depth info in input list. Depth cannot increase more than 1 per row. Index {0} has depth {1} while index {2} has depth {3}", i, depth, i + 1, nextDepth)); - } - - for (int i = 1; i < list.Count; ++i) - if (list[i].Depth < 0) - throw new ArgumentException("Invalid depth value for item at index " + i + ". Only the first item (the root) should have depth below 0."); - - if (list.Count > 1 && list[1].Depth != 0) - throw new ArgumentException("Input list item at index 1 is assumed to have a depth of 0", "list"); - } - - - // For updating depth values below any given element e.g after reparenting elements - public static void UpdateDepthValues(T root) where T : TreeElement - { - if (root == null) - throw new ArgumentNullException("root", "The root is null"); - - if (!root.HasChildren) - return; - - Stack stack = new Stack(); - stack.Push(root); - while (stack.Count > 0) - { - TreeElement current = stack.Pop(); - if (current.Children != null) - { - foreach (var child in current.Children) - { - child.Depth = current.Depth + 1; - stack.Push(child); - } - } - } - } - - // Returns true if there is an ancestor of child in the elements list - static bool IsChildOf(T child, IList elements) where T : TreeElement - { - while (child != null) - { - child = (T)child.Parent; - if (elements.Contains(child)) - return true; - } - return false; - } - - public static IList FindCommonAncestorsWithinList(IList elements) where T : TreeElement - { - if (elements.Count == 1) - return new List(elements); - - List result = new List(elements); - result.RemoveAll(g => IsChildOf(g, elements)); - return result; - } - } -} +using System; +using System.Collections.Generic; + +namespace Assets.Scripts.AI.Tree +{ + // TreeElementUtility and TreeElement are useful helper classes for backend tree data structures. + // See tests at the bottom for examples of how to use. + + public static class TreeElementUtility + { + public static void TreeToList(T root, IList result) where T : TreeElement + { + if (result == null) + throw new NullReferenceException("The input 'IList result' list is null"); + result.Clear(); + + Stack stack = new Stack(); + stack.Push(root); + + while (stack.Count > 0) + { + T current = stack.Pop(); + result.Add(current); + + if (current.Children != null) + { + for (int i = current.Children.Count - 1; i >= 0; i--) + { + stack.Push((T)current.Children[i]); + } + } + } + } + + // Returns the root of the tree parsed from the list (always the first element). + // Important: the first item is required to have a depth value of -1. + // The rest of the items should have depth >= 0. + public static T ListToTree(IList list) where T : TreeElement + { + // Validate input + ValidateDepthValues (list); + + // Clear old states + foreach (var element in list) + { + element.Parent = null; + element.Children = null; + } + + // Set child and parent references using depth info + for (int parentIndex = 0; parentIndex < list.Count; parentIndex++) + { + var parent = list[parentIndex]; + bool alreadyHasValidChildren = parent.Children != null; + if (alreadyHasValidChildren) + continue; + + int parentDepth = parent.Depth; + int childCount = 0; + + // Count children based depth value, we are looking at children until it's the same depth as this object + for (int i = parentIndex + 1; i < list.Count; i++) + { + if (list[i].Depth == parentDepth + 1) + childCount++; + if (list[i].Depth <= parentDepth) + break; + } + + // Fill child array + List childList = null; + if (childCount != 0) + { + childList = new List(childCount); // Allocate once + childCount = 0; + for (int i = parentIndex + 1; i < list.Count; i++) + { + if (list[i].Depth == parentDepth + 1) + { + list[i].Parent = parent; + childList.Add(list[i]); + childCount++; + } + + if (list[i].Depth <= parentDepth) + break; + } + } + parent.Children = childList; + } + return list[0]; + } + + // Check state of input list + public static void ValidateDepthValues(IList list) where T : TreeElement + { + if (list.Count == 0) + throw new ArgumentException("list should have items, count is 0, check before calling ValidateDepthValues", "list"); + + if (list[0].Depth != -1) + throw new ArgumentException("list item at index 0 should have a depth of -1 (since this should be the hidden root of the tree). Depth is: " + list[0].Depth, "list"); + + for (int i = 0; i < list.Count - 1; i++) + { + int depth = list[i].Depth; + int nextDepth = list[i + 1].Depth; + if (nextDepth > depth && nextDepth - depth > 1) + throw new ArgumentException(string.Format("Invalid depth info in input list. Depth cannot increase more than 1 per row. Index {0} has depth {1} while index {2} has depth {3}", i, depth, i + 1, nextDepth)); + } + + for (int i = 1; i < list.Count; ++i) + if (list[i].Depth < 0) + throw new ArgumentException("Invalid depth value for item at index " + i + ". Only the first item (the root) should have depth below 0."); + + if (list.Count > 1 && list[1].Depth != 0) + throw new ArgumentException("Input list item at index 1 is assumed to have a depth of 0", "list"); + } + + + // For updating depth values below any given element e.g after reparenting elements + public static void UpdateDepthValues(T root) where T : TreeElement + { + if (root == null) + throw new ArgumentNullException("root", "The root is null"); + + if (!root.HasChildren) + return; + + Stack stack = new Stack(); + stack.Push(root); + while (stack.Count > 0) + { + TreeElement current = stack.Pop(); + if (current.Children != null) + { + foreach (var child in current.Children) + { + child.Depth = current.Depth + 1; + stack.Push(child); + } + } + } + } + + // Returns true if there is an ancestor of child in the elements list + static bool IsChildOf(T child, IList elements) where T : TreeElement + { + while (child != null) + { + child = (T)child.Parent; + if (elements.Contains(child)) + return true; + } + return false; + } + + public static IList FindCommonAncestorsWithinList(IList elements) where T : TreeElement + { + if (elements.Count == 1) + return new List(elements); + + List result = new List(elements); + result.RemoveAll(g => IsChildOf(g, elements)); + return result; + } + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElementUtility.cs.meta b/Assets/Scripts/AI/Tree/TreeElementUtility.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElementUtility.cs.meta rename to Assets/Scripts/AI/Tree/TreeElementUtility.cs.meta index 12d8902..7ecc88f 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeElementUtility.cs.meta +++ b/Assets/Scripts/AI/Tree/TreeElementUtility.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: fd65e8f324e17a344a97ddcf5a8d89d2 -timeCreated: 1471616285 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: fd65e8f324e17a344a97ddcf5a8d89d2 +timeCreated: 1471616285 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeModel.cs b/Assets/Scripts/AI/Tree/TreeModel.cs similarity index 96% rename from Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeModel.cs rename to Assets/Scripts/AI/Tree/TreeModel.cs index 906685a..2ad32b5 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeModel.cs +++ b/Assets/Scripts/AI/Tree/TreeModel.cs @@ -1,294 +1,294 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Assets.Scripts.AI.Tree -{ - // The TreeModel is a utility class working on a list of serializable TreeElements where the order and the depth of each TreeElement define - // the tree structure. Note that the TreeModel itself is not serializable (in Unity we are currently limited to serializing lists/arrays) but the - // input list is. - // The tree representation (parent and children references) are then build internally using TreeElementUtility.ListToTree (using depth - // values of the elements). - // The first element of the input list is required to have depth == -1 (the hiddenroot) and the rest to have - // depth >= 0 (otherwise an exception will be thrown) - - public class TreeModel where T : TreeElement - { - IList m_Data; - T m_Root; - int m_MaxID; - - public T Root { get { return m_Root; } set { m_Root = value; } } - public event Action ModelChanged; - public int NumberOfDataElements - { - get { return m_Data.Count; } - } - - public TreeModel (IList data) - { - SetData (data); - } - - public T Find (int id) - { - return m_Data.FirstOrDefault (element => element.ID == id); - } - - public void SetData (IList data) - { - Init (data); - } - - void Init (IList data) - { - if (data == null) - throw new ArgumentNullException("data", "Input data is null. Ensure input is a non-null list."); - - m_Data = data; - if (m_Data.Count > 0) - { - m_Root = TreeElementUtility.ListToTree(data); - m_MaxID = m_Data.Max(e => e.ID); - } - else - { - m_MaxID = -1; - } - - } - - public int GenerateUniqueID () - { - return ++m_MaxID; - } - - public IList GetAncestors (int id) - { - var parents = new List(); - TreeElement T = Find(id); - if (T != null) - { - while (T.Parent != null) - { - parents.Add(T.Parent.ID); - T = T.Parent; - } - } - return parents; - } - - public IList GetDescendantsThatHaveChildren (int id) - { - T searchFromThis = Find(id); - if (searchFromThis != null) - { - return GetParentsBelowStackBased(searchFromThis); - } - return new List(); - } - - IList GetParentsBelowStackBased(TreeElement searchFromThis) - { - Stack stack = new Stack(); - stack.Push(searchFromThis); - - var parentsBelow = new List(); - while (stack.Count > 0) - { - TreeElement current = stack.Pop(); - if (current.HasChildren) - { - parentsBelow.Add(current.ID); - foreach (var T in current.Children) - { - stack.Push(T); - } - } - } - - return parentsBelow; - } - - public void RemoveElements (IList elementIDs) - { - IList elements = m_Data.Where (element => elementIDs.Contains (element.ID)).ToArray (); - RemoveElements (elements); - } - - public void RemoveElements (IList elements) - { - foreach (var element in elements) - if (element == m_Root) - throw new ArgumentException("It is not allowed to remove the root element"); - - var commonAncestors = TreeElementUtility.FindCommonAncestorsWithinList (elements); - - foreach (var element in commonAncestors) - { - element.Parent.Children.Remove (element); - element.Parent = null; - } - - TreeElementUtility.TreeToList(m_Root, m_Data); - - Changed(); - } - - public void AddElements (IList elements, TreeElement parent, int insertPosition) - { - if (elements == null) - throw new ArgumentNullException("elements", "elements is null"); - if (elements.Count == 0) - throw new ArgumentNullException("elements", "elements Count is 0: nothing to add"); - if (parent == null) - throw new ArgumentNullException("parent", "parent is null"); - - if (parent.Children == null) - parent.Children = new List(); - - parent.Children.InsertRange(insertPosition, elements.Cast ()); - foreach (var element in elements) - { - element.Parent = parent; - element.Depth = parent.Depth + 1; - TreeElementUtility.UpdateDepthValues(element); - } - - TreeElementUtility.TreeToList(m_Root, m_Data); - - Changed(); - } - - public void AddRoot (T root) - { - if (root == null) - throw new ArgumentNullException("root", "root is null"); - - if (m_Data == null) - throw new InvalidOperationException("Internal Error: data list is null"); - - if (m_Data.Count != 0) - throw new InvalidOperationException("AddRoot is only allowed on empty data list"); - - root.ID = GenerateUniqueID (); - root.Depth = -1; - m_Data.Add (root); - } - - public void AddElement (T element, TreeElement parent, int insertPosition) - { - if (element == null) - throw new ArgumentNullException("element", "element is null"); - if (parent == null) - throw new ArgumentNullException("parent", "parent is null"); - - if (parent.Children == null) - parent.Children = new List (); - - parent.Children.Insert (insertPosition, element); - element.Parent = parent; - - TreeElementUtility.UpdateDepthValues(parent); - TreeElementUtility.TreeToList(m_Root, m_Data); - - Changed (); - } - - public void MoveElements(TreeElement parentElement, int insertionIndex, List elements) - { - if (insertionIndex < 0) - throw new ArgumentException("Invalid input: insertionIndex is -1, client needs to decide what index elements should be reparented at"); - - // Invalid reparenting input - if (parentElement == null) - return; - - // We are moving items so we adjust the insertion index to accomodate that any items above the insertion index is removed before inserting - if (insertionIndex > 0) - insertionIndex -= parentElement.Children.GetRange(0, insertionIndex).Count(elements.Contains); - - // Remove draggedItems from their parents - foreach (var draggedItem in elements) - { - draggedItem.Parent.Children.Remove(draggedItem); // remove from old parent - draggedItem.Parent = parentElement; // set new parent - } - - if (parentElement.Children == null) - parentElement.Children = new List(); - - // Insert dragged items under new parent - parentElement.Children.InsertRange(insertionIndex, elements); - - TreeElementUtility.UpdateDepthValues (Root); - TreeElementUtility.TreeToList (m_Root, m_Data); - - Changed (); - } - - void Changed () - { - if(ModelChanged != null) - { - ModelChanged.Invoke(); - } - } - } - - - //#region Tests - //class TreeModelTests - //{ - // [Test] - // public static void TestTreeModelCanAddElements() - // { - // var root = new TreeElement {Name = "Root", Depth = -1}; - // var listOfElements = new List(); - // listOfElements.Add(root); - - // var model = new TreeModel(listOfElements); - // model.AddElement(new TreeElement { Name = "Element" }, root, 0); - // model.AddElement(new TreeElement { Name = "Element " + root.Children.Count }, root, 0); - // model.AddElement(new TreeElement { Name = "Element " + root.Children.Count }, root, 0); - // model.AddElement(new TreeElement { Name = "Sub Element" }, root.Children[1], 0); - - // // Assert order is correct - // string[] namesInCorrectOrder = { "Root", "Element 2", "Element 1", "Sub Element", "Element" }; - // Assert.AreEqual(namesInCorrectOrder.Length, listOfElements.Count, "Result count does not match"); - // for (int i = 0; i < namesInCorrectOrder.Length; ++i) - // Assert.AreEqual(namesInCorrectOrder[i], listOfElements[i].Name); - - // // Assert depths are valid - // TreeElementUtility.ValidateDepthValues(listOfElements); - // } - - // [Test] - // public static void TestTreeModelCanRemoveElements() - // { - // var root = new TreeElement { Name = "Root", Depth = -1 }; - // var listOfElements = new List(); - // listOfElements.Add(root); - - // var model = new TreeModel(listOfElements); - // model.AddElement(new TreeElement { Name = "Element" }, root, 0); - // model.AddElement(new TreeElement { Name = "Element " + root.Children.Count }, root, 0); - // model.AddElement(new TreeElement { Name = "Element " + root.Children.Count }, root, 0); - // model.AddElement(new TreeElement { Name = "Sub Element" }, root.Children[1], 0); - - // model.RemoveElements(new[] { root.Children[1].Children[0], root.Children[1] }); - - // // Assert order is correct - // string[] namesInCorrectOrder = { "Root", "Element 2", "Element" }; - // Assert.AreEqual(namesInCorrectOrder.Length, listOfElements.Count, "Result count does not match"); - // for (int i = 0; i < namesInCorrectOrder.Length; ++i) - // Assert.AreEqual(namesInCorrectOrder[i], listOfElements[i].Name); - - // // Assert depths are valid - // TreeElementUtility.ValidateDepthValues(listOfElements); - // } - //} - - //#endregion - -} +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Assets.Scripts.AI.Tree +{ + // The TreeModel is a utility class working on a list of serializable TreeElements where the order and the depth of each TreeElement define + // the tree structure. Note that the TreeModel itself is not serializable (in Unity we are currently limited to serializing lists/arrays) but the + // input list is. + // The tree representation (parent and children references) are then build internally using TreeElementUtility.ListToTree (using depth + // values of the elements). + // The first element of the input list is required to have depth == -1 (the hiddenroot) and the rest to have + // depth >= 0 (otherwise an exception will be thrown) + + public class TreeModel where T : TreeElement + { + IList m_Data; + T m_Root; + int m_MaxID; + + public T Root { get { return m_Root; } set { m_Root = value; } } + public event Action ModelChanged; + public int NumberOfDataElements + { + get { return m_Data.Count; } + } + + public TreeModel (IList data) + { + SetData (data); + } + + public T Find (int id) + { + return m_Data.FirstOrDefault (element => element.ID == id); + } + + public void SetData (IList data) + { + Init (data); + } + + void Init (IList data) + { + if (data == null) + throw new ArgumentNullException("data", "Input data is null. Ensure input is a non-null list."); + + m_Data = data; + if (m_Data.Count > 0) + { + m_Root = TreeElementUtility.ListToTree(data); + m_MaxID = m_Data.Max(e => e.ID); + } + else + { + m_MaxID = -1; + } + + } + + public int GenerateUniqueID () + { + return ++m_MaxID; + } + + public IList GetAncestors (int id) + { + var parents = new List(); + TreeElement T = Find(id); + if (T != null) + { + while (T.Parent != null) + { + parents.Add(T.Parent.ID); + T = T.Parent; + } + } + return parents; + } + + public IList GetDescendantsThatHaveChildren (int id) + { + T searchFromThis = Find(id); + if (searchFromThis != null) + { + return GetParentsBelowStackBased(searchFromThis); + } + return new List(); + } + + IList GetParentsBelowStackBased(TreeElement searchFromThis) + { + Stack stack = new Stack(); + stack.Push(searchFromThis); + + var parentsBelow = new List(); + while (stack.Count > 0) + { + TreeElement current = stack.Pop(); + if (current.HasChildren) + { + parentsBelow.Add(current.ID); + foreach (var T in current.Children) + { + stack.Push(T); + } + } + } + + return parentsBelow; + } + + public void RemoveElements (IList elementIDs) + { + IList elements = m_Data.Where (element => elementIDs.Contains (element.ID)).ToArray (); + RemoveElements (elements); + } + + public void RemoveElements (IList elements) + { + foreach (var element in elements) + if (element == m_Root) + throw new ArgumentException("It is not allowed to remove the root element"); + + var commonAncestors = TreeElementUtility.FindCommonAncestorsWithinList (elements); + + foreach (var element in commonAncestors) + { + element.Parent.Children.Remove (element); + element.Parent = null; + } + + TreeElementUtility.TreeToList(m_Root, m_Data); + + Changed(); + } + + public void AddElements (IList elements, TreeElement parent, int insertPosition) + { + if (elements == null) + throw new ArgumentNullException("elements", "elements is null"); + if (elements.Count == 0) + throw new ArgumentNullException("elements", "elements Count is 0: nothing to add"); + if (parent == null) + throw new ArgumentNullException("parent", "parent is null"); + + if (parent.Children == null) + parent.Children = new List(); + + parent.Children.InsertRange(insertPosition, elements.Cast ()); + foreach (var element in elements) + { + element.Parent = parent; + element.Depth = parent.Depth + 1; + TreeElementUtility.UpdateDepthValues(element); + } + + TreeElementUtility.TreeToList(m_Root, m_Data); + + Changed(); + } + + public void AddRoot (T root) + { + if (root == null) + throw new ArgumentNullException("root", "root is null"); + + if (m_Data == null) + throw new InvalidOperationException("Internal Error: data list is null"); + + if (m_Data.Count != 0) + throw new InvalidOperationException("AddRoot is only allowed on empty data list"); + + root.ID = GenerateUniqueID (); + root.Depth = -1; + m_Data.Add (root); + } + + public void AddElement (T element, TreeElement parent, int insertPosition) + { + if (element == null) + throw new ArgumentNullException("element", "element is null"); + if (parent == null) + throw new ArgumentNullException("parent", "parent is null"); + + if (parent.Children == null) + parent.Children = new List (); + + parent.Children.Insert (insertPosition, element); + element.Parent = parent; + + TreeElementUtility.UpdateDepthValues(parent); + TreeElementUtility.TreeToList(m_Root, m_Data); + + Changed (); + } + + public void MoveElements(TreeElement parentElement, int insertionIndex, List elements) + { + if (insertionIndex < 0) + throw new ArgumentException("Invalid input: insertionIndex is -1, client needs to decide what index elements should be reparented at"); + + // Invalid reparenting input + if (parentElement == null) + return; + + // We are moving items so we adjust the insertion index to accomodate that any items above the insertion index is removed before inserting + if (insertionIndex > 0) + insertionIndex -= parentElement.Children.GetRange(0, insertionIndex).Count(elements.Contains); + + // Remove draggedItems from their parents + foreach (var draggedItem in elements) + { + draggedItem.Parent.Children.Remove(draggedItem); // remove from old parent + draggedItem.Parent = parentElement; // set new parent + } + + if (parentElement.Children == null) + parentElement.Children = new List(); + + // Insert dragged items under new parent + parentElement.Children.InsertRange(insertionIndex, elements); + + TreeElementUtility.UpdateDepthValues (Root); + TreeElementUtility.TreeToList (m_Root, m_Data); + + Changed (); + } + + void Changed () + { + if(ModelChanged != null) + { + ModelChanged.Invoke(); + } + } + } + + + //#region Tests + //class TreeModelTests + //{ + // [Test] + // public static void TestTreeModelCanAddElements() + // { + // var root = new TreeElement {Name = "Root", Depth = -1}; + // var listOfElements = new List(); + // listOfElements.Add(root); + + // var model = new TreeModel(listOfElements); + // model.AddElement(new TreeElement { Name = "Element" }, root, 0); + // model.AddElement(new TreeElement { Name = "Element " + root.Children.Count }, root, 0); + // model.AddElement(new TreeElement { Name = "Element " + root.Children.Count }, root, 0); + // model.AddElement(new TreeElement { Name = "Sub Element" }, root.Children[1], 0); + + // // Assert order is correct + // string[] namesInCorrectOrder = { "Root", "Element 2", "Element 1", "Sub Element", "Element" }; + // Assert.AreEqual(namesInCorrectOrder.Length, listOfElements.Count, "Result count does not match"); + // for (int i = 0; i < namesInCorrectOrder.Length; ++i) + // Assert.AreEqual(namesInCorrectOrder[i], listOfElements[i].Name); + + // // Assert depths are valid + // TreeElementUtility.ValidateDepthValues(listOfElements); + // } + + // [Test] + // public static void TestTreeModelCanRemoveElements() + // { + // var root = new TreeElement { Name = "Root", Depth = -1 }; + // var listOfElements = new List(); + // listOfElements.Add(root); + + // var model = new TreeModel(listOfElements); + // model.AddElement(new TreeElement { Name = "Element" }, root, 0); + // model.AddElement(new TreeElement { Name = "Element " + root.Children.Count }, root, 0); + // model.AddElement(new TreeElement { Name = "Element " + root.Children.Count }, root, 0); + // model.AddElement(new TreeElement { Name = "Sub Element" }, root.Children[1], 0); + + // model.RemoveElements(new[] { root.Children[1].Children[0], root.Children[1] }); + + // // Assert order is correct + // string[] namesInCorrectOrder = { "Root", "Element 2", "Element" }; + // Assert.AreEqual(namesInCorrectOrder.Length, listOfElements.Count, "Result count does not match"); + // for (int i = 0; i < namesInCorrectOrder.Length; ++i) + // Assert.AreEqual(namesInCorrectOrder[i], listOfElements[i].Name); + + // // Assert depths are valid + // TreeElementUtility.ValidateDepthValues(listOfElements); + // } + //} + + //#endregion + +} diff --git a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeModel.cs.meta b/Assets/Scripts/AI/Tree/TreeModel.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeModel.cs.meta rename to Assets/Scripts/AI/Tree/TreeModel.cs.meta index 0ee779c..966a8ac 100644 --- a/Assets/Visual Behavior Tree/Scripts/AI/Tree/TreeModel.cs.meta +++ b/Assets/Scripts/AI/Tree/TreeModel.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: 6f9fab1cf2636a6439c644bf08108abb -timeCreated: 1472122507 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 6f9fab1cf2636a6439c644bf08108abb +timeCreated: 1472122507 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Scripts/BehaviorReactiveExtensions.cs b/Assets/Scripts/BehaviorReactiveExtensions.cs similarity index 97% rename from Assets/Visual Behavior Tree/Scripts/BehaviorReactiveExtensions.cs rename to Assets/Scripts/BehaviorReactiveExtensions.cs index 4f82cde..6855692 100644 --- a/Assets/Visual Behavior Tree/Scripts/BehaviorReactiveExtensions.cs +++ b/Assets/Scripts/BehaviorReactiveExtensions.cs @@ -1,37 +1,37 @@ -using Assets.Scripts.AI; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UniRx; - -namespace Assets.Visual_Behavior_Tree.Scripts -{ - public static class BehaviorReactiveExtensions - { - public static IObservable Publish( - this IObservable source, Func, IObservable> selector) - { - return Observable.CreateSafe((IObserver observer) => - { - var s = source.Publish(); - var p = selector(s).Subscribe(observer); - return new CompositeDisposable(p, s.Connect()); - }); - } - - public static IObservable TakeWhileInclusive( - this IObservable source, Func predicate) - { - return source.Publish(co => co.TakeWhile(predicate) - .Merge(co.SkipWhile(predicate) - .Take(1))); - } - - public static IObservable Any(this IObservable source, Func predicate) - { - return source.Where(predicate).Select(e => true).Concat(Observable.Return(false)).Take(1); - } - } -} +using Assets.Scripts.AI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UniRx; + +namespace Assets.Visual_Behavior_Tree.Scripts +{ + public static class BehaviorReactiveExtensions + { + public static IObservable Publish( + this IObservable source, Func, IObservable> selector) + { + return Observable.CreateSafe((IObserver observer) => + { + var s = source.Publish(); + var p = selector(s).Subscribe(observer); + return new CompositeDisposable(p, s.Connect()); + }); + } + + public static IObservable TakeWhileInclusive( + this IObservable source, Func predicate) + { + return source.Publish(co => co.TakeWhile(predicate) + .Merge(co.SkipWhile(predicate) + .Take(1))); + } + + public static IObservable Any(this IObservable source, Func predicate) + { + return source.Where(predicate).Select(e => true).Concat(Observable.Return(false)).Take(1); + } + } +} diff --git a/Assets/Visual Behavior Tree/Scripts/BehaviorReactiveExtensions.cs.meta b/Assets/Scripts/BehaviorReactiveExtensions.cs.meta similarity index 100% rename from Assets/Visual Behavior Tree/Scripts/BehaviorReactiveExtensions.cs.meta rename to Assets/Scripts/BehaviorReactiveExtensions.cs.meta diff --git a/Assets/Scripts/TreeNodeAsset.cs b/Assets/Scripts/TreeNodeAsset.cs new file mode 100644 index 0000000..375dd96 --- /dev/null +++ b/Assets/Scripts/TreeNodeAsset.cs @@ -0,0 +1,39 @@ +using Assets.Scripts.AI; +using Assets.Scripts.AI.Tree; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace Assets.Visual_Behavior_Tree.Scripts +{ + public class TreeNodeAsset : ScriptableObject + { + public List positions; + + public string treeElements; + } + + public static class AssetExtensions + { + public static BehaviorTreeElement LoadRoot(this TreeNodeAsset asset) + { + var elements = JsonConvert.DeserializeObject>(asset.treeElements); + + var behaviorElements = new List(); + foreach (dynamic el in elements) + { + string typeName = el.ElementType; + Type type = Assembly.GetAssembly(typeof(BehaviorTreeElement)).GetType(typeName); + dynamic newBehavior = Activator.CreateInstance(type, (string)el.Name, (int)el.Depth, (int)el.ID); + JsonConvert.PopulateObject(JsonConvert.SerializeObject(el), newBehavior); + behaviorElements.Add(newBehavior); + } + return TreeElementUtility.ListToTree(behaviorElements); + } + } +} diff --git a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenExtensions.cs.meta b/Assets/Scripts/TreeNodeAsset.cs.meta similarity index 83% rename from Assets/Plugins/UniRx/Scripts/Async/CancellationTokenExtensions.cs.meta rename to Assets/Scripts/TreeNodeAsset.cs.meta index 28a6958..e25a651 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenExtensions.cs.meta +++ b/Assets/Scripts/TreeNodeAsset.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4be7209f04146bd45ac5ee775a5f7c26 +guid: b7130206f8e2d7e4b94035cb63f37007 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/TestScene.meta b/Assets/TestScene.meta new file mode 100644 index 0000000..fec7342 --- /dev/null +++ b/Assets/TestScene.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5697b8d8d1200ce4a90f1a4dd9370305 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TestScene.unity b/Assets/TestScene.unity index 1cbd18a..04ae904 100644 --- a/Assets/TestScene.unity +++ b/Assets/TestScene.unity @@ -38,24 +38,23 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1} + m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 - serializedVersion: 11 + serializedVersion: 12 m_GIWorkflowMode: 0 m_GISettings: serializedVersion: 2 m_BounceScale: 1 m_IndirectOutputScale: 1 m_AlbedoBoost: 1 - m_TemporalCoherenceThreshold: 1 m_EnvironmentLightingMode: 0 m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 10 + serializedVersion: 12 m_Resolution: 2 m_BakeResolution: 40 m_AtlasSize: 1024 @@ -63,6 +62,7 @@ LightmapSettings: m_AOMaxDistance: 1 m_CompAOExponent: 1 m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 m_Padding: 2 m_LightmapParameters: {fileID: 0} m_LightmapsBakeMode: 1 @@ -77,10 +77,16 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 500 m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 m_PVRFilterTypeDirect: 0 m_PVRFilterTypeIndirect: 0 m_PVRFilterTypeAO: 0 - m_PVRFilteringMode: 1 + m_PVREnvironmentMIS: 0 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 m_PVRFilteringGaussRadiusIndirect: 5 @@ -88,9 +94,12 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 m_LightingDataAsset: {fileID: 0} - m_UseShadowmask: 1 + m_LightingSettings: {fileID: 4890085278179872738, guid: c6eb88022a890e1469fec23a151ba963, + type: 2} --- !u!196 &4 NavMeshSettings: serializedVersion: 2 @@ -110,14 +119,17 @@ NavMeshSettings: manualTileSize: 0 tileSize: 256 accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 debug: m_Flags: 0 - m_NavMeshData: {fileID: 0} + m_NavMeshData: {fileID: 23800000, guid: 2b940fadc4be91f4abaa36dd9487eacd, type: 2} --- !u!1 &132278577 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 132278582} @@ -125,6 +137,7 @@ GameObject: - component: {fileID: 132278580} - component: {fileID: 132278579} - component: {fileID: 132278578} + - component: {fileID: 132278583} m_Layer: 0 m_Name: Enemy 2 m_TagString: Untagged @@ -136,23 +149,24 @@ GameObject: MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 132278577} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 73bc91841bad4424992751c051af5030, type: 3} m_Name: m_EditorClassIdentifier: - BehaviorTreeFile: {fileID: 11400000, guid: f4cb4c96e175fa243baf0700d4057360, type: 2} - MilliSecondsBetweenTicks: 10000 - TimesToTick: -1 - spliceNewIntoTree: 0 - SpliceList: [] + BehaviorTreeFiles: + - {fileID: 11400000, guid: 47aa65c014fca5c4b84622b79234ac8b, type: 2} + MilliSecondsBetweenTicks: 100 + TimesToTick: 1 --- !u!23 &132278579 MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 132278577} m_Enabled: 1 m_CastShadows: 1 @@ -161,7 +175,10 @@ MeshRenderer: m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 4294967295 + m_RendererPriority: 0 m_Materials: - {fileID: 2100000, guid: e57457a42a153bd4894a06d8105866c5, type: 2} m_StaticBatchInfo: @@ -171,6 +188,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 1 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -183,11 +201,13 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!65 &132278580 BoxCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 132278577} m_Material: {fileID: 0} m_IsTrigger: 0 @@ -199,14 +219,16 @@ BoxCollider: MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 132278577} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!4 &132278582 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 132278577} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 37.41, y: 0.5, z: 23.24} @@ -215,11 +237,34 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!195 &132278583 +NavMeshAgent: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 132278577} + m_Enabled: 1 + m_AgentTypeID: 0 + m_Radius: 0.5 + m_Speed: 3.5 + m_Acceleration: 8 + avoidancePriority: 50 + m_AngularSpeed: 120 + m_StoppingDistance: 0 + m_AutoTraverseOffMeshLink: 1 + m_AutoBraking: 1 + m_AutoRepath: 1 + m_Height: 1 + m_BaseOffset: 0.5 + m_WalkableMask: 4294967295 + m_ObstacleAvoidanceType: 4 --- !u!1 &271199282 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 271199288} @@ -238,27 +283,32 @@ GameObject: AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 271199282} m_Enabled: 1 --- !u!124 &271199285 Behaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 271199282} m_Enabled: 1 --- !u!20 &271199287 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 271199282} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 2 m_BackGroundColor: {r: 0.15084341, g: 0.18082586, b: 0.22794116, a: 0} m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} m_FocalLength: 50 @@ -292,7 +342,8 @@ Camera: Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 271199282} m_LocalRotation: {x: 0.2164396, y: -0, z: -0, w: 0.97629607} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -305,7 +356,8 @@ Transform: MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 271199282} m_Enabled: 1 m_EditorHideFlags: 0 @@ -317,7 +369,8 @@ MonoBehaviour: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 374731286} @@ -325,6 +378,7 @@ GameObject: - component: {fileID: 374731284} - component: {fileID: 374731283} - component: {fileID: 374731287} + - component: {fileID: 374731288} m_Layer: 0 m_Name: Enemy m_TagString: Untagged @@ -336,7 +390,8 @@ GameObject: MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 374731282} m_Enabled: 1 m_CastShadows: 1 @@ -345,7 +400,10 @@ MeshRenderer: m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 4294967295 + m_RendererPriority: 0 m_Materials: - {fileID: 2100000, guid: e57457a42a153bd4894a06d8105866c5, type: 2} m_StaticBatchInfo: @@ -355,6 +413,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 1 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -367,11 +426,13 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!65 &374731284 BoxCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 374731282} m_Material: {fileID: 0} m_IsTrigger: 0 @@ -383,14 +444,16 @@ BoxCollider: MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 374731282} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!4 &374731286 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 374731282} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 30, y: 0.5, z: 30} @@ -403,23 +466,46 @@ Transform: MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 374731282} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 73bc91841bad4424992751c051af5030, type: 3} m_Name: m_EditorClassIdentifier: - BehaviorTreeFile: {fileID: 11400000, guid: f4cb4c96e175fa243baf0700d4057360, type: 2} + BehaviorTreeFiles: + - {fileID: 11400000, guid: 47aa65c014fca5c4b84622b79234ac8b, type: 2} MilliSecondsBetweenTicks: 1000 - TimesToTick: -1 - spliceNewIntoTree: 0 - SpliceList: [] + TimesToTick: 1 +--- !u!195 &374731288 +NavMeshAgent: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 374731282} + m_Enabled: 1 + m_AgentTypeID: 0 + m_Radius: 0.5 + m_Speed: 3.5 + m_Acceleration: 8 + avoidancePriority: 50 + m_AngularSpeed: 120 + m_StoppingDistance: 0 + m_AutoTraverseOffMeshLink: 1 + m_AutoBraking: 1 + m_AutoRepath: 1 + m_Height: 1 + m_BaseOffset: 0.5 + m_WalkableMask: 4294967295 + m_ObstacleAvoidanceType: 4 --- !u!1 &761835721 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 761835725} @@ -438,7 +524,8 @@ GameObject: MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 761835721} m_Enabled: 1 m_CastShadows: 1 @@ -447,7 +534,10 @@ MeshRenderer: m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 4294967295 + m_RendererPriority: 0 m_Materials: - {fileID: 2100000, guid: e57457a42a153bd4894a06d8105866c5, type: 2} m_StaticBatchInfo: @@ -457,6 +547,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 0 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -469,11 +560,13 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!143 &761835723 CharacterController: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 761835721} m_Material: {fileID: 0} m_IsTrigger: 0 @@ -490,17 +583,19 @@ CharacterController: MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 761835721} m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} --- !u!4 &761835725 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 761835721} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 8, y: 1, z: 10} + m_LocalPosition: {x: 8, y: 1.5, z: 10} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 271199288} @@ -511,7 +606,8 @@ Transform: MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 761835721} m_Enabled: 1 m_EditorHideFlags: 0 @@ -524,7 +620,8 @@ MonoBehaviour: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 1302823950} @@ -540,7 +637,8 @@ GameObject: Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1302823949} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -553,7 +651,8 @@ Transform: MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1302823949} m_Enabled: 1 m_EditorHideFlags: 0 @@ -564,7 +663,8 @@ MonoBehaviour: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 1669096003} @@ -580,15 +680,18 @@ GameObject: Light: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1669096001} m_Enabled: 1 - serializedVersion: 8 + serializedVersion: 10 m_Type: 1 + m_Shape: 0 m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} m_Intensity: 0.5 m_Range: 10 m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 m_CookieSize: 10 m_Shadows: m_Type: 2 @@ -598,6 +701,24 @@ Light: m_Bias: 0 m_NormalBias: 0.83 m_NearPlane: 0.1 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 m_Cookie: {fileID: 0} m_DrawHalo: 0 m_Flare: {fileID: 0} @@ -605,19 +726,23 @@ Light: m_CullingMask: serializedVersion: 2 m_Bits: 4294967295 + m_RenderingLayerMask: 1 m_Lightmapping: 1 m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 m_ColorTemperature: 6570 m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!4 &1669096003 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1669096001} m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 25.01, y: 27.58, z: 4.71} @@ -630,7 +755,8 @@ Transform: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 1735717992} @@ -648,7 +774,8 @@ GameObject: MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1735717988} m_Enabled: 1 m_CastShadows: 1 @@ -657,7 +784,10 @@ MeshRenderer: m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 m_RenderingLayerMask: 4294967295 + m_RendererPriority: 0 m_Materials: - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} m_StaticBatchInfo: @@ -667,6 +797,7 @@ MeshRenderer: m_ProbeAnchor: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0} m_ScaleInLightmap: 1 + m_ReceiveGI: 1 m_PreserveUVs: 1 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 @@ -679,11 +810,13 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!65 &1735717990 BoxCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1735717988} m_Material: {fileID: 0} m_IsTrigger: 0 @@ -695,14 +828,16 @@ BoxCollider: MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1735717988} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!4 &1735717992 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1735717988} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 26, y: 0, z: 26} @@ -715,7 +850,8 @@ Transform: GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - component: {fileID: 1865069244} @@ -730,7 +866,8 @@ GameObject: Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1865069242} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 11.206564, y: -4.905942, z: 15.366896} diff --git a/Assets/TestScene/NavMesh.asset b/Assets/TestScene/NavMesh.asset new file mode 100644 index 0000000..6dbef7d Binary files /dev/null and b/Assets/TestScene/NavMesh.asset differ diff --git a/Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 2.asset.meta b/Assets/TestScene/NavMesh.asset.meta similarity index 64% rename from Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 2.asset.meta rename to Assets/TestScene/NavMesh.asset.meta index 358b714..04298ba 100644 --- a/Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 2.asset.meta +++ b/Assets/TestScene/NavMesh.asset.meta @@ -1,8 +1,8 @@ fileFormatVersion: 2 -guid: 65b380827923ec54a9e62d5a93692437 +guid: 2b940fadc4be91f4abaa36dd9487eacd NativeFormatImporter: externalObjects: {} - mainObjectFileID: 11400000 + mainObjectFileID: 0 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/TestSceneSettings.lighting b/Assets/TestSceneSettings.lighting new file mode 100644 index 0000000..cc2444d --- /dev/null +++ b/Assets/TestSceneSettings.lighting @@ -0,0 +1,62 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!850595691 &4890085278179872738 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: TestSceneSettings + serializedVersion: 2 + m_GIWorkflowMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_RealtimeEnvironmentLighting: 1 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_UsingShadowmask: 1 + m_BakeBackend: 0 + m_LightmapMaxSize: 1024 + m_BakeResolution: 40 + m_Padding: 2 + m_TextureCompression: 1 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAO: 0 + m_MixedBakeMode: 2 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 0} + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 256 + m_FinalGatherFiltering: 1 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRRussianRouletteStartBounce: 2 + m_PVREnvironmentMIS: 0 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 diff --git a/Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 3.asset.meta b/Assets/TestSceneSettings.lighting.meta similarity index 64% rename from Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 3.asset.meta rename to Assets/TestSceneSettings.lighting.meta index 8dc54ab..1e43978 100644 --- a/Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 3.asset.meta +++ b/Assets/TestSceneSettings.lighting.meta @@ -1,8 +1,8 @@ fileFormatVersion: 2 -guid: 4e6f222bb6258d74fbb9b433517c5811 +guid: c6eb88022a890e1469fec23a151ba963 NativeFormatImporter: externalObjects: {} - mainObjectFileID: 11400000 + mainObjectFileID: 0 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/VFXDefaultResources.asset b/Assets/VFXDefaultResources.asset new file mode 100644 index 0000000..317a4de --- /dev/null +++ b/Assets/VFXDefaultResources.asset @@ -0,0 +1,82 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cd0a560c562a33e4b94f515804e2bd27, type: 3} + m_Name: VFXDefaultResources + m_EditorClassIdentifier: + particleTexture: {fileID: 0} + noiseTexture: {fileID: 0} + vectorField: {fileID: 0} + signedDistanceField: {fileID: 0} + mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} + animationCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 0.25 + value: 0.25 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + gradient: + serializedVersion: 2 + key0: {r: 1, g: 1, b: 1, a: 0} + key1: {r: 0.5, g: 0.5, b: 0.5, a: 1} + key2: {r: 0, g: 0, b: 0, a: 0.8} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 65535 + ctime2: 0 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 6554 + atime2: 52428 + atime3: 65535 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 2 + m_NumAlphaKeys: 4 + shader: {fileID: 0} diff --git a/Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 1.asset.meta b/Assets/VFXDefaultResources.asset.meta similarity index 79% rename from Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 1.asset.meta rename to Assets/VFXDefaultResources.asset.meta index 7426080..27d310c 100644 --- a/Assets/Visual Behavior Tree/Examples/New BehaviorTreeManagerAsset 1.asset.meta +++ b/Assets/VFXDefaultResources.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ffad9363e8ef7564ab91378eeac8c5a8 +guid: 07f8badda17a87c4db712c7f0e313008 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Visual Behavior Tree/Editor.meta b/Assets/Visual Behavior Tree/Editor.meta index 3d5afc6..5c86e45 100644 --- a/Assets/Visual Behavior Tree/Editor.meta +++ b/Assets/Visual Behavior Tree/Editor.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 03d7de68d91115549a1883cd567a56b9 +guid: 9a05ec06ce38b7649974ab657ccffb77 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Visual Behavior Tree/Editor/BaseEditor.cs b/Assets/Visual Behavior Tree/Editor/BaseEditor.cs index 97686b3..bbf23d0 100644 --- a/Assets/Visual Behavior Tree/Editor/BaseEditor.cs +++ b/Assets/Visual Behavior Tree/Editor/BaseEditor.cs @@ -1,101 +1,96 @@ -using Assets.Scripts.AI; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; -using UnityEditor; -using UnityEngine; - -namespace Assets.Editor -{ - public class BaseEditor : UnityEditor.Editor where T : MonoBehaviour - { - T data; - protected virtual void OnEnable() - { - data = (T)serializedObject.targetObject; - } - - public override void OnInspectorGUI() - { - serializedObject.Update(); - - GUIContent label = new GUIContent(); - label.text = "Properties"; - - DrawDefaultInspectors(label, data); - - if (GUI.changed) - { - EditorUtility.SetDirty(target); - } - - serializedObject.ApplyModifiedProperties(); - } - - protected void DrawDefaultInspectors(GUIContent label, T target) - { - EditorGUILayout.Separator(); - Type type = typeof(T); - FieldInfo[] fields = type.GetFields(); - EditorGUI.indentLevel++; - - foreach (FieldInfo field in fields) - { - if (field.IsPublic) - { - if (field.FieldType == typeof(int)) - { - field.SetValue(target, EditorGUILayout.IntField( - MakeLabel(field), (int)field.GetValue(target))); - } - else if (field.FieldType == typeof(float)) - { - field.SetValue(target, EditorGUILayout.FloatField( - MakeLabel(field), (float)field.GetValue(target))); - } - else if(field.FieldType == typeof(List)) - { - var fieldProp = serializedObject.FindProperty(field.Name); - EditorList.Show(fieldProp, EditorListOption.Buttons | EditorListOption.ElementLabels); - } - else if(field.FieldType == typeof(GameObject[])) - { - var fieldProp = serializedObject.FindProperty(field.Name); - EditorList.Show(fieldProp, EditorListOption.Buttons | EditorListOption.ElementLabels); - } - else if(serializedObject != null) - { - //Debug.Log("Trying to draw: " + field.Name); - EditorGUILayout.PropertyField(serializedObject.FindProperty(field.Name)); - } - else - { - Debug.LogError( - "DrawDefaultInspectors does not support fields of type " + - field.FieldType); - } - } - } - - EditorGUI.indentLevel--; - } - - private static GUIContent MakeLabel(FieldInfo field) - { - GUIContent guiContent = new GUIContent(); - guiContent.text = field.Name; - object[] descriptions = - field.GetCustomAttributes(typeof(DescriptionAttribute), true); - - if (descriptions.Length > 0) - { - //just use the first one. - guiContent.tooltip = - (descriptions[0] as DescriptionAttribute).Description; - } - - return guiContent; - } - } +using Assets.Scripts.AI; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Reflection; +using UnityEditor; +using UnityEngine; + +namespace Assets.Editor +{ + public class BaseEditor : UnityEditor.Editor where T : MonoBehaviour + { + T data; + protected virtual void OnEnable() + { + data = (T)serializedObject.targetObject; + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + GUIContent label = new GUIContent(); + label.text = "Properties"; + + DrawDefaultInspectors(label, data); + + if (GUI.changed) + { + EditorUtility.SetDirty(target); + } + + serializedObject.ApplyModifiedProperties(); + } + + protected void DrawDefaultInspectors(GUIContent label, T target) + { + EditorGUILayout.Separator(); + Type type = typeof(T); + FieldInfo[] fields = type.GetFields(); + EditorGUI.indentLevel++; + + foreach (FieldInfo field in fields) + { + if (field.IsPublic) + { + if (field.FieldType == typeof(int)) + { + field.SetValue(target, EditorGUILayout.IntField( + MakeLabel(field), (int)field.GetValue(target))); + } + else if (field.FieldType == typeof(float)) + { + field.SetValue(target, EditorGUILayout.FloatField( + MakeLabel(field), (float)field.GetValue(target))); + } + else if(field.FieldType == typeof(GameObject[])) + { + var fieldProp = serializedObject.FindProperty(field.Name); + EditorList.Show(fieldProp, EditorListOption.Buttons | EditorListOption.ElementLabels); + } + else if(serializedObject != null) + { + //Debug.Log("Trying to draw: " + field.Name); + EditorGUILayout.PropertyField(serializedObject.FindProperty(field.Name)); + } + else + { + Debug.LogError( + "DrawDefaultInspectors does not support fields of type " + + field.FieldType); + } + } + } + + EditorGUI.indentLevel--; + } + + private static GUIContent MakeLabel(FieldInfo field) + { + GUIContent guiContent = new GUIContent(); + guiContent.text = field.Name; + object[] descriptions = + field.GetCustomAttributes(typeof(DescriptionAttribute), true); + + if (descriptions.Length > 0) + { + //just use the first one. + guiContent.tooltip = + (descriptions[0] as DescriptionAttribute).Description; + } + + return guiContent; + } + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/BaseEditor.cs.meta b/Assets/Visual Behavior Tree/Editor/BaseEditor.cs.meta index 50e33ab..f3ae85f 100644 --- a/Assets/Visual Behavior Tree/Editor/BaseEditor.cs.meta +++ b/Assets/Visual Behavior Tree/Editor/BaseEditor.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 0f35796c41cc8eb46b957581083c3fb6 -timeCreated: 1519507240 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 0f35796c41cc8eb46b957581083c3fb6 +timeCreated: 1519507240 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorDebuggerWindow.cs b/Assets/Visual Behavior Tree/Editor/BehaviorDebuggerWindow.cs new file mode 100644 index 0000000..d1be555 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/BehaviorDebuggerWindow.cs @@ -0,0 +1,39 @@ +using Assets.Visual_Behavior_Tree.Editor.NodeEditor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEditor; +using UnityEngine; + +namespace Assets.Visual_Behavior_Tree.Editor +{ + class BehaviorDebuggerWindow : BehaviorNodeEditorWindow + { + [MenuItem("Window/uVBT/Node Debugger")] + private static void OpenWindow() + { + BehaviorDebuggerWindow window = GetWindow(); + window.titleContent = new GUIContent("Behavior Debugger"); + } + + protected override void OnGUI() + { + DrawToolbar(); + + DrawGrid(20, 0.2f, Color.gray); + DrawGrid(100, 0.4f, Color.gray); + + DrawNodes(); + DrawConnections(); + + DrawConnectionLine(Event.current); + + ProcessNodeEvents(Event.current); + ProcessEvents(Event.current); + + if (GUI.changed) Repaint(); + } + } +} diff --git a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenSourceExtensions.cs.meta b/Assets/Visual Behavior Tree/Editor/BehaviorDebuggerWindow.cs.meta similarity index 83% rename from Assets/Plugins/UniRx/Scripts/Async/CancellationTokenSourceExtensions.cs.meta rename to Assets/Visual Behavior Tree/Editor/BehaviorDebuggerWindow.cs.meta index fd09fe4..7bd9934 100644 --- a/Assets/Plugins/UniRx/Scripts/Async/CancellationTokenSourceExtensions.cs.meta +++ b/Assets/Visual Behavior Tree/Editor/BehaviorDebuggerWindow.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 22d85d07f1e70ab42a7a4c25bd65e661 +guid: 1191ae4cc15422f4a93ccf2aea5e67b1 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BehaviorExtensions.cs b/Assets/Visual Behavior Tree/Editor/BehaviorExtensions.cs similarity index 87% rename from Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BehaviorExtensions.cs rename to Assets/Visual Behavior Tree/Editor/BehaviorExtensions.cs index 4682ff1..e583a06 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BehaviorExtensions.cs +++ b/Assets/Visual Behavior Tree/Editor/BehaviorExtensions.cs @@ -1,142 +1,141 @@ -using Assets.Scripts.AI; -using Assets.Scripts.AI.Components; -using Assets.Scripts.AI.Tree; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using UnityEditor; -using UnityEngine; - -namespace Assets.Editor.BehaviorTreeViewEditor -{ - public static class BehaviorExtensions - { - public static IOrderedEnumerable Order(this IEnumerable source, Func selector, bool ascending) - { - if (ascending) - { - return source.OrderBy(selector); - } - else - { - return source.OrderByDescending(selector); - } - } - - public static IOrderedEnumerable ThenBy(this IOrderedEnumerable source, Func selector, bool ascending) - { - if (ascending) - { - return source.ThenBy(selector); - } - else - { - return source.ThenByDescending(selector); - } - } - - public static void CreateTypeMenu(this GenericMenu menu, GenericMenu.MenuFunction2 func) where T : class - { - foreach (Type type in - Assembly.GetAssembly(typeof(T)).GetTypes() - .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T)))) - { - var menuStrings = type.ToString().Split('.'); - menu.AddItem(new GUIContent(menuStrings[menuStrings.Length - 2] + - "/" + menuStrings.Last()), false, func, type.ToString()); - } - } - - public static void CreateManagerMenu(this GenericMenu menu, GenericMenu.MenuFunction2 func) - { - var managers = UnityEngine.Object.FindObjectsOfType(); - foreach (BehaviorManager manager in managers) - { - string menuName = manager.BehaviorLogger.Name; - menu.AddItem(new GUIContent(menuName), false, func, menuName); - } - } - - public static Color GetBehaviorStateColor(this BehaviorState state) - { - switch (state) - { - case BehaviorState.Fail: - return Color.red; - case BehaviorState.Running: - return Color.blue; - case BehaviorState.Success: - return new Color(0.1f, 0.9f, 0.2f); - case BehaviorState.Null: - return Color.grey; - default: - return Color.black; - } - } - - - /// - /// Saves a scriptable object behavior tree and sets the active asset back to the behavior manager - /// - /// - /// - /// - public static void SaveBehaviorAsset(this BehaviorManager behaviorManager, string filePath, - BehaviorTreeManagerAsset asset, Merge root = null) - { - if (asset == null) - asset = ScriptableObject.CreateInstance(); - - var runnerElementList = new List(); - - Debug.Log("Attempting save at path: " + filePath); - - int indexS = filePath.LastIndexOf("/") + 1; - int indexD = filePath.LastIndexOf(".") - indexS; - - asset.name = filePath.Substring(indexS, indexD); - - var json = asset.RunnerElementsJSON; - - if(behaviorManager != null) - { - behaviorManager.Reinitialize(); - asset.MilliSecondsBetweenTicks =behaviorManager.MilliSecondsBetweenTicks; - asset.TimesToTick = behaviorManager.TimesToTick; - - TreeElementUtility.TreeToList(behaviorManager.Runner, runnerElementList); - } - - if(root != null) - { - TreeElementUtility.TreeToList(root, runnerElementList); - } - - if(json == "" || runnerElementList.Count == 0) - { - var runner = new Merge("Extension Root", -1, -1); - runnerElementList.Add(runner); - - json = JsonConvert.SerializeObject(runnerElementList, Formatting.Indented); - } - json = JsonConvert.SerializeObject(runnerElementList, Formatting.Indented); - asset.RunnerElementsJSON = json; - - Debug.Log("JSON Saved: " + asset.RunnerElementsJSON); - - var curPath = AssetDatabase.GetAssetPath(asset); - - if(curPath == null || curPath == "") - { - Debug.Log("Creating asset: " + filePath); - AssetDatabase.CreateAsset(asset, filePath); - } - - //AssetDatabase.Refresh(); - EditorUtility.SetDirty(asset); - AssetDatabase.SaveAssets(); - } - } -} +using Assets.Scripts.AI; +using Assets.Scripts.AI.Components; +using Assets.Scripts.AI.Tree; +using Assets.Visual_Behavior_Tree.Scripts; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEngine; + +namespace Assets.Editor +{ + public static class BehaviorExtensions + { + public static IOrderedEnumerable Order(this IEnumerable source, Func selector, bool ascending) + { + if (ascending) + { + return source.OrderBy(selector); + } + else + { + return source.OrderByDescending(selector); + } + } + + public static IOrderedEnumerable ThenBy(this IOrderedEnumerable source, Func selector, bool ascending) + { + if (ascending) + { + return source.ThenBy(selector); + } + else + { + return source.ThenByDescending(selector); + } + } + + public static void CreateTypeMenu(this GenericMenu menu, GenericMenu.MenuFunction2 func) where T : class + { + foreach (Type type in + Assembly.GetAssembly(typeof(T)).GetTypes() + .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T)))) + { + var menuStrings = type.ToString().Split('.'); + menu.AddItem(new GUIContent(menuStrings[menuStrings.Length - 2] + + "/" + menuStrings.Last()), false, func, type.ToString()); + } + } + + public static void CreateManagerMenu(this GenericMenu menu, GenericMenu.MenuFunction2 func) + { + var managers = UnityEngine.Object.FindObjectsOfType(); + foreach (BehaviorManager manager in managers) + { + string menuName = manager.BehaviorLogger.Name; + menu.AddItem(new GUIContent(menuName), false, func, menuName); + } + } + + public static Color GetBehaviorStateColor(this BehaviorState state) + { + switch (state) + { + case BehaviorState.Fail: + return Color.red; + case BehaviorState.Running: + return Color.blue; + case BehaviorState.Success: + return new Color(0.1f, 0.9f, 0.2f); + case BehaviorState.Null: + return Color.grey; + default: + return Color.black; + } + } + + + /// + /// Saves a scriptable object behavior tree and sets the active asset back to the behavior manager + /// + /// + /// + /// + public static void SaveBehaviorAsset(this BehaviorManager behaviorManager, string filePath, + TreeNodeAsset asset, Merge root = null) + { + if (asset == null) + asset = ScriptableObject.CreateInstance(); + + var runnerElementList = new List(); + + Debug.Log("Attempting save at path: " + filePath); + + int indexS = filePath.LastIndexOf("/") + 1; + int indexD = filePath.LastIndexOf(".") - indexS; + + asset.name = filePath.Substring(indexS, indexD); + + var json = asset.treeElements; + + if(behaviorManager != null) + { + behaviorManager.Reinitialize(); + //asset.MilliSecondsBetweenTicks =behaviorManager.MilliSecondsBetweenTicks; + //asset.TimesToTick = behaviorManager.TimesToTick; + + TreeElementUtility.TreeToList(behaviorManager.Runner, runnerElementList); + } + + if(root != null) + { + TreeElementUtility.TreeToList(root, runnerElementList); + } + + if(json == "" || runnerElementList.Count == 0) + { + var runner = new Merge("Extension Root", -1, -1); + runnerElementList.Add(runner); + } + json = JsonConvert.SerializeObject(runnerElementList, Formatting.Indented); + asset.treeElements = json; + + Debug.Log("JSON Saved: " + asset.treeElements); + + var curPath = AssetDatabase.GetAssetPath(asset); + + if(curPath == null || curPath == "") + { + Debug.Log("Creating asset: " + filePath); + AssetDatabase.CreateAsset(asset, filePath); + } + + //AssetDatabase.Refresh(); + EditorUtility.SetDirty(asset); + AssetDatabase.SaveAssets(); + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BehaviorExtensions.cs.meta b/Assets/Visual Behavior Tree/Editor/BehaviorExtensions.cs.meta similarity index 95% rename from Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BehaviorExtensions.cs.meta rename to Assets/Visual Behavior Tree/Editor/BehaviorExtensions.cs.meta index 613e62a..9524c48 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BehaviorExtensions.cs.meta +++ b/Assets/Visual Behavior Tree/Editor/BehaviorExtensions.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 1330b717549e1754396c1479bdd90d07 -timeCreated: 1520483523 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 1330b717549e1754396c1479bdd90d07 +timeCreated: 1520483523 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorLogDrawer.cs b/Assets/Visual Behavior Tree/Editor/BehaviorLogDrawer.cs deleted file mode 100644 index 3ee9540..0000000 --- a/Assets/Visual Behavior Tree/Editor/BehaviorLogDrawer.cs +++ /dev/null @@ -1,179 +0,0 @@ -using Assets.Scripts.AI.Behavior_Logger; -using UniRx; -using UnityEngine; -using System; -using UnityEditor; -using Assets.Editor.BehaviorTreeViewEditor; -using System.Collections.Generic; - -namespace Assets.Editor -{ - public class BehaviorLogDrawer - { - private int BehaviorID; - private string ManagerName = "Wolf Pancakes Taste Like Fur"; - public Rect DrawHere; - - public Vector2 BoxSize; - public RectOffset TotalOffset; - - protected BehaviorLogDrawer Parent = null; - - /// - /// Depth of this drawer (taken from entry) Default: 0 - /// - private int DrawDepth = 0; - - private Dictionary ChildrenDrawers = new Dictionary(); - - /// - /// Custom Styling options for this behavior log drawer - /// - public GUIStyle Style = new GUIStyle(); - - public BehaviorLogEntry Entry { get; set; } - private IObservable LogStream; - - public BehaviorLogDrawer(string loggerName, int ID, Vector2 boxSize, GUIStyle subStyle = null) - { - BehaviorID = ID; - ManagerName = loggerName; - BoxSize = boxSize; - if (subStyle != null) - Style = subStyle; - else - { - Style = new GUIStyle(); - Style.margin = new RectOffset(15, 15, 30, 30); - } - - TotalOffset = Style.margin; - Initialize(); - } - - private bool Initialized = false; - public void Initialize() - { - ChildrenDrawers = new Dictionary(); - LogStream = ObservableBehaviorLogger.Listener - .Where(x => - x.BehaviorID == BehaviorID && - x.LoggerName == ManagerName) - .Do(x => - { - Entry = x; - if(Entry.State.HasChildren) - { - foreach (var child in Entry.State.Children) - { - if (!ChildrenDrawers.ContainsKey(child.ID)) - { - float y = (child.Depth+1) * (BoxSize.y + Style.margin.top); - ChildrenDrawers.Add(child.ID, new BehaviorLogDrawer(ManagerName, child.ID, BoxSize, Style) - { - Parent = this, - DrawHere = new Rect(Style.margin.left, y, BoxSize.x, BoxSize.y) - }); - } - } - } - }); - - Initialized = true; - } - - public void DrawBehaviorWithAllChildren() - { - if (!Initialized) - { - Initialize(); - } - //Draw Breadth First, Offset parent second - LogStream.Subscribe(); - - int offset = Style.margin.left; - - if(Entry == null) - { - return; - } - else if(Entry.State.HasChildren) - { - offset = DrawChildrenAndGetOffset() / 2; - } - var parent = Entry.State.Parent; - if (parent != null) - { - if (parent.HasChildren) - { - if (parent.Children.Count == 1) - { - offset = (int)BoxSize.x / 2; - } - } - } - this.TotalOffset.left = offset; - this.TotalOffset.right = offset; - DrawBehaviorLogEntry(); - } - - private int DrawChildrenAndGetOffset() - { - var newOffset = 0; - BehaviorLogDrawer prevChildDrawer = null; - foreach (var child in ChildrenDrawers.Values) - { - if (prevChildDrawer == null) - { - child.DrawHere.x = this.DrawHere.x; - } - else - { - child.DrawHere.x = prevChildDrawer.DrawHere.x + - BoxSize.x + - prevChildDrawer.TotalOffset.right; - - newOffset += prevChildDrawer.TotalOffset.right; - } - - newOffset += (int)BoxSize.x; - prevChildDrawer = child; - child.DrawBehaviorWithAllChildren(); - } - return newOffset; - } - //FIXED - - public void DrawBehaviorLogEntry() - { - if(Entry != null) - { - var totalX = DrawHere.x + TotalOffset.left; - var totalPosition = new Rect(totalX, DrawHere.y, - BoxSize.x, BoxSize.y); - - if(Parent != null) - { - var startVector = new Vector3(totalX + BoxSize.x / 2, DrawHere.y); - var endVector = new Vector3(Parent.DrawHere.x + BoxSize.x / 2 + Parent.TotalOffset.left, - Parent.DrawHere.y + BoxSize.y); - using (new Handles.DrawingScope(Color.black)) - { - Handles.DrawLine(startVector, endVector); - } - } - - CustomGUI.DrawQuad(totalPosition, Entry.State.CurrentState.GetBehaviorStateColor()); - - GUI.BeginGroup(totalPosition); - - if (Entry.State.Parent != null) - { - GUI.Label(new Rect(0, 20, 120, 30), new GUIContent(Entry.State.Parent.Name)); - } - GUI.Label(new Rect(0,35,120,30), new GUIContent(Entry.State.Name)); - GUI.EndGroup(); - } - } - } -} diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorLogDrawer.cs.meta b/Assets/Visual Behavior Tree/Editor/BehaviorLogDrawer.cs.meta deleted file mode 100644 index ef1818e..0000000 --- a/Assets/Visual Behavior Tree/Editor/BehaviorLogDrawer.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 9738ef56f1e79b742a44e32a1c251288 -timeCreated: 1523326211 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorManagerEditor.cs b/Assets/Visual Behavior Tree/Editor/BehaviorManagerEditor.cs deleted file mode 100644 index 20ef9d1..0000000 --- a/Assets/Visual Behavior Tree/Editor/BehaviorManagerEditor.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Assets.Editor.BehaviorTreeViewEditor; -using Assets.Scripts.AI; -using UnityEditor; -using UnityEngine; - -namespace Assets.Editor -{ - [CustomEditor(typeof(BehaviorManager))] - public class BehaviorManagerEditor : BaseEditor - { - BehaviorManager BTreeManager; - BehaviorTreeManagerAsset _BTreeAsset; - - protected override void OnEnable() - { - base.OnEnable(); - BTreeManager = (BehaviorManager)serializedObject.targetObject; - } - - public override void OnInspectorGUI() - { - base.OnInspectorGUI(); - - if (GUILayout.Button("Reload")) - { - BTreeManager.Reinitialize(); - } - - if(GUILayout.Button("Debug")) - { - TreeDebuggerWindow.ShowWindow(); - } - } - } -} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorManagerEditor.cs.meta b/Assets/Visual Behavior Tree/Editor/BehaviorManagerEditor.cs.meta deleted file mode 100644 index f91faac..0000000 --- a/Assets/Visual Behavior Tree/Editor/BehaviorManagerEditor.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: e7a6d9a840a13454bb0138acc1d15134 -timeCreated: 1518939676 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor.meta b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor.meta index 4d1b84b..71d8b3d 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor.meta +++ b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor.meta @@ -1,10 +1,10 @@ -fileFormatVersion: 2 -guid: 8500cdf61abde6f4d9f00cf5d3c4b012 -folderAsset: yes -timeCreated: 1518939676 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 8500cdf61abde6f4d9f00cf5d3c4b012 +folderAsset: yes +timeCreated: 1518939676 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData.meta b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData.meta index cf20717..ec4f34b 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData.meta +++ b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData.meta @@ -1,9 +1,9 @@ -fileFormatVersion: 2 -guid: 352ae18c571bea34092dc22719650ab6 -folderAsset: yes -timeCreated: 1472023475 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 352ae18c571bea34092dc22719650ab6 +folderAsset: yes +timeCreated: 1472023475 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBTreeWindow.cs b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBTreeWindow.cs index 36ba764..d6fe118 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBTreeWindow.cs +++ b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBTreeWindow.cs @@ -1,261 +1,262 @@ -using Assets.Scripts.AI; -using Assets.Scripts.AI.Components; -using Assets.Scripts.AI.Tree; -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using UnityEditor.Callbacks; -using UnityEditor.IMGUI.Controls; -using UnityEngine; - -namespace Assets.Editor.BehaviorTreeViewEditor.BackendData -{ - class MultiColumnBTreeWindow : EditorWindow - { - [NonSerialized] bool _Initialized; - [SerializeField] TreeViewState _TreeViewState; // Serialized in the window layout file so it survives assembly reloading - [SerializeField] MultiColumnHeaderState _MultiColumnHeaderState; - SearchField _SearchField; - MultiColumnBehaviorTreeView _TreeView; - [SerializeField] BehaviorTreeManagerAsset _BehaviorTreeManagerAsset; - - string FilePath = ""; - private static string FileDir = "Assets/Behaviors/"; - - [MenuItem("Behavior Tree/New Tree")] - public static MultiColumnBTreeWindow GetWindow() - { - var window = GetWindow(); - window.titleContent = new GUIContent("Behavior Tree Builder"); - window.Focus(); - window.Repaint(); - return window; - } - - [OnOpenAsset] - public static bool OnOpenAsset(int instanceID, int line) - { - var BTreeAsset = EditorUtility.InstanceIDToObject(instanceID) as BehaviorTreeManagerAsset; - if (BTreeAsset != null) - { - var window = GetWindow(); - window.SetTreeAsset(BTreeAsset); - return true; - } - return false; // we did not handle the open - } - - public void SetTreeAsset(BehaviorTreeManagerAsset BehaviorTreeAsset) - { - if(BehaviorTreeAsset == null || BehaviorTreeAsset.RunnerElementsJSON == "") - { - CreateNewTree(); - } - _BehaviorTreeManagerAsset = BehaviorTreeAsset; - _Initialized = false; - } - - Rect multiColumnTreeViewRect - { - get { return new Rect(20, 50, position.width - 40, position.height - 70); } - } - - Rect toolbarRect - { - get { return new Rect(20f, 10f, position.width - 40f, 20f); } - } - - Rect topToolbarRect - { - get { return new Rect(20f, 30f, position.width - 40f, 30f); } - } - - Rect bottomToolbarRect - { - get { return new Rect(20f, position.height - 18f, position.width - 60f, 16f); } - } - - public MultiColumnBehaviorTreeView treeView - { - get { return _TreeView; } - } - - void InitIfNeeded() - { - if (!_Initialized) - { - // Check if it already exists (deserialized from window layout file or scriptable object) - if (_TreeViewState == null) - _TreeViewState = new TreeViewState(); - - bool firstInit = _MultiColumnHeaderState == null; - var headerState = MultiColumnBehaviorTreeView.CreateDefaultMultiColumnHeaderState(multiColumnTreeViewRect.width); - if (MultiColumnHeaderState.CanOverwriteSerializedFields(_MultiColumnHeaderState, headerState)) - MultiColumnHeaderState.OverwriteSerializedFields(_MultiColumnHeaderState, headerState); - _MultiColumnHeaderState = headerState; - - var multiColumnHeader = new BTreeMultiColumnHeader(headerState); - if (firstInit) - multiColumnHeader.ResizeToFit(); - - var treeModel = new TreeModel(GetData()); - - _TreeView = new MultiColumnBehaviorTreeView(_TreeViewState, multiColumnHeader, treeModel); - - _SearchField = new SearchField(); - _SearchField.downOrUpArrowKeyPressed += _TreeView.SetFocusAndEnsureSelectedItem; - - _Initialized = true; - } - } - - IList GetData() - { - if (_BehaviorTreeManagerAsset == null) - { - CreateNewTree(); - } - - var treeRoot = _BehaviorTreeManagerAsset.LoadFromJSON(); - if(treeRoot == null) - { - treeRoot = new Merge("New Root",-1, -1); - } - var treeList = new List(); - - TreeElementUtility.TreeToList(treeRoot, treeList); - - return treeList; - } - - void CreateNewTree() - { - CustomAssetUtility.CreateAsset(); - _BehaviorTreeManagerAsset = (BehaviorTreeManagerAsset)Selection.activeObject; - var root =new Merge("root",-1,-1); - BehaviorExtensions.SaveBehaviorAsset(null, AssetDatabase.GetAssetPath(_BehaviorTreeManagerAsset), - _BehaviorTreeManagerAsset,(Merge)root); - } - - void OnSelectionChange() - { - if (!_Initialized) - return; - - var BehaviorTreeAsset = Selection.activeObject as BehaviorTreeManagerAsset; - if (BehaviorTreeAsset != null && BehaviorTreeAsset != _BehaviorTreeManagerAsset) - { - _BehaviorTreeManagerAsset = BehaviorTreeAsset; - _TreeView.treeModel.SetData(GetData()); - _TreeView.Reload(); - } - } - - void OnGUI() - { - InitIfNeeded(); - - SearchBar(toolbarRect); - TopToolbar(topToolbarRect); - DoTreeView(multiColumnTreeViewRect); - BottomToolBar(bottomToolbarRect); - } - - void SearchBar(Rect rect) - { - treeView.searchString = _SearchField.OnGUI(rect, treeView.searchString); - } - - void DoTreeView(Rect rect) - { - _TreeView.OnGUI(rect); - } - - void TopToolbar(Rect rect) - { - GUILayout.BeginArea(rect); - - using (new EditorGUILayout.HorizontalScope()) - { - GenericMenu menu = new GenericMenu(); - if (EditorGUILayout.DropdownButton(new GUIContent("Add Behavior"),FocusType.Passive)) - { - menu.CreateTypeMenu(OnTypeSelected); - menu.ShowAsContext(); - } - - if (GUILayout.Button("Remove Behavior")) - { - var selection = _TreeView.GetSelection(); - _TreeView.treeModel.RemoveElements(selection); - } - - FilePath = GUILayout.TextField(FilePath); - if (GUILayout.Button("Save Tree")) - { - FilePath = EditorUtility.SaveFilePanel("", FileDir, "New Behavior Tree", "asset"); - BehaviorExtensions.SaveBehaviorAsset(null, FilePath, _BehaviorTreeManagerAsset, (Merge)_TreeView.treeModel.Root); - } - } - - GUILayout.EndArea(); - } - - private void OnTypeSelected(object typeName) - { - var selection = _TreeView.GetSelection(); - BehaviorTreeElement parent = (selection.Count == 1 ? _TreeView.treeModel.Find(selection[0]) : null) ?? _TreeView.treeModel.Root; - int depth = parent != null ? parent.Depth + 1 : 0; - int id = _TreeView.treeModel.GenerateUniqueID(); - - Type type = typeof(BehaviorTreeElement).Assembly.GetType((string)typeName, true); - - dynamic element = Activator.CreateInstance(type, type.ToString().Split('.').Last() + " " + id, depth, id); - element.ElementType = element.GetType().ToString(); - //element.BehaviorTreeManager = parent.BehaviorTreeManager; - _TreeView.treeModel.AddElement(element, parent, 0); - - _TreeView.SetSelection(new[] { id }, TreeViewSelectionOptions.RevealAndFrame); - //TODO: Show there are unsaved changes - } - - void BottomToolBar(Rect rect) - { - GUILayout.BeginArea(rect); - - using(new EditorGUILayout.HorizontalScope()) - { - var style = "miniButton"; - if (GUILayout.Button("Expand All", style)) - { - treeView.ExpandAll(); - } - - if (GUILayout.Button("Collapse All", style)) - { - treeView.CollapseAll(); - } - - GUILayout.Space(10); - - _TreeView.ShowParams = (MultiColumnBehaviorTreeView.ShowParameters) - EditorGUILayout.EnumPopup("Show Parameter Lists", _TreeView.ShowParams, "miniButton"); - } - GUILayout.EndArea(); - } - } - - internal class BTreeMultiColumnHeader : MultiColumnHeader - { - public BTreeMultiColumnHeader(MultiColumnHeaderState state) - : base(state) - { } - - protected override void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex) - { - // Default column header gui - base.ColumnHeaderGUI(column, headerRect, columnIndex); - } - } -} +using Assets.Scripts.AI; +using Assets.Scripts.AI.Components; +using Assets.Scripts.AI.Tree; +using Assets.Visual_Behavior_Tree.Scripts; +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.Callbacks; +using UnityEditor.IMGUI.Controls; +using UnityEngine; + +namespace Assets.Editor.BehaviorTreeViewEditor.BackendData +{ + class MultiColumnBTreeWindow : EditorWindow + { + [NonSerialized] bool _Initialized; + [SerializeField] TreeViewState _TreeViewState; // Serialized in the window layout file so it survives assembly reloading + [SerializeField] MultiColumnHeaderState _MultiColumnHeaderState; + SearchField _SearchField; + MultiColumnBehaviorTreeView _TreeView; + [SerializeField] TreeNodeAsset _TreeNodeAsset; + + string FilePath = ""; + private static string FileDir = "Assets/Behaviors/"; + + [MenuItem("Behavior Tree/New Tree")] + public static MultiColumnBTreeWindow GetWindow() + { + var window = GetWindow(); + window.titleContent = new GUIContent("Behavior Tree Builder"); + window.Focus(); + window.Repaint(); + return window; + } + + [OnOpenAsset] + public static bool OnOpenAsset(int instanceID, int line) + { + var BTreeAsset = EditorUtility.InstanceIDToObject(instanceID) as TreeNodeAsset; + if (BTreeAsset != null) + { + var window = GetWindow(); + window.SetTreeAsset(BTreeAsset); + return true; + } + return false; // we did not handle the open + } + + public void SetTreeAsset(TreeNodeAsset BehaviorTreeAsset) + { + if(BehaviorTreeAsset == null || BehaviorTreeAsset.treeElements == "") + { + CreateNewTree(); + } + _TreeNodeAsset = BehaviorTreeAsset; + _Initialized = false; + } + + Rect multiColumnTreeViewRect + { + get { return new Rect(20, 50, position.width - 40, position.height - 70); } + } + + Rect toolbarRect + { + get { return new Rect(20f, 10f, position.width - 40f, 20f); } + } + + Rect topToolbarRect + { + get { return new Rect(20f, 30f, position.width - 40f, 30f); } + } + + Rect bottomToolbarRect + { + get { return new Rect(20f, position.height - 18f, position.width - 60f, 16f); } + } + + public MultiColumnBehaviorTreeView treeView + { + get { return _TreeView; } + } + + void InitIfNeeded() + { + if (!_Initialized) + { + // Check if it already exists (deserialized from window layout file or scriptable object) + if (_TreeViewState == null) + _TreeViewState = new TreeViewState(); + + bool firstInit = _MultiColumnHeaderState == null; + var headerState = MultiColumnBehaviorTreeView.CreateDefaultMultiColumnHeaderState(multiColumnTreeViewRect.width); + if (MultiColumnHeaderState.CanOverwriteSerializedFields(_MultiColumnHeaderState, headerState)) + MultiColumnHeaderState.OverwriteSerializedFields(_MultiColumnHeaderState, headerState); + _MultiColumnHeaderState = headerState; + + var multiColumnHeader = new BTreeMultiColumnHeader(headerState); + if (firstInit) + multiColumnHeader.ResizeToFit(); + + var treeModel = new TreeModel(GetData()); + + _TreeView = new MultiColumnBehaviorTreeView(_TreeViewState, multiColumnHeader, treeModel); + + _SearchField = new SearchField(); + _SearchField.downOrUpArrowKeyPressed += _TreeView.SetFocusAndEnsureSelectedItem; + + _Initialized = true; + } + } + + IList GetData() + { + if (_TreeNodeAsset == null) + { + CreateNewTree(); + } + + var treeRoot = _TreeNodeAsset.LoadRoot(); + if(treeRoot == null) + { + treeRoot = new Merge("New Root",-1, -1); + } + var treeList = new List(); + + TreeElementUtility.TreeToList(treeRoot, treeList); + + return treeList; + } + + void CreateNewTree() + { + CustomAssetUtility.CreateAsset(); + _TreeNodeAsset = (TreeNodeAsset)Selection.activeObject; + var root =new Merge("root",-1,-1); + //BehaviorExtensions.SaveBehaviorAsset(null, AssetDatabase.GetAssetPath(_TreeNodeAsset), + // _TreeNodeAsset,(Merge)root); + } + + void OnSelectionChange() + { + if (!_Initialized) + return; + + var BehaviorTreeAsset = Selection.activeObject as TreeNodeAsset; + if (BehaviorTreeAsset != null && BehaviorTreeAsset != _TreeNodeAsset) + { + _TreeNodeAsset = BehaviorTreeAsset; + _TreeView.treeModel.SetData(GetData()); + _TreeView.Reload(); + } + } + + void OnGUI() + { + InitIfNeeded(); + + SearchBar(toolbarRect); + TopToolbar(topToolbarRect); + DoTreeView(multiColumnTreeViewRect); + BottomToolBar(bottomToolbarRect); + } + + void SearchBar(Rect rect) + { + treeView.searchString = _SearchField.OnGUI(rect, treeView.searchString); + } + + void DoTreeView(Rect rect) + { + _TreeView.OnGUI(rect); + } + + void TopToolbar(Rect rect) + { + GUILayout.BeginArea(rect); + + using (new EditorGUILayout.HorizontalScope()) + { + GenericMenu menu = new GenericMenu(); + if (EditorGUILayout.DropdownButton(new GUIContent("Add Behavior"),FocusType.Passive)) + { + menu.CreateTypeMenu(OnTypeSelected); + menu.ShowAsContext(); + } + + if (GUILayout.Button("Remove Behavior")) + { + var selection = _TreeView.GetSelection(); + _TreeView.treeModel.RemoveElements(selection); + } + + FilePath = GUILayout.TextField(FilePath); + if (GUILayout.Button("Save Tree")) + { + FilePath = EditorUtility.SaveFilePanel("", FileDir, "New Behavior Tree", "asset"); + //BehaviorExtensions.SaveBehaviorAsset(null, FilePath, _TreeNodeAsset, (Merge)_TreeView.treeModel.Root); + } + } + + GUILayout.EndArea(); + } + + private void OnTypeSelected(object typeName) + { + var selection = _TreeView.GetSelection(); + BehaviorTreeElement parent = (selection.Count == 1 ? _TreeView.treeModel.Find(selection[0]) : null) ?? _TreeView.treeModel.Root; + int depth = parent != null ? parent.Depth + 1 : 0; + int id = _TreeView.treeModel.GenerateUniqueID(); + + Type type = typeof(BehaviorTreeElement).Assembly.GetType((string)typeName, true); + + dynamic element = Activator.CreateInstance(type, type.ToString().Split('.').Last() + " " + id, depth, id); + element.ElementType = element.GetType().ToString(); + //element.BehaviorTreeManager = parent.BehaviorTreeManager; + _TreeView.treeModel.AddElement(element, parent, 0); + + _TreeView.SetSelection(new[] { id }, TreeViewSelectionOptions.RevealAndFrame); + //TODO: Show there are unsaved changes + } + + void BottomToolBar(Rect rect) + { + GUILayout.BeginArea(rect); + + using(new EditorGUILayout.HorizontalScope()) + { + var style = "miniButton"; + if (GUILayout.Button("Expand All", style)) + { + treeView.ExpandAll(); + } + + if (GUILayout.Button("Collapse All", style)) + { + treeView.CollapseAll(); + } + + GUILayout.Space(10); + + _TreeView.ShowParams = (MultiColumnBehaviorTreeView.ShowParameters) + EditorGUILayout.EnumPopup("Show Parameter Lists", _TreeView.ShowParams, "miniButton"); + } + GUILayout.EndArea(); + } + } + + internal class BTreeMultiColumnHeader : MultiColumnHeader + { + public BTreeMultiColumnHeader(MultiColumnHeaderState state) + : base(state) + { } + + protected override void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex) + { + // Default column header gui + base.ColumnHeaderGUI(column, headerRect, columnIndex); + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBTreeWindow.cs.meta b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBTreeWindow.cs.meta index 5dca947..8b776a8 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBTreeWindow.cs.meta +++ b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBTreeWindow.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 712b683d552664c44a375445a3a54067 -timeCreated: 1518236410 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 712b683d552664c44a375445a3a54067 +timeCreated: 1518236410 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBehaviorTreeView.cs b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBehaviorTreeView.cs index c655b23..20c1c9a 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBehaviorTreeView.cs +++ b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBehaviorTreeView.cs @@ -1,334 +1,335 @@ -using Assets.Scripts.AI; -using Assets.Scripts.AI.Tree; -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using UnityEditor.IMGUI.Controls; -using UnityEngine; -using UnityEngine.Assertions; - -namespace Assets.Editor.BehaviorTreeViewEditor.BackendData -{ - internal class MultiColumnBehaviorTreeView : TreeViewWithTreeModel - { - const float kRowHeights = 20f; - const float kToggleWidth = 18f; - const float kTypeButtonWidth = 70f; - public ShowParameters ShowParams; - - // All columns - enum BTreeColumns - { - State, - Name, - Parameters - } - - public enum SortOption - { - State, - Name, - Parameters - } - - public enum ShowParameters - { - None, - Active, - All - } - - // Sort options per column - SortOption[] m_SortOptions = - { - SortOption.State, - SortOption.Name, - SortOption.Parameters - }; - - public static void TreeToList(TreeViewItem root, IList result) - { - if (root == null) - throw new NullReferenceException("root"); - if (result == null) - throw new NullReferenceException("result"); - - result.Clear(); - - if (root.children == null) - return; - - Stack stack = new Stack(); - for (int i = root.children.Count - 1; i >= 0; i--) - stack.Push(root.children[i]); - - while (stack.Count > 0) - { - TreeViewItem current = stack.Pop(); - result.Add(current); - - if (current.hasChildren && current.children[0] != null) - { - for (int i = current.children.Count - 1; i >= 0; i--) - { - stack.Push(current.children[i]); - } - } - } - } - - public MultiColumnBehaviorTreeView(TreeViewState state, MultiColumnHeader multicolumnHeader, TreeModel model) - : base(state, multicolumnHeader, model) - { - Assert.AreEqual(m_SortOptions.Length, Enum.GetValues(typeof(BTreeColumns)).Length, "Ensure number of sort options are in sync with number of MyColumns enum values"); - - // Custom setup - columnIndexForTreeFoldouts = 1; - - showAlternatingRowBackgrounds = true; - showBorder = true; - customFoldoutYOffset = (kRowHeights - EditorGUIUtility.singleLineHeight) * 0.5f; // center foldout in the row since we also center content. See RowGUI - extraSpaceBeforeIconAndLabel = kToggleWidth; - multicolumnHeader.sortingChanged += OnSortingChanged; - - Reload(); - } - - - // Note we We only build the visible rows, only the backend has the full tree information. - // The treeview only creates info for the row list. - protected override IList BuildRows(TreeViewItem root) - { - var rows = base.BuildRows(root); - SortIfNeeded(root, rows); - return rows; - } - - void OnSortingChanged(MultiColumnHeader multiColumnHeader) - { - SortIfNeeded(rootItem, GetRows()); - } - - void SortIfNeeded(TreeViewItem root, IList rows) - { - if (rows.Count <= 1) - return; - - if (multiColumnHeader.sortedColumnIndex == -1) - { - return; // No column to sort for (just use the order the data are in) - } - - // Sort the roots of the existing tree items - SortByMultipleColumns(); - TreeToList(root, rows); - Repaint(); - } - - void SortByMultipleColumns() - { - var sortedColumns = multiColumnHeader.state.sortedColumns; - - if (sortedColumns.Length == 0) - return; - - var myTypes = rootItem.children.Cast>(); - var orderedQuery = InitialOrder(myTypes, sortedColumns); - for (int i = 1; i < sortedColumns.Length; i++) - { - SortOption sortOption = m_SortOptions[sortedColumns[i]]; - bool ascending = multiColumnHeader.IsSortedAscending(sortedColumns[i]); - - switch (sortOption) - { - case SortOption.Name: - orderedQuery = orderedQuery.ThenBy(l => l.data.Name, ascending); - break; - } - } - - rootItem.children = orderedQuery.Cast().ToList(); - } - - IOrderedEnumerable> InitialOrder(IEnumerable> myTypes, int[] history) - { - SortOption sortOption = m_SortOptions[history[0]]; - bool ascending = multiColumnHeader.IsSortedAscending(history[0]); - switch (sortOption) - { - case SortOption.Name: - return myTypes.Order(l => l.data.Name, ascending); - default: - Assert.IsTrue(false, "Unhandled enum"); - break; - } - - // default - return myTypes.Order(l => l.data.Name, ascending); - } - - protected override void ContextClickedItem(int id) - { - //var item = treeModel.Find(id); - GenericMenu menu = new GenericMenu(); - menu.CreateTypeMenu(OnMenuTypeSelected); - menu.ShowAsContext(); - } - - public void OnMenuTypeSelected(object itemTypeSelected) - { - object[] obj = itemTypeSelected as object[]; - BehaviorTreeElement element = obj[0] as BehaviorTreeElement; - element.ElementType = obj[1].ToString(); - element.Name = element.ElementType.Split('.').Last() + " " + element.ID; - Reload(); - } - - protected override void RowGUI(RowGUIArgs args) - { - var item = (TreeViewItem)args.item; - - for (int i = 0; i < args.GetNumVisibleColumns(); ++i) - { - CellGUI(args.GetCellRect(i), item, (BTreeColumns)args.GetColumn(i), ref args); - } - } - - void CellGUI(Rect cellRect, TreeViewItem item, BTreeColumns column, ref RowGUIArgs args) - { - // Center cell rect vertically (makes it easier to place controls, icons etc in the cells) - switch (column) - { - case BTreeColumns.State: - CenterRectUsingSingleLineHeight(ref cellRect); - //EditorGUI.DrawRect(cellRect, GetBehaviorStateColor((int)item.data.CurrentState)); - break; - case BTreeColumns.Name: - // Do toggle - CenterRectUsingSingleLineHeight(ref cellRect); - Rect toggleRect = cellRect; - toggleRect.x += GetContentIndent(item); - toggleRect.width = kToggleWidth; - - // Default icon and label - args.rowRect = cellRect; - base.RowGUI(args); - break; - case BTreeColumns.Parameters: - switch(ShowParams) - { - case ShowParameters.Active: - if (IsSelected(item.id)) - { - cellRect.height = TypeDependantDrawer.GetTotalHeightOfProperties(item.data); - TypeDependantDrawer.DrawAllFields(item.data, cellRect); - } - break; - case ShowParameters.All: - cellRect.height = TypeDependantDrawer.GetTotalHeightOfProperties(item.data); - TypeDependantDrawer.DrawAllFields(item.data, cellRect); - break; - default: - break; - } - args.rowRect = cellRect; - break; - } - } - - protected override void AfterRowsGUI() - { - base.AfterRowsGUI(); - RefreshCustomRowHeights(); - } - - protected override float GetCustomRowHeight(int row, TreeViewItem item) - { - float maxHeight = 0; - if((ShowParams.HasFlag(ShowParameters.Active) && IsSelected(item.id)) || - ShowParams.HasFlag(ShowParameters.All)) - { - maxHeight = TypeDependantDrawer.GetTotalHeightOfProperties((item as TreeViewItem).data); - } - return Math.Max(20f, maxHeight); - } - - // Rename - //-------- - - protected override bool CanRename(TreeViewItem item) - { - // Only allow rename if we can show the rename overlay with a certain width (label might be clipped by other columns) - Rect renameRect = GetRenameRect(treeViewRect, 0, item); - return renameRect.width > 30; - } - - protected override void RenameEnded(RenameEndedArgs args) - { - // Set the backend name and reload the tree to reflect the new model - if (args.acceptedRename) - { - var element = treeModel.Find(args.itemID); - element.Name = args.newName; - Reload(); - } - } - - protected override Rect GetRenameRect(Rect rowRect, int row, TreeViewItem item) - { - Rect cellRect = GetCellRectForTreeFoldouts(rowRect); - CenterRectUsingSingleLineHeight(ref cellRect); - return base.GetRenameRect(cellRect, row, item); - } - - // Misc - //-------- - - protected override bool CanMultiSelect(TreeViewItem item) - { - return true; - } - - public static MultiColumnHeaderState CreateDefaultMultiColumnHeaderState(float treeViewWidth) - { - var columns = new[] - { - new MultiColumnHeaderState.Column - { - headerContent = new GUIContent("State"), - headerTextAlignment = TextAlignment.Left, - width = 20, - minWidth = 10, - autoResize = true, - allowToggleVisibility = true - }, - new MultiColumnHeaderState.Column - { - headerContent = new GUIContent("Name"), - headerTextAlignment = TextAlignment.Left, - sortedAscending = true, - sortingArrowAlignment = TextAlignment.Center, - width = 125, - minWidth = 60, - autoResize = true, - allowToggleVisibility = false - }, - new MultiColumnHeaderState.Column - { - headerContent = new GUIContent("Parameters"), - headerTextAlignment = TextAlignment.Left, - width = 200, - minWidth = 60, - autoResize = true, - allowToggleVisibility = true - } - }; - - Assert.AreEqual(columns.Length, Enum.GetValues(typeof(BTreeColumns)).Length, "Number of columns should match number of enum values: You probably forgot to update one of them."); - - var state = new MultiColumnHeaderState(columns); - return state; - } - } -} +using Assets.Scripts.AI; +using Assets.Scripts.AI.Tree; +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.IMGUI.Controls; +using UnityEngine; +using UnityEngine.Assertions; + +namespace Assets.Editor.BehaviorTreeViewEditor.BackendData +{ + internal class MultiColumnBehaviorTreeView : TreeViewWithTreeModel + { + const float kRowHeights = 20f; + const float kToggleWidth = 18f; + const float kTypeButtonWidth = 70f; + public ShowParameters ShowParams; + + // All columns + enum BTreeColumns + { + State, + Name, + Parameters + } + + public enum SortOption + { + State, + Name, + Parameters + } + + public enum ShowParameters + { + None, + Active, + All + } + + // Sort options per column + SortOption[] m_SortOptions = + { + SortOption.State, + SortOption.Name, + SortOption.Parameters + }; + + public static void TreeToList(TreeViewItem root, IList result) + { + if (root == null) + throw new NullReferenceException("root"); + if (result == null) + throw new NullReferenceException("result"); + + result.Clear(); + + if (root.children == null) + return; + + Stack stack = new Stack(); + for (int i = root.children.Count - 1; i >= 0; i--) + stack.Push(root.children[i]); + + while (stack.Count > 0) + { + TreeViewItem current = stack.Pop(); + result.Add(current); + + if (current.hasChildren && current.children[0] != null) + { + for (int i = current.children.Count - 1; i >= 0; i--) + { + stack.Push(current.children[i]); + } + } + } + } + + public MultiColumnBehaviorTreeView(TreeViewState state, MultiColumnHeader multicolumnHeader, TreeModel model) + : base(state, multicolumnHeader, model) + { + Assert.AreEqual(m_SortOptions.Length, Enum.GetValues(typeof(BTreeColumns)).Length, "Ensure number of sort options are in sync with number of MyColumns enum values"); + + // Custom setup + columnIndexForTreeFoldouts = 1; + + showAlternatingRowBackgrounds = true; + showBorder = true; + customFoldoutYOffset = (kRowHeights - EditorGUIUtility.singleLineHeight) * 0.5f; // center foldout in the row since we also center content. See RowGUI + extraSpaceBeforeIconAndLabel = kToggleWidth; + multicolumnHeader.sortingChanged += OnSortingChanged; + + Reload(); + } + + + // Note we We only build the visible rows, only the backend has the full tree information. + // The treeview only creates info for the row list. + protected override IList BuildRows(TreeViewItem root) + { + var rows = base.BuildRows(root); + SortIfNeeded(root, rows); + return rows; + } + + void OnSortingChanged(MultiColumnHeader multiColumnHeader) + { + SortIfNeeded(rootItem, GetRows()); + } + + void SortIfNeeded(TreeViewItem root, IList rows) + { + if (rows.Count <= 1) + return; + + if (multiColumnHeader.sortedColumnIndex == -1) + { + return; // No column to sort for (just use the order the data are in) + } + + // Sort the roots of the existing tree items + SortByMultipleColumns(); + TreeToList(root, rows); + Repaint(); + } + + void SortByMultipleColumns() + { + var sortedColumns = multiColumnHeader.state.sortedColumns; + + if (sortedColumns.Length == 0) + return; + + var myTypes = rootItem.children.Cast>(); + var orderedQuery = InitialOrder(myTypes, sortedColumns); + for (int i = 1; i < sortedColumns.Length; i++) + { + SortOption sortOption = m_SortOptions[sortedColumns[i]]; + bool ascending = multiColumnHeader.IsSortedAscending(sortedColumns[i]); + + switch (sortOption) + { + case SortOption.Name: + orderedQuery = orderedQuery.ThenBy(l => l.data.Name, ascending); + break; + } + } + + rootItem.children = orderedQuery.Cast().ToList(); + } + + IOrderedEnumerable> InitialOrder(IEnumerable> myTypes, int[] history) + { + SortOption sortOption = m_SortOptions[history[0]]; + bool ascending = multiColumnHeader.IsSortedAscending(history[0]); + switch (sortOption) + { + case SortOption.Name: + return myTypes.Order(l => l.data.Name, ascending); + default: + Assert.IsTrue(false, "Unhandled enum"); + break; + } + + // default + return myTypes.Order(l => l.data.Name, ascending); + } + + protected override void ContextClickedItem(int id) + { + //var item = treeModel.Find(id); + GenericMenu menu = new GenericMenu(); + menu.CreateTypeMenu(OnMenuTypeSelected); + menu.ShowAsContext(); + } + + public void OnMenuTypeSelected(object itemTypeSelected) + { + Debug.Log(itemTypeSelected); + object[] obj = itemTypeSelected as object[]; + BehaviorTreeElement element = obj[0] as BehaviorTreeElement; + element.ElementType = obj[1].ToString(); + element.Name = element.ElementType.Split('.').Last() + " " + element.ID; + Reload(); + } + + protected override void RowGUI(RowGUIArgs args) + { + var item = (TreeViewItem)args.item; + + for (int i = 0; i < args.GetNumVisibleColumns(); ++i) + { + CellGUI(args.GetCellRect(i), item, (BTreeColumns)args.GetColumn(i), ref args); + } + } + + void CellGUI(Rect cellRect, TreeViewItem item, BTreeColumns column, ref RowGUIArgs args) + { + // Center cell rect vertically (makes it easier to place controls, icons etc in the cells) + switch (column) + { + case BTreeColumns.State: + CenterRectUsingSingleLineHeight(ref cellRect); + //EditorGUI.DrawRect(cellRect, GetBehaviorStateColor((int)item.data.CurrentState)); + break; + case BTreeColumns.Name: + // Do toggle + CenterRectUsingSingleLineHeight(ref cellRect); + Rect toggleRect = cellRect; + toggleRect.x += GetContentIndent(item); + toggleRect.width = kToggleWidth; + + // Default icon and label + args.rowRect = cellRect; + base.RowGUI(args); + break; + case BTreeColumns.Parameters: + switch(ShowParams) + { + case ShowParameters.Active: + if (IsSelected(item.id)) + { + //cellRect.height = TypeDependantDrawer.GetTotalHeightOfProperties(item.data); + //TypeDependantDrawer.DrawAllFields(item.data, cellRect); + } + break; + case ShowParameters.All: + //cellRect.height = TypeDependantDrawer.GetTotalHeightOfProperties(item.data); + //TypeDependantDrawer.DrawAllFields(item.data, cellRect); + break; + default: + break; + } + args.rowRect = cellRect; + break; + } + } + + protected override void AfterRowsGUI() + { + base.AfterRowsGUI(); + RefreshCustomRowHeights(); + } + + protected override float GetCustomRowHeight(int row, TreeViewItem item) + { + float maxHeight = 0; + if((ShowParams.HasFlag(ShowParameters.Active) && IsSelected(item.id)) || + ShowParams.HasFlag(ShowParameters.All)) + { + //maxHeight = TypeDependantDrawer.GetTotalHeightOfProperties((item as TreeViewItem).data); + } + return Math.Max(20f, maxHeight); + } + + // Rename + //-------- + + protected override bool CanRename(TreeViewItem item) + { + // Only allow rename if we can show the rename overlay with a certain width (label might be clipped by other columns) + Rect renameRect = GetRenameRect(treeViewRect, 0, item); + return renameRect.width > 30; + } + + protected override void RenameEnded(RenameEndedArgs args) + { + // Set the backend name and reload the tree to reflect the new model + if (args.acceptedRename) + { + var element = treeModel.Find(args.itemID); + element.Name = args.newName; + Reload(); + } + } + + protected override Rect GetRenameRect(Rect rowRect, int row, TreeViewItem item) + { + Rect cellRect = GetCellRectForTreeFoldouts(rowRect); + CenterRectUsingSingleLineHeight(ref cellRect); + return base.GetRenameRect(cellRect, row, item); + } + + // Misc + //-------- + + protected override bool CanMultiSelect(TreeViewItem item) + { + return true; + } + + public static MultiColumnHeaderState CreateDefaultMultiColumnHeaderState(float treeViewWidth) + { + var columns = new[] + { + new MultiColumnHeaderState.Column + { + headerContent = new GUIContent("State"), + headerTextAlignment = TextAlignment.Left, + width = 20, + minWidth = 10, + autoResize = true, + allowToggleVisibility = true + }, + new MultiColumnHeaderState.Column + { + headerContent = new GUIContent("Name"), + headerTextAlignment = TextAlignment.Left, + sortedAscending = true, + sortingArrowAlignment = TextAlignment.Center, + width = 125, + minWidth = 60, + autoResize = true, + allowToggleVisibility = false + }, + new MultiColumnHeaderState.Column + { + headerContent = new GUIContent("Parameters"), + headerTextAlignment = TextAlignment.Left, + width = 200, + minWidth = 60, + autoResize = true, + allowToggleVisibility = true + } + }; + + Assert.AreEqual(columns.Length, Enum.GetValues(typeof(BTreeColumns)).Length, "Number of columns should match number of enum values: You probably forgot to update one of them."); + + var state = new MultiColumnHeaderState(columns); + return state; + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBehaviorTreeView.cs.meta b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBehaviorTreeView.cs.meta index df77774..9b8245a 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBehaviorTreeView.cs.meta +++ b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/MultiColumnBehaviorTreeView.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: bc4d8ed3357bc4f4783234fc525745d3 -timeCreated: 1518236410 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: bc4d8ed3357bc4f4783234fc525745d3 +timeCreated: 1518236410 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/TreeViewWithTreeModel.cs b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/TreeViewWithTreeModel.cs index 8378c86..b1e1bff 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/TreeViewWithTreeModel.cs +++ b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/TreeViewWithTreeModel.cs @@ -1,248 +1,248 @@ -using Assets.Scripts.AI.Tree; -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using UnityEditor.IMGUI.Controls; -using UnityEngine; - - -namespace Assets.Editor.BehaviorTreeViewEditor.BackendData -{ - internal class TreeViewItem : TreeViewItem where T : TreeElement - { - public T data { get; set; } - - public TreeViewItem (int id, int depth, string displayName, T data) : base (id, depth, displayName) - { - this.data = data; - } - } - - internal class TreeViewWithTreeModel : TreeView where T : TreeElement - { - TreeModel _TreeModel; - readonly List _Rows = new List(100); - public event Action treeChanged; - - public TreeModel treeModel { get { return _TreeModel; } } - public event Action> beforeDroppingDraggedItems; - - public TreeViewWithTreeModel (TreeViewState state, TreeModel model) : base (state) - { - Init (model); - } - - public TreeViewWithTreeModel (TreeViewState state, MultiColumnHeader multiColumnHeader, TreeModel model) - : base(state, multiColumnHeader) - { - Init (model); - } - - void Init (TreeModel model) - { - _TreeModel = model; - _TreeModel.ModelChanged += ModelChanged; - - } - - void ModelChanged () - { - if (treeChanged != null) - treeChanged (); - - Reload (); - } - - protected override TreeViewItem BuildRoot() - { - int depthForHiddenRoot = -1; - - if(null == _TreeModel.Root) - { - Debug.LogError("Tree Model root is null!!"); - } - - return new TreeViewItem(_TreeModel.Root.ID, depthForHiddenRoot, _TreeModel.Root.Name, _TreeModel.Root); - } - - protected override IList BuildRows (TreeViewItem root) - { - if (_TreeModel.Root == null) - { - Debug.LogError ("tree model root is null. did you call SetData()?"); - } - - _Rows.Clear (); - if (!string.IsNullOrEmpty(searchString)) - { - Search (_TreeModel.Root, searchString, _Rows); - } - else - { - if (_TreeModel.Root.HasChildren) - AddChildrenRecursive(_TreeModel.Root, 0, _Rows); - } - - // We still need to setup the child parent information for the rows since this - // information is used by the TreeView internal logic (navigation, dragging etc) - SetupParentsAndChildrenFromDepths (root, _Rows); - - return _Rows; - } - - void AddChildrenRecursive (T parent, int depth, IList newRows) - { - foreach (T child in parent.Children) - { - var item = new TreeViewItem(child.ID, depth, child.Name, child); - newRows.Add(item); - - if (child.HasChildren) - { - if (IsExpanded(child.ID)) - { - AddChildrenRecursive (child, depth + 1, newRows); - } - else - { - item.children = CreateChildListForCollapsedParent(); - } - } - } - } - - void Search(T searchFromThis, string search, List result) - { - if (string.IsNullOrEmpty(search)) - throw new ArgumentException("Invalid search: cannot be null or empty", "search"); - - const int kItemDepth = 0; // tree is flattened when searching - - Stack stack = new Stack(); - foreach (var element in searchFromThis.Children) - stack.Push((T)element); - while (stack.Count > 0) - { - T current = stack.Pop(); - // Matches search? - if (current.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) - { - result.Add(new TreeViewItem(current.ID, kItemDepth, current.Name, current)); - } - - if (current.Children != null && current.Children.Count > 0) - { - foreach (var element in current.Children) - { - stack.Push((T)element); - } - } - } - SortSearchResult(result); - } - - protected virtual void SortSearchResult (List rows) - { - rows.Sort ((x,y) => EditorUtility.NaturalCompare (x.displayName, y.displayName)); // sort by displayName by default, can be overriden for multicolumn solutions - } - - protected override IList GetAncestors (int id) - { - return _TreeModel.GetAncestors(id); - } - - protected override IList GetDescendantsThatHaveChildren (int id) - { - return _TreeModel.GetDescendantsThatHaveChildren(id); - } - - - // Dragging - //----------- - - const string k_GenericDragID = "GenericDragColumnDragging"; - - protected override bool CanStartDrag (CanStartDragArgs args) - { - return true; - } - - protected override void SetupDragAndDrop(SetupDragAndDropArgs args) - { - if (hasSearch) - return; - - DragAndDrop.PrepareStartDrag(); - var draggedRows = GetRows().Where(item => args.draggedItemIDs.Contains(item.id)).ToList(); - DragAndDrop.SetGenericData(k_GenericDragID, draggedRows); - DragAndDrop.objectReferences = new UnityEngine.Object[] { }; // this IS required for dragging to work - string title = draggedRows.Count == 1 ? draggedRows[0].displayName : "< Multiple >"; - DragAndDrop.StartDrag (title); - } - - protected override DragAndDropVisualMode HandleDragAndDrop (DragAndDropArgs args) - { - // Check if we can handle the current drag data (could be dragged in from other areas/windows in the editor) - var draggedRows = DragAndDrop.GetGenericData(k_GenericDragID) as List; - if (draggedRows == null) - return DragAndDropVisualMode.None; - - // Parent item is null when dragging outside any tree view items. - switch (args.dragAndDropPosition) - { - case DragAndDropPosition.UponItem: - case DragAndDropPosition.BetweenItems: - { - bool validDrag = ValidDrag(args.parentItem, draggedRows); - if (args.performDrop && validDrag) - { - T parentData = ((TreeViewItem)args.parentItem).data; - OnDropDraggedElementsAtIndex(draggedRows, parentData, args.insertAtIndex == -1 ? 0 : args.insertAtIndex); - } - return validDrag ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None; - } - - case DragAndDropPosition.OutsideItems: - { - if (args.performDrop) - OnDropDraggedElementsAtIndex(draggedRows, _TreeModel.Root, _TreeModel.Root.Children.Count); - - return DragAndDropVisualMode.Move; - } - default: - Debug.LogError("Unhandled enum " + args.dragAndDropPosition); - return DragAndDropVisualMode.None; - } - } - - public virtual void OnDropDraggedElementsAtIndex (List draggedRows, T parent, int insertIndex) - { - if (beforeDroppingDraggedItems != null) - beforeDroppingDraggedItems (draggedRows); - - var draggedElements = new List (); - foreach (var x in draggedRows) - draggedElements.Add (((TreeViewItem) x).data); - - var selectedIDs = draggedElements.Select (x => x.ID).ToArray(); - _TreeModel.MoveElements (parent, insertIndex, draggedElements); - SetSelection(selectedIDs, TreeViewSelectionOptions.RevealAndFrame); - } - - - bool ValidDrag(TreeViewItem parent, List draggedItems) - { - TreeViewItem currentParent = parent; - while (currentParent != null) - { - if (draggedItems.Contains(currentParent)) - return false; - currentParent = currentParent.parent; - } - return true; - } - - } - -} +using Assets.Scripts.AI.Tree; +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.IMGUI.Controls; +using UnityEngine; + + +namespace Assets.Editor.BehaviorTreeViewEditor.BackendData +{ + internal class TreeViewItem : TreeViewItem where T : TreeElement + { + public T data { get; set; } + + public TreeViewItem (int id, int depth, string displayName, T data) : base (id, depth, displayName) + { + this.data = data; + } + } + + internal class TreeViewWithTreeModel : TreeView where T : TreeElement + { + TreeModel _TreeModel; + readonly List _Rows = new List(100); + public event Action treeChanged; + + public TreeModel treeModel { get { return _TreeModel; } } + public event Action> beforeDroppingDraggedItems; + + public TreeViewWithTreeModel (TreeViewState state, TreeModel model) : base (state) + { + Init (model); + } + + public TreeViewWithTreeModel (TreeViewState state, MultiColumnHeader multiColumnHeader, TreeModel model) + : base(state, multiColumnHeader) + { + Init (model); + } + + void Init (TreeModel model) + { + _TreeModel = model; + _TreeModel.ModelChanged += ModelChanged; + + } + + void ModelChanged () + { + if (treeChanged != null) + treeChanged (); + + Reload (); + } + + protected override TreeViewItem BuildRoot() + { + int depthForHiddenRoot = -1; + + if(null == _TreeModel.Root) + { + Debug.LogError("Tree Model root is null!!"); + } + + return new TreeViewItem(_TreeModel.Root.ID, depthForHiddenRoot, _TreeModel.Root.Name, _TreeModel.Root); + } + + protected override IList BuildRows (TreeViewItem root) + { + if (_TreeModel.Root == null) + { + Debug.LogError ("tree model root is null. did you call SetData()?"); + } + + _Rows.Clear (); + if (!string.IsNullOrEmpty(searchString)) + { + Search (_TreeModel.Root, searchString, _Rows); + } + else + { + if (_TreeModel.Root.HasChildren) + AddChildrenRecursive(_TreeModel.Root, 0, _Rows); + } + + // We still need to setup the child parent information for the rows since this + // information is used by the TreeView internal logic (navigation, dragging etc) + SetupParentsAndChildrenFromDepths (root, _Rows); + + return _Rows; + } + + void AddChildrenRecursive (T parent, int depth, IList newRows) + { + foreach (T child in parent.Children) + { + var item = new TreeViewItem(child.ID, depth, child.Name, child); + newRows.Add(item); + + if (child.HasChildren) + { + if (IsExpanded(child.ID)) + { + AddChildrenRecursive (child, depth + 1, newRows); + } + else + { + item.children = CreateChildListForCollapsedParent(); + } + } + } + } + + void Search(T searchFromThis, string search, List result) + { + if (string.IsNullOrEmpty(search)) + throw new ArgumentException("Invalid search: cannot be null or empty", "search"); + + const int kItemDepth = 0; // tree is flattened when searching + + Stack stack = new Stack(); + foreach (var element in searchFromThis.Children) + stack.Push((T)element); + while (stack.Count > 0) + { + T current = stack.Pop(); + // Matches search? + if (current.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) + { + result.Add(new TreeViewItem(current.ID, kItemDepth, current.Name, current)); + } + + if (current.Children != null && current.Children.Count > 0) + { + foreach (var element in current.Children) + { + stack.Push((T)element); + } + } + } + SortSearchResult(result); + } + + protected virtual void SortSearchResult (List rows) + { + rows.Sort ((x,y) => EditorUtility.NaturalCompare (x.displayName, y.displayName)); // sort by displayName by default, can be overriden for multicolumn solutions + } + + protected override IList GetAncestors (int id) + { + return _TreeModel.GetAncestors(id); + } + + protected override IList GetDescendantsThatHaveChildren (int id) + { + return _TreeModel.GetDescendantsThatHaveChildren(id); + } + + + // Dragging + //----------- + + const string k_GenericDragID = "GenericDragColumnDragging"; + + protected override bool CanStartDrag (CanStartDragArgs args) + { + return true; + } + + protected override void SetupDragAndDrop(SetupDragAndDropArgs args) + { + if (hasSearch) + return; + + DragAndDrop.PrepareStartDrag(); + var draggedRows = GetRows().Where(item => args.draggedItemIDs.Contains(item.id)).ToList(); + DragAndDrop.SetGenericData(k_GenericDragID, draggedRows); + DragAndDrop.objectReferences = new UnityEngine.Object[] { }; // this IS required for dragging to work + string title = draggedRows.Count == 1 ? draggedRows[0].displayName : "< Multiple >"; + DragAndDrop.StartDrag (title); + } + + protected override DragAndDropVisualMode HandleDragAndDrop (DragAndDropArgs args) + { + // Check if we can handle the current drag data (could be dragged in from other areas/windows in the editor) + var draggedRows = DragAndDrop.GetGenericData(k_GenericDragID) as List; + if (draggedRows == null) + return DragAndDropVisualMode.None; + + // Parent item is null when dragging outside any tree view items. + switch (args.dragAndDropPosition) + { + case DragAndDropPosition.UponItem: + case DragAndDropPosition.BetweenItems: + { + bool validDrag = ValidDrag(args.parentItem, draggedRows); + if (args.performDrop && validDrag) + { + T parentData = ((TreeViewItem)args.parentItem).data; + OnDropDraggedElementsAtIndex(draggedRows, parentData, args.insertAtIndex == -1 ? 0 : args.insertAtIndex); + } + return validDrag ? DragAndDropVisualMode.Move : DragAndDropVisualMode.None; + } + + case DragAndDropPosition.OutsideItems: + { + if (args.performDrop) + OnDropDraggedElementsAtIndex(draggedRows, _TreeModel.Root, _TreeModel.Root.Children.Count); + + return DragAndDropVisualMode.Move; + } + default: + Debug.LogError("Unhandled enum " + args.dragAndDropPosition); + return DragAndDropVisualMode.None; + } + } + + public virtual void OnDropDraggedElementsAtIndex (List draggedRows, T parent, int insertIndex) + { + if (beforeDroppingDraggedItems != null) + beforeDroppingDraggedItems (draggedRows); + + var draggedElements = new List (); + foreach (var x in draggedRows) + draggedElements.Add (((TreeViewItem) x).data); + + var selectedIDs = draggedElements.Select (x => x.ID).ToArray(); + _TreeModel.MoveElements (parent, insertIndex, draggedElements); + SetSelection(selectedIDs, TreeViewSelectionOptions.RevealAndFrame); + } + + + bool ValidDrag(TreeViewItem parent, List draggedItems) + { + TreeViewItem currentParent = parent; + while (currentParent != null) + { + if (draggedItems.Contains(currentParent)) + return false; + currentParent = currentParent.parent; + } + return true; + } + + } + +} diff --git a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/TreeViewWithTreeModel.cs.meta b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/TreeViewWithTreeModel.cs.meta index 5077bf7..2cff069 100644 --- a/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/TreeViewWithTreeModel.cs.meta +++ b/Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData/TreeViewWithTreeModel.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: 68fe63fd42552e7418aac450b41b8afb -timeCreated: 1472481611 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 68fe63fd42552e7418aac450b41b8afb +timeCreated: 1472481611 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/BuiltInResourcesWindow.cs b/Assets/Visual Behavior Tree/Editor/BuiltInResourcesWindow.cs new file mode 100644 index 0000000..0c36d22 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/BuiltInResourcesWindow.cs @@ -0,0 +1,229 @@ +using System; +using UnityEditor; +using UnityEngine; +using System.Collections.Generic; + +namespace Assets.Editor.BehaviorTreeViewEditor.BackendData +{ + public class BuiltInResourcesWindow : EditorWindow + { + [MenuItem("Window/Built-in styles and icons")] + public static void ShowWindow() + { + BuiltInResourcesWindow w = (BuiltInResourcesWindow)EditorWindow.GetWindow(); + w.Show(); + } + + private struct Drawing + { + public Rect Rect; + public Action Draw; + } + + private List Drawings; + + private List _objects; + private float _scrollPos; + private float _maxY; + private Rect _oldPosition; + + private bool _showingStyles = true; + private bool _showingIcons = false; + + private string _search = ""; + + void OnGUI() + { + if (position.width != _oldPosition.width && Event.current.type == EventType.Layout) + { + Drawings = null; + _oldPosition = position; + } + + GUILayout.BeginHorizontal(); + + if (GUILayout.Toggle(_showingStyles, "Styles", EditorStyles.toolbarButton) != _showingStyles) + { + _showingStyles = !_showingStyles; + _showingIcons = !_showingStyles; + Drawings = null; + } + + if (GUILayout.Toggle(_showingIcons, "Icons", EditorStyles.toolbarButton) != _showingIcons) + { + _showingIcons = !_showingIcons; + _showingStyles = !_showingIcons; + Drawings = null; + } + + GUILayout.EndHorizontal(); + + string newSearch = GUILayout.TextField(_search); + if (newSearch != _search) + { + _search = newSearch; + Drawings = null; + } + + float top = 36; + + if (Drawings == null) + { + string lowerSearch = _search.ToLower(); + + Drawings = new List(); + + GUIContent inactiveText = new GUIContent("inactive"); + GUIContent activeText = new GUIContent("active"); + + float x = 5.0f; + float y = 5.0f; + + if (_showingStyles) + { + foreach (GUIStyle ss in GUI.skin.customStyles) + { + if (lowerSearch != "" && !ss.name.ToLower().Contains(lowerSearch)) + continue; + + GUIStyle thisStyle = ss; + + Drawing draw = new Drawing(); + + float width = Mathf.Max( + 100.0f, + GUI.skin.button.CalcSize(new GUIContent(ss.name)).x, + ss.CalcSize(inactiveText).x + ss.CalcSize(activeText).x + ) + 16.0f; + + float height = 60.0f; + + if (x + width > position.width - 32 && x > 5.0f) + { + x = 5.0f; + y += height + 10.0f; + } + + draw.Rect = new Rect(x, y, width, height); + + width -= 8.0f; + + draw.Draw = () => + { + if (GUILayout.Button(thisStyle.name, GUILayout.Width(width))) + CopyText("(GUIStyle)\"" + thisStyle.name + "\""); + + GUILayout.BeginHorizontal(); + GUILayout.Toggle(false, inactiveText, thisStyle, GUILayout.Width(width / 2)); + GUILayout.Toggle(false, activeText, thisStyle, GUILayout.Width(width / 2)); + GUILayout.EndHorizontal(); + }; + + x += width + 18.0f; + + Drawings.Add(draw); + } + } + else if (_showingIcons) + { + if (_objects == null) + { + _objects = new List(Resources.FindObjectsOfTypeAll(typeof(Texture))); + _objects.Sort((pA, pB) => System.String.Compare(pA.name, pB.name, System.StringComparison.OrdinalIgnoreCase)); + } + + float rowHeight = 0.0f; + + foreach (UnityEngine.Object oo in _objects) + { + Texture texture = (Texture)oo; + + if (texture.name == "") + continue; + + if (lowerSearch != "" && !texture.name.ToLower().Contains(lowerSearch)) + continue; + + Drawing draw = new Drawing(); + + float width = Mathf.Max( + GUI.skin.button.CalcSize(new GUIContent(texture.name)).x, + texture.width + ) + 8.0f; + + float height = texture.height + GUI.skin.button.CalcSize(new GUIContent(texture.name)).y + 8.0f; + + if (x + width > position.width - 32.0f) + { + x = 5.0f; + y += rowHeight + 8.0f; + rowHeight = 0.0f; + } + + draw.Rect = new Rect(x, y, width, height); + + rowHeight = Mathf.Max(rowHeight, height); + + width -= 8.0f; + + draw.Draw = () => + { + if (GUILayout.Button(texture.name, GUILayout.Width(width))) + CopyText("EditorGUIUtility.FindTexture( \"" + texture.name + "\" )"); + + Rect textureRect = GUILayoutUtility.GetRect(texture.width, texture.width, texture.height, texture.height, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)); + EditorGUI.DrawTextureTransparent(textureRect, texture); + }; + + x += width + 8.0f; + + Drawings.Add(draw); + } + } + + _maxY = y; + } + + Rect r = position; + r.y = top; + r.height -= r.y; + r.x = r.width - 16; + r.width = 16; + + float areaHeight = position.height - top; + _scrollPos = GUI.VerticalScrollbar(r, _scrollPos, areaHeight, 0.0f, _maxY); + + Rect area = new Rect(0, top, position.width - 16.0f, areaHeight); + GUILayout.BeginArea(area); + + int count = 0; + foreach (Drawing draw in Drawings) + { + Rect newRect = draw.Rect; + newRect.y -= _scrollPos; + + if (newRect.y + newRect.height > 0 && newRect.y < areaHeight) + { + GUILayout.BeginArea(newRect, GUI.skin.textField); + draw.Draw(); + GUILayout.EndArea(); + + count++; + } + } + + GUILayout.EndArea(); + } + + void CopyText(string pText) + { + TextEditor editor = new TextEditor(); + + //editor.content = new GUIContent(pText); // Unity 4.x code + editor.text = pText; // Unity 5.x code + + editor.SelectAll(); + editor.Copy(); + } + } +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/BuiltInResourcesWindow.cs.meta b/Assets/Visual Behavior Tree/Editor/BuiltInResourcesWindow.cs.meta new file mode 100644 index 0000000..28c0361 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/BuiltInResourcesWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9bf60dacfc064644aa383caa186d105e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/CustomAssetUtitlity.cs b/Assets/Visual Behavior Tree/Editor/CustomAssetUtitlity.cs index 8040170..0694f0f 100644 --- a/Assets/Visual Behavior Tree/Editor/CustomAssetUtitlity.cs +++ b/Assets/Visual Behavior Tree/Editor/CustomAssetUtitlity.cs @@ -1,30 +1,30 @@ -using UnityEngine; -using UnityEditor; -using System.IO; - -public static class CustomAssetUtility -{ - public static void CreateAsset(string name = "") where T : ScriptableObject - { - T asset = ScriptableObject.CreateInstance(); - - string path = AssetDatabase.GetAssetPath(Selection.activeObject); - if (path == "") - { - path = "Assets/Visual Behavior Tree/Examples"; - } - else if (Path.GetExtension(path) != "") - { - path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); - } - - string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/" + - (name == "" ? "New "+ typeof(T).Name.ToString() : name) + ".asset"); - - AssetDatabase.CreateAsset(asset, assetPathAndName); - - AssetDatabase.SaveAssets(); - EditorUtility.FocusProjectWindow(); - Selection.activeObject = asset; - } +using UnityEngine; +using UnityEditor; +using System.IO; + +public static class CustomAssetUtility +{ + public static void CreateAsset(string name = "") where T : ScriptableObject + { + T asset = ScriptableObject.CreateInstance(); + + string path = AssetDatabase.GetAssetPath(Selection.activeObject); + if (path == "") + { + path = "Assets/Visual Behavior Tree/Examples"; + } + else if (Path.GetExtension(path) != "") + { + path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); + } + + string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/" + + (name == "" ? "New "+ typeof(T).Name.ToString() : name) + ".asset"); + + AssetDatabase.CreateAsset(asset, assetPathAndName); + + AssetDatabase.SaveAssets(); + EditorUtility.FocusProjectWindow(); + Selection.activeObject = asset; + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/CustomAssetUtitlity.cs.meta b/Assets/Visual Behavior Tree/Editor/CustomAssetUtitlity.cs.meta index 9745e87..79bc2e6 100644 --- a/Assets/Visual Behavior Tree/Editor/CustomAssetUtitlity.cs.meta +++ b/Assets/Visual Behavior Tree/Editor/CustomAssetUtitlity.cs.meta @@ -1,13 +1,13 @@ -fileFormatVersion: 2 -guid: 4bae2ef2c7aaaa74fa70d0029c78ffa8 -timeCreated: 1518939824 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 4bae2ef2c7aaaa74fa70d0029c78ffa8 +timeCreated: 1518939824 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/CustomGUI.cs b/Assets/Visual Behavior Tree/Editor/CustomGUI.cs deleted file mode 100644 index 1ea651d..0000000 --- a/Assets/Visual Behavior Tree/Editor/CustomGUI.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -namespace Assets.Editor -{ - public static class CustomGUI - { - //Taken from https://answers.unity.com/questions/37752/how-to-render-a-colored-2d-rectangle.html - private static List> quadTextures = new List>(); - public static void DrawQuad(Rect position, Color color) - { - var tmp = quadTextures.Find(t => t.Key == color); - Texture2D texture; - if (tmp.Equals(default(KeyValuePair))) - { - texture = new Texture2D(1, 1); - texture.SetPixel(0, 0, color); - texture.Apply(); - quadTextures.Add(new KeyValuePair(color, texture)); - } - else - { - texture = tmp.Value; - } - - GUI.skin.box.normal.background = texture; - GUI.Box(position, GUIContent.none); - } - } -} diff --git a/Assets/Visual Behavior Tree/Editor/CustomGUI.cs.meta b/Assets/Visual Behavior Tree/Editor/CustomGUI.cs.meta deleted file mode 100644 index 96c7e92..0000000 --- a/Assets/Visual Behavior Tree/Editor/CustomGUI.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 3e87cbdeec6c288478c89e98393c507f -timeCreated: 1524003509 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/Drawing.meta b/Assets/Visual Behavior Tree/Editor/Drawing.meta new file mode 100644 index 0000000..9a79f3a --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/Drawing.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 58ebc041830a470429990bfaf8acd8ca +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/EditorList.cs b/Assets/Visual Behavior Tree/Editor/EditorList.cs index 379cfb5..0f60974 100644 --- a/Assets/Visual Behavior Tree/Editor/EditorList.cs +++ b/Assets/Visual Behavior Tree/Editor/EditorList.cs @@ -1,124 +1,124 @@ -using UnityEditor; -using UnityEngine; -using System; - -namespace Assets.Editor -{ - [Flags] - public enum EditorListOption - { - None = 0, - ListSize = 1, - ListLabel = 2, - ElementLabels = 4, - Buttons = 8, - Default = ListSize | ListLabel | ElementLabels, - NoElementLabels = ListSize | ListLabel, - All = Default | Buttons - } - - public static class EditorList - { - - private static GUIContent - moveButtonContent = new GUIContent("\u21b4", "move down"), - duplicateButtonContent = new GUIContent("+", "duplicate"), - deleteButtonContent = new GUIContent("-", "delete"), - addButtonContent = new GUIContent("+", "add element"); - - private static GUILayoutOption miniButtonWidth = GUILayout.Width(20f); - - public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default) - { - if (!list.isArray) - { - EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error); - return; - } - - bool - showListLabel = (options & EditorListOption.ListLabel) != 0, - showListSize = (options & EditorListOption.ListSize) != 0; - - if (showListLabel) - { - EditorGUILayout.PropertyField(list); - EditorGUI.indentLevel += 1; - } - if (!showListLabel || list.isExpanded) - { - SerializedProperty size = list.FindPropertyRelative("Array.size"); - if (showListSize) - { - EditorGUILayout.PropertyField(size); - } - if (size.hasMultipleDifferentValues) - { - EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info); - } - else - { - ShowElements(list, options); - } - } - if (showListLabel) - { - EditorGUI.indentLevel -= 1; - } - } - - private static void ShowElements(SerializedProperty list, EditorListOption options) - { - bool - showElementLabels = (options & EditorListOption.ElementLabels) != 0, - showButtons = (options & EditorListOption.Buttons) != 0; - - for (int i = 0; i < list.arraySize; i++) - { - if (showButtons) - { - EditorGUILayout.BeginHorizontal(); - } - if (showElementLabels) - { - var element = list.GetArrayElementAtIndex(i); - EditorGUILayout.PropertyField(element); - } - else - { - EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none); - } - if (showButtons) - { - ShowButtons(list, i); - EditorGUILayout.EndHorizontal(); - } - } - if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton)) - { - list.arraySize += 1; - } - } - - private static void ShowButtons(SerializedProperty list, int index) - { - if (GUILayout.Button(moveButtonContent, EditorStyles.miniButtonLeft, miniButtonWidth)) - { - list.MoveArrayElement(index, index + 1); - } - if (GUILayout.Button(duplicateButtonContent, EditorStyles.miniButtonMid, miniButtonWidth)) - { - list.InsertArrayElementAtIndex(index); - } - if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButtonRight, miniButtonWidth)) - { - int oldSize = list.arraySize; - list.DeleteArrayElementAtIndex(index); - if (list.arraySize == oldSize) - { - list.DeleteArrayElementAtIndex(index); - } - } - } - } +using UnityEditor; +using UnityEngine; +using System; + +namespace Assets.Editor +{ + [Flags] + public enum EditorListOption + { + None = 0, + ListSize = 1, + ListLabel = 2, + ElementLabels = 4, + Buttons = 8, + Default = ListSize | ListLabel | ElementLabels, + NoElementLabels = ListSize | ListLabel, + All = Default | Buttons + } + + public static class EditorList + { + + private static GUIContent + moveButtonContent = new GUIContent("\u21b4", "move down"), + duplicateButtonContent = new GUIContent("+", "duplicate"), + deleteButtonContent = new GUIContent("-", "delete"), + addButtonContent = new GUIContent("+", "add element"); + + private static GUILayoutOption miniButtonWidth = GUILayout.Width(20f); + + public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default) + { + if (!list.isArray) + { + EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error); + return; + } + + bool + showListLabel = (options & EditorListOption.ListLabel) != 0, + showListSize = (options & EditorListOption.ListSize) != 0; + + if (showListLabel) + { + EditorGUILayout.PropertyField(list); + EditorGUI.indentLevel += 1; + } + if (!showListLabel || list.isExpanded) + { + SerializedProperty size = list.FindPropertyRelative("Array.size"); + if (showListSize) + { + EditorGUILayout.PropertyField(size); + } + if (size.hasMultipleDifferentValues) + { + EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info); + } + else + { + ShowElements(list, options); + } + } + if (showListLabel) + { + EditorGUI.indentLevel -= 1; + } + } + + private static void ShowElements(SerializedProperty list, EditorListOption options) + { + bool + showElementLabels = (options & EditorListOption.ElementLabels) != 0, + showButtons = (options & EditorListOption.Buttons) != 0; + + for (int i = 0; i < list.arraySize; i++) + { + if (showButtons) + { + EditorGUILayout.BeginHorizontal(); + } + if (showElementLabels) + { + var element = list.GetArrayElementAtIndex(i); + EditorGUILayout.PropertyField(element); + } + else + { + EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none); + } + if (showButtons) + { + ShowButtons(list, i); + EditorGUILayout.EndHorizontal(); + } + } + if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton)) + { + list.arraySize += 1; + } + } + + private static void ShowButtons(SerializedProperty list, int index) + { + if (GUILayout.Button(moveButtonContent, EditorStyles.miniButtonLeft, miniButtonWidth)) + { + list.MoveArrayElement(index, index + 1); + } + if (GUILayout.Button(duplicateButtonContent, EditorStyles.miniButtonMid, miniButtonWidth)) + { + list.InsertArrayElementAtIndex(index); + } + if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButtonRight, miniButtonWidth)) + { + int oldSize = list.arraySize; + list.DeleteArrayElementAtIndex(index); + if (list.arraySize == oldSize) + { + list.DeleteArrayElementAtIndex(index); + } + } + } + } } \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/EditorList.cs.meta b/Assets/Visual Behavior Tree/Editor/EditorList.cs.meta index 0b8074f..0a71b59 100644 --- a/Assets/Visual Behavior Tree/Editor/EditorList.cs.meta +++ b/Assets/Visual Behavior Tree/Editor/EditorList.cs.meta @@ -1,12 +1,12 @@ -fileFormatVersion: 2 -guid: 2e8e452db8c3f44fdb9b2c25ba5e641a -timeCreated: 18446744011573954816 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: 2e8e452db8c3f44fdb9b2c25ba5e641a +timeCreated: 18446744011573954816 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor.meta b/Assets/Visual Behavior Tree/Editor/NodeEditor.meta new file mode 100644 index 0000000..ac4476f --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 70ef418e18b24764ba79b3f065be76c2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorEditorNode.cs b/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorEditorNode.cs new file mode 100644 index 0000000..694bd37 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorEditorNode.cs @@ -0,0 +1,188 @@ +using Assets.Editor; +using Assets.Scripts.AI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEditor; +using UnityEngine; +using System.Reflection; + +namespace Assets.Visual_Behavior_Tree.Editor.NodeEditor +{ + public class BehaviorEditorNode + { + public Rect fullRect; + public Rect subInspectorRect; + + public string title; + public int titleSize = 10; + + public bool isDragged; + public bool isSelected; + + [SerializeField] + public BehaviorTreeElement treeElement; + + public SerializedObject elementObject; + + public ConnectionPoint inPoint; + public ConnectionPoint outPoint; + + private GUIStyle inPointStyle; + private GUIStyle outPointStyle; + + public GUIStyle style; + public GUIStyle defaultNodeStyle; + public GUIStyle selectedNodeStyle; + + public Action OnRemoveNode; + + public BehaviorEditorNode(Vector2 position, float width, float height, BehaviorTreeElement element, Action OnClickInPoint, Action OnClickOutPoint, Action OnClickRemoveNode) + { + fullRect = new Rect(position.x, position.y, width, height); + + style = new GUIStyle(); + style.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/node1.png") as Texture2D; + style.border = new RectOffset(12, 12, 12, 12); + + defaultNodeStyle = style; + + selectedNodeStyle = new GUIStyle(); + selectedNodeStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/node1 on.png") as Texture2D; + selectedNodeStyle.border = new RectOffset(12, 12, 12, 12); + + inPointStyle = new GUIStyle(); + inPointStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/btn left.png") as Texture2D; + inPointStyle.active.background = EditorGUIUtility.Load("builtin skins/darkskin/images/btn left on.png") as Texture2D; + inPointStyle.border = new RectOffset(4, 4, 12, 12); + + outPointStyle = new GUIStyle(); + outPointStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/btn right.png") as Texture2D; + outPointStyle.active.background = EditorGUIUtility.Load("builtin skins/darkskin/images/btn right on.png") as Texture2D; + outPointStyle.border = new RectOffset(4, 4, 12, 12); + + inPoint = new ConnectionPoint(this, ConnectionPointType.In, inPointStyle, OnClickInPoint); + outPoint = new ConnectionPoint(this, ConnectionPointType.Out, outPointStyle, OnClickOutPoint); + + Vector2 inPointSize = inPoint.rect.size; + Vector2 outPointSize = outPoint.rect.size; + + subInspectorRect = new Rect(position.x + inPointSize.x, position.y + titleSize, width - inPointSize.x - outPointSize.x, height - (titleSize * 2)); + + treeElement = element; + elementObject = new SerializedObject(treeElement); + + title = treeElement.Name; + + OnRemoveNode = OnClickRemoveNode; + } + + public void Drag(Vector2 delta) + { + fullRect.position += delta; + subInspectorRect.position += delta; + } + + public void Draw() + { + inPoint.Draw(); + if(treeElement.CanHaveChildren) + outPoint.Draw(); + + GUI.Box(fullRect, title, style); + GUI.Box(subInspectorRect, "", selectedNodeStyle); + + Type type = Assembly.GetAssembly(typeof(BehaviorTreeElement)).GetType(treeElement.ElementType); + FieldInfo[] fields = type.GetFields(); + + var items = new List(); + foreach (FieldInfo field in fields) + { + items.Add(field.Name); + } + + var objStyle = EditorStyles.objectField; + var boxes = EditorGUIUtility.GetFlowLayoutedRects(subInspectorRect, objStyle, 2, 0, items); + for (int i = 0; i < items.Count; ++i) + { + var box = boxes[i]; + box.x = box.x + 7; + box.y = box.y + 9; + box.xMax = subInspectorRect.xMax - 10; + using (new GUILayout.AreaScope(box, "")) + { + var prop = elementObject.FindProperty(items[i]); + + GUILayout.BeginHorizontal(); + var label = new GUIContent(prop.displayName,prop.displayName); + EditorGUILayout.LabelField(label, EditorStyles.whiteLabel, GUILayout.MinWidth(45), GUILayout.ExpandWidth(true)); + EditorGUILayout.PropertyField(prop, GUIContent.none, true, GUILayout.MinWidth(95), GUILayout.ExpandWidth(true)); + GUILayout.EndHorizontal(); + } + } + elementObject.ApplyModifiedProperties(); + } + + public bool ProcessEvents(Event e) + { + switch (e.type) + { + case EventType.MouseDown: + if (e.button == 0) + { + if (fullRect.Contains(e.mousePosition)) + { + isDragged = true; + GUI.changed = true; + isSelected = true; + style = selectedNodeStyle; + } + else + { + GUI.changed = true; + isSelected = false; + style = defaultNodeStyle; + } + } + + if (e.button == 1 && isSelected && fullRect.Contains(e.mousePosition)) + { + ProcessContextMenu(); + e.Use(); + } + break; + + case EventType.MouseUp: + isDragged = false; + break; + + case EventType.MouseDrag: + if (e.button == 0 && isDragged) + { + Drag(e.delta); + e.Use(); + return true; + } + break; + } + + return false; + } + + private void ProcessContextMenu() + { + GenericMenu genericMenu = new GenericMenu(); + genericMenu.AddItem(new GUIContent("Remove node"), false, OnClickRemoveNode); + genericMenu.ShowAsContext(); + } + + private void OnClickRemoveNode() + { + OnRemoveNode?.Invoke(this); + } + } + + +} diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorEditorNode.cs.meta b/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorEditorNode.cs.meta new file mode 100644 index 0000000..5ca6399 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorEditorNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 254964a679f134e418054923f120d496 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorNodeEditorWindow.cs b/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorNodeEditorWindow.cs new file mode 100644 index 0000000..0f6a17f --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorNodeEditorWindow.cs @@ -0,0 +1,343 @@ +using Assets.Editor; +using Assets.Scripts.AI; +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace Assets.Visual_Behavior_Tree.Editor.NodeEditor +{ + public class BehaviorNodeEditorWindow : EditorWindow + { + private List nodes; + private List connections; + + private GUIStyle nodeStyle; + private GUIStyle selectedNodeStyle; + + private ConnectionPoint selectedInPoint; + private ConnectionPoint selectedOutPoint; + + private Vector2 offset; + private Vector2 drag; + + [MenuItem("Window/uVBT/Node Editor")] + private static void OpenWindow() + { + BehaviorNodeEditorWindow window = GetWindow(); + window.titleContent = new GUIContent("Behavior Node Editor"); + } + + private void OnEnable() + { + selectedNodeStyle = new GUIStyle(); + selectedNodeStyle.normal.background = EditorGUIUtility.Load("builtin skins/lightskin/images/node6 on.png") as Texture2D; + selectedNodeStyle.border = new RectOffset(10, 10, 10, 10); + } + + protected virtual void OnGUI() + { + DrawToolbar(); + + DrawGrid(20, 0.2f, Color.gray); + DrawGrid(100, 0.4f, Color.gray); + + DrawNodes(); + DrawConnections(); + + DrawConnectionLine(Event.current); + + ProcessNodeEvents(Event.current); + ProcessEvents(Event.current); + + if (GUI.changed) Repaint(); + } + + protected void DrawToolbar() + { + if(GUILayout.Button("Save")) { + SaveAllNodesToFile(); + } + if (GUILayout.Button("Load")) + { + LoadNodesFromFile(); + } + } + + protected void DrawGrid(float gridSpacing, float gridOpacity, Color gridColor) + { + int widthDivs = Mathf.CeilToInt(position.width / gridSpacing); + int heightDivs = Mathf.CeilToInt(position.height / gridSpacing); + + Handles.BeginGUI(); + Handles.color = new Color(gridColor.r, gridColor.g, gridColor.b, gridOpacity); + + offset += drag * 0.5f; + Vector3 newOffset = new Vector3(offset.x % gridSpacing, offset.y % gridSpacing, 0); + + for (int i = 0; i < widthDivs; i++) + { + Handles.DrawLine(new Vector3(gridSpacing * i, -gridSpacing, 0) + newOffset, new Vector3(gridSpacing * i, position.height, 0f) + newOffset); + } + + for (int j = 0; j < heightDivs; j++) + { + Handles.DrawLine(new Vector3(-gridSpacing, gridSpacing * j, 0) + newOffset, new Vector3(position.width, gridSpacing * j, 0f) + newOffset); + } + + Handles.color = Color.white; + Handles.EndGUI(); + } + + protected void DrawNodes() + { + if(nodes != null) + { + for (int i = 0; i < nodes.Count; i++) + { + nodes[i].Draw(); + } + } + } + + protected void DrawConnections() + { + if (connections != null) + { + for (int i = 0; i < connections.Count; i++) + { + connections[i].Draw(); + } + } + } + + protected void DrawConnectionLine(Event e) + { + if (selectedInPoint != null) + { + Handles.DrawLine(selectedInPoint.rect.center, + e.mousePosition); + GUI.changed = true; + } + + if (selectedOutPoint != null) + { + Handles.DrawLine(selectedOutPoint.rect.center, + e.mousePosition); + + GUI.changed = true; + } + } + + protected void ProcessEvents(Event e) + { + drag = Vector2.zero; + + switch (e.type) + { + case EventType.MouseDown: + if (e.button == 1) + { + ProcessContextMenu(e.mousePosition); + } + break; + + case EventType.MouseDrag: + if (e.button == 0) + { + OnDrag(e.delta); + } + break; + } + } + + protected void ProcessNodeEvents(Event e) + { + if (nodes != null) + { + for (int i = nodes.Count - 1; i >= 0; i--) + { + bool guiChanged = nodes[i].ProcessEvents(e); + + if (guiChanged) + { + GUI.changed = true; + } + } + } + } + + protected void ProcessContextMenu(Vector2 mousePosition) + { + GenericMenu genericMenu = new GenericMenu(); + genericMenu.CreateTypeMenu((typeName) => OnClickAddNode(mousePosition, typeName)); + genericMenu.ShowAsContext(); + } + + protected void OnClickAddNode(Vector2 mousePosition, object itemTypeSelected) + { + if (nodes == null) + { + nodes = new List(); + } + Debug.Log((string)itemTypeSelected); + Type type = typeof(BehaviorTreeElement).Assembly.GetType((string)itemTypeSelected, true); + + var treeElement = (BehaviorTreeElement)CreateInstance(type); + treeElement.ID = 0; + treeElement.Name = type.ToString().Split('.').Last(); + treeElement.Depth = -1; + treeElement.ElementType = type.ToString(); + + nodes.Add(new BehaviorEditorNode(mousePosition, 200, 150, treeElement, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode)); + } + + private void OnClickRemoveNode(BehaviorEditorNode node) + { + if (connections != null) + { + List connectionsToRemove = new List(); + + for (int i = 0; i < connections.Count; i++) + { + if (connections[i].inPoint == node.inPoint || connections[i].outPoint == node.outPoint) + { + connectionsToRemove.Add(connections[i]); + } + } + + for (int i = 0; i < connectionsToRemove.Count; i++) + { + var connection = connectionsToRemove[i]; + connections.Remove(connection); + if(connection.inPoint.connections.Contains(connection)) + { + connection.inPoint.connections.Remove(connection); + } + + if (connection.outPoint.connections.Contains(connection)) + { + connection.outPoint.connections.Remove(connection); + } + } + + connectionsToRemove = null; + } + + nodes.Remove(node); + } + + private void OnDrag(Vector2 delta) + { + drag = delta; + + if (nodes != null) + { + for (int i = 0; i < nodes.Count; i++) + { + nodes[i].Drag(delta); + } + } + + GUI.changed = true; + } + + protected void OnClickInPoint(ConnectionPoint inPoint) + { + selectedInPoint = inPoint; + + if (selectedOutPoint != null) + { + if (selectedOutPoint.node != selectedInPoint.node) + { + CreateConnection(); + } + ClearConnectionSelection(); + } + } + + private void OnClickOutPoint(ConnectionPoint outPoint) + { + selectedOutPoint = outPoint; + + if (selectedInPoint != null) + { + if (selectedOutPoint.node != selectedInPoint.node) + { + CreateConnection(); + } + ClearConnectionSelection(); + } + } + + private void OnClickRemoveConnection(Connection connection) + { + connection.inPoint.connections.Remove(connection); + connection.outPoint.connections.Remove(connection); + connections.Remove(connection); + } + + private void CreateConnection() + { + if (connections == null) + { + connections = new List(); + } + + var connection = new Connection(selectedInPoint, selectedOutPoint, OnClickRemoveConnection); + + selectedInPoint.connections.Add(connection); + selectedOutPoint.connections.Add(connection); + connections.Add(connection); + } + + private void ClearConnectionSelection() + { + selectedInPoint = null; + selectedOutPoint = null; + } + + private void SaveAllNodesToFile() + { + if (IsValidTree()) + { + var path = EditorUtility.SaveFilePanelInProject( + "Save behavior tree", + "New Behavior Tree.asset", + "asset", + "Save behavior tree asset"); + + TreeSaver saver = new TreeSaver(); + saver.SaveTree(nodes, path); + } + } + + protected void LoadNodesFromFile() + { + var path = EditorUtility.OpenFilePanel( + "Save behavior tree", + "", + "asset"); + + TreeLoader loader = new TreeLoader(); + var root = loader.LoadFromAsset(path); + nodes = loader.GetNodes(OnClickInPoint, OnClickOutPoint, OnClickRemoveNode); + connections = loader.GetConnectionsFromRoot(root, OnClickRemoveConnection); + } + + private bool IsValidTree() + { + DeselectAllNodes(); + return new TreeValidator(selectedNodeStyle).IsValidTreeByNodes(nodes); + } + + private void DeselectAllNodes() + { + foreach(var node in nodes) + { + node.style = node.defaultNodeStyle; + } + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorNodeEditorWindow.cs.meta b/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorNodeEditorWindow.cs.meta new file mode 100644 index 0000000..70da8e7 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor/BehaviorNodeEditorWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ef59855f1150f8742bcd883baed3b122 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor/Connection.cs b/Assets/Visual Behavior Tree/Editor/NodeEditor/Connection.cs new file mode 100644 index 0000000..94bdd5e --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor/Connection.cs @@ -0,0 +1,31 @@ +using System; +using UnityEditor; +using UnityEngine; + +namespace Assets.Visual_Behavior_Tree.Editor.NodeEditor +{ + public class Connection + { + public ConnectionPoint inPoint; + public ConnectionPoint outPoint; + public Action OnClickRemoveConnection; + + public Connection(ConnectionPoint inPoint, ConnectionPoint outPoint, Action OnClickRemoveConnection) + { + this.inPoint = inPoint; + this.outPoint = outPoint; + this.OnClickRemoveConnection = OnClickRemoveConnection; + } + + public void Draw() + { + Handles.DrawLine(inPoint.rect.center, + outPoint.rect.center); + + if (Handles.Button((inPoint.rect.center + outPoint.rect.center) * 0.5f, Quaternion.identity, 4, 8, Handles.RectangleHandleCap)) + { + OnClickRemoveConnection?.Invoke(this); + } + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor/Connection.cs.meta b/Assets/Visual Behavior Tree/Editor/NodeEditor/Connection.cs.meta new file mode 100644 index 0000000..9d0938d --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor/Connection.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ac308657714d51a46bd948e79efc2b85 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor/ConnectionPoint.cs b/Assets/Visual Behavior Tree/Editor/NodeEditor/ConnectionPoint.cs new file mode 100644 index 0000000..ec803b3 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor/ConnectionPoint.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Assets.Visual_Behavior_Tree.Editor.NodeEditor +{ + public enum ConnectionPointType { In, Out } + + public class ConnectionPoint + { + public Rect rect; + + public ConnectionPointType type; + + public BehaviorEditorNode node; + + public GUIStyle style; + + public Action OnClickConnectionPoint; + + public List connections = new List(); + + public ConnectionPoint(BehaviorEditorNode node, ConnectionPointType type, GUIStyle style, Action OnClickConnectionPoint) + { + this.node = node; + this.type = type; + this.style = style; + this.OnClickConnectionPoint = OnClickConnectionPoint; + rect = new Rect(0, 0, 20f, 10f); + } + + public void Draw() + { + rect.x = node.fullRect.x + (node.fullRect.width * 0.5f) - rect.width * 0.5f; + + switch (type) + { + case ConnectionPointType.In: + rect.y = node.fullRect.y - rect.height + 4f; + break; + + case ConnectionPointType.Out: + rect.y = node.fullRect.y + node.fullRect.height - 5f; + break; + } + + if (GUI.Button(rect, "", style)) + { + OnClickConnectionPoint?.Invoke(this); + } + } + } +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/NodeEditor/ConnectionPoint.cs.meta b/Assets/Visual Behavior Tree/Editor/NodeEditor/ConnectionPoint.cs.meta new file mode 100644 index 0000000..e019b05 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/NodeEditor/ConnectionPoint.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2971b473c2b353548830401e10a3e6ab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/TreeDebuggerWindow.cs b/Assets/Visual Behavior Tree/Editor/TreeDebuggerWindow.cs deleted file mode 100644 index 684f974..0000000 --- a/Assets/Visual Behavior Tree/Editor/TreeDebuggerWindow.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using System.Collections.Generic; -using Assets.Editor.BehaviorTreeViewEditor; -using Assets.Scripts.AI; -using Assets.Scripts.AI.Behavior_Logger; -using UniRx; -using UnityEditor; -using UnityEngine; -using System.Linq; - -namespace Assets.Editor -{ - public class TreeDebuggerWindow : EditorWindow - { - private static Vector2 BehaviorLogRectSize = new Vector2(120, 120); - private RectOffset MinimumMargins; - - private GUIStyle TreeStyle = new GUIStyle(); - - private void OnEnable() - { - Initialize(); - } - - private CompositeDisposable Disposables = new CompositeDisposable(); - - public StringReactiveProperty ManagerName = new StringReactiveProperty(); - - /// - /// Behavior IDs to track current behaviors being watched. - /// - public Dictionary LogDrawers = new Dictionary(); - public Dictionary> LogDrawersByDepth = new Dictionary>(); - - - Rect TopToolbarRect - { - get { return new Rect(10f, 5f, position.width - 40f, 30f); } - } - - Rect TreeDrawArea - { - get { return new Rect(6f, 20f, position.width - 30f, position.height - 40f); } - } - - [MenuItem("Behavior Tree/Debugger")] - public static TreeDebuggerWindow ShowWindow() - { - var window = GetWindow(); - window.Focus(); - window.Repaint(); - return window; - } - - private void OnGUI() - { - if (!Initialized) Initialize(); - - using (new EditorGUILayout.VerticalScope()) - { - TopToolbar(TopToolbarRect); - TreeLogArea(TreeDrawArea); - } - } - - private bool Initialized = false; - private void Initialize() - { - BehaviorLogRectSize = new Vector2(120, 120); - MinimumMargins = new RectOffset(5, 5, 25, 25); - LogDrawers = new Dictionary(); - rowTotalDrawn = new Dictionary(); - parents = new HashSet(); - this.autoRepaintOnSceneChange = true; - - TreeStyle.margin = MinimumMargins; - Initialized = true; - Repaint(); - } - - GenericMenu ManagerSelectMenu = new GenericMenu(); - private void TopToolbar(Rect rect) - { - using(new EditorGUILayout.HorizontalScope()) - { - GUILayout.Space(5); - string dropDownName = "Manager To Debug"; - if (ManagerName.Value != "") dropDownName = ManagerName.Value; - - if(EditorGUILayout.DropdownButton(new GUIContent(dropDownName, "Change visible debugger"), FocusType.Passive, GUILayout.Height(30))) - { - ManagerSelectMenu.CreateManagerMenu(OnManagerSelected); - ManagerSelectMenu.ShowAsContext(); - } - } - } - - private void OnManagerSelected(object name) - { - ManagerName.SetValueAndForceNotify((string)name); - Initialize(); - } - - private Dictionary rowTotalDrawn = new Dictionary(); - private HashSet parents = new HashSet(); - bool parentPaddingSet = false; - - private void TreeLogArea(Rect rect) - { - ObservableBehaviorLogger.Listener - .Where(x => x.LoggerName == ManagerName.Value && - x.State.HasChildren) - .Do(x => - { - //keep a single drawer per ID value - if (!LogDrawers.ContainsKey(x.BehaviorID)) - { - GUIStyle subStyle = new GUIStyle(); - subStyle.margin = MinimumMargins; - //keep only the parents. Parents are responsible for drawing their children. - LogDrawers.Add(x.BehaviorID, - new BehaviorLogDrawer(x.LoggerName, x.BehaviorID, BehaviorLogRectSize, subStyle) - { - TotalOffset = MinimumMargins, - Entry = x - }); - - - } - }) - .Subscribe(); - GUI.BeginGroup(rect); - DrawAllLogDrawers(); - GUI.EndGroup(); - } - - private void DrawAllLogDrawers() - { - var parentsDepthSorted = LogDrawers.Values.Where(x => x.Entry.State.Depth == -1); - - foreach (var parentDrawer in parentsDepthSorted) - { - //Should be called in sorted order, from bottom to top. - //this allows lower depth parents to know the correct spacing of their children - parentDrawer.DrawBehaviorWithAllChildren(); - } - } - - private void OnDestroy() - { - Disposables.Clear(); - } - } -} diff --git a/Assets/Visual Behavior Tree/Editor/TreeDebuggerWindow.cs.meta b/Assets/Visual Behavior Tree/Editor/TreeDebuggerWindow.cs.meta deleted file mode 100644 index 229ee9d..0000000 --- a/Assets/Visual Behavior Tree/Editor/TreeDebuggerWindow.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: f24d03852519aec4f9b0dbb8e2fd015b -timeCreated: 1522900582 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/TreeLoader.cs b/Assets/Visual Behavior Tree/Editor/TreeLoader.cs new file mode 100644 index 0000000..304e3af --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/TreeLoader.cs @@ -0,0 +1,89 @@ +using Assets.Scripts.AI; +using Assets.Scripts.AI.Tree; +using Assets.Visual_Behavior_Tree.Editor.NodeEditor; +using Assets.Visual_Behavior_Tree.Scripts; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEngine; + +namespace Assets.Visual_Behavior_Tree.Editor +{ + public class TreeLoader + { + private TreeNodeAsset asset; + + private List behaviorElements = new List(); + + private BehaviorTreeElement root; + + private List nodes; + private List connections = new List(); + + public BehaviorTreeElement LoadFromAsset(string path) + { + var filename = path.Substring(path.LastIndexOf("Assets/")); + asset = AssetDatabase.LoadAssetAtPath(filename); + + var elements = JsonConvert.DeserializeObject>(asset.treeElements); + + behaviorElements = new List(); + foreach (dynamic el in elements) + { + string typeName = el.ElementType; + Type type = Assembly.GetAssembly(typeof(BehaviorTreeElement)).GetType(typeName); + dynamic newBehavior = Activator.CreateInstance(type, (string)el.Name, (int)el.Depth, (int)el.ID); + JsonConvert.PopulateObject(JsonConvert.SerializeObject(el), newBehavior); + behaviorElements.Add(newBehavior); + } + root = TreeElementUtility.ListToTree(behaviorElements); + return root; + } + + public List GetNodes(Action OnClickInPoint, Action OnClickOutPoint, Action OnClickRemoveNode) + { + nodes = new List(); + + for(int i = 0; i < behaviorElements.Count; ++i) + { + var nodeRect = asset.positions[i]; + var newNode = new BehaviorEditorNode(nodeRect.position, nodeRect.width, nodeRect.height, behaviorElements[i], OnClickInPoint, OnClickOutPoint, OnClickRemoveNode); + + nodes.Add(newNode); + } + + return nodes; + } + + internal List GetConnectionsFromRoot(BehaviorTreeElement root, Action onClickRemoveConnection) + { + for (int parentIndex = 0; parentIndex < behaviorElements.Count; parentIndex++) + { + var parent = behaviorElements[parentIndex]; + + int parentDepth = parent.Depth; + + // Count children based depth value, we are looking at children until it's the same depth as this object + for (int i = parentIndex + 1; i < behaviorElements.Count; i++) + { + if (behaviorElements[i].Depth == parentDepth + 1) + { + var inPoint = nodes[i].inPoint; + var connection = new Connection(nodes[i].inPoint, nodes[parentIndex].outPoint, onClickRemoveConnection); + nodes[i].inPoint.connections.Add(connection); + nodes[parentIndex].outPoint.connections.Add(connection); + connections.Add(connection); + } + + if (behaviorElements[i].Depth <= parentDepth) + break; + } + } + return connections; + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/TreeLoader.cs.meta b/Assets/Visual Behavior Tree/Editor/TreeLoader.cs.meta new file mode 100644 index 0000000..83f4092 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/TreeLoader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4ddb318f7b8e3554285cf50db163ac7c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/TreeSaver.cs b/Assets/Visual Behavior Tree/Editor/TreeSaver.cs new file mode 100644 index 0000000..ac7c7f6 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/TreeSaver.cs @@ -0,0 +1,112 @@ +using Assets.Scripts.AI; +using Assets.Scripts.AI.Tree; +using Assets.Visual_Behavior_Tree.Editor.NodeEditor; +using Assets.Visual_Behavior_Tree.Editor.UIENodeEditor; +using Assets.Visual_Behavior_Tree.Scripts; +using Newtonsoft.Json; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +namespace Assets.Visual_Behavior_Tree.Editor +{ + public class TreeSaver + { + private List positions; + + public void SaveTree(List nodes, string path) + { + BehaviorEditorNode rootNode = nodes.Find(node => node.inPoint.connections.Count == 0); + + rootNode.treeElement.Depth = -1; + + positions = new List(); + positions.Add(rootNode.fullRect); + + RecursiveAddChildren(rootNode); + + var json = GetJsonSaveDataFromRoot(rootNode.treeElement); + + Debug.Log(json); + + SaveAssetToDatabase(path, positions, json); + } + + private void RecursiveAddChildren(BehaviorEditorNode rootNode) + { + rootNode.treeElement.Children = new List(); + var rootNodeConnections = rootNode.outPoint.connections; + rootNodeConnections.ForEach(outNode => + { + var outInpointNode = outNode.inPoint.node; + if (outInpointNode != rootNode) + { + var treeElement = outInpointNode.treeElement; + treeElement.Parent = rootNode.treeElement; + treeElement.Depth = rootNode.treeElement.Depth + 1; + rootNode.treeElement.Children.Add(treeElement); + var pos = outInpointNode.fullRect; + positions.Add(pos); + RecursiveAddChildren(outInpointNode); + } + }); + } + + public void SaveTree(List nodes, string path) + { + EditorNode rootNode = nodes.Find(node => node.inPoint.connections.Count == 0); + + rootNode.TreeElement.Depth = -1; + + positions = new List + { + rootNode.layout + }; + + RecursiveAddChildren(rootNode); + + var json = GetJsonSaveDataFromRoot(rootNode.TreeElement); + + SaveAssetToDatabase(path, positions, json); + } + + private void RecursiveAddChildren(EditorNode rootNode) + { + rootNode.TreeElement.Children = new List(); + var rootOutNode = rootNode.outPoint; + if (rootOutNode == null) return; + var rootNodeConnections = rootOutNode.connections; + rootNodeConnections.ForEach(outNode => + { + var outInpointNode = outNode.inPoint.node; + if (outInpointNode != rootNode) + { + var treeElement = outInpointNode.TreeElement; + treeElement.Parent = rootNode.TreeElement; + treeElement.Depth = rootNode.TreeElement.Depth + 1; + rootNode.TreeElement.Children.Add(treeElement); + var pos = outInpointNode.layout; + positions.Add(pos); + RecursiveAddChildren(outInpointNode); + } + }); + } + + private string GetJsonSaveDataFromRoot(BehaviorTreeElement root) + { + var elementList = new List(); + TreeElementUtility.TreeToList(root, elementList); + + return JsonConvert.SerializeObject(elementList, Formatting.Indented); + } + + private void SaveAssetToDatabase(string path, List positions, string json) + { + TreeNodeAsset asset = ScriptableObject.CreateInstance(); + asset.positions = positions; + asset.treeElements = json; + + AssetDatabase.CreateAsset(asset, path); + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/TreeSaver.cs.meta b/Assets/Visual Behavior Tree/Editor/TreeSaver.cs.meta new file mode 100644 index 0000000..cc0ac79 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/TreeSaver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b3745f49c3c3fff42bdcf8166a2a93e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/TreeValidator.cs b/Assets/Visual Behavior Tree/Editor/TreeValidator.cs new file mode 100644 index 0000000..1fadb79 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/TreeValidator.cs @@ -0,0 +1,64 @@ +using Assets.Visual_Behavior_Tree.Editor.NodeEditor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace Assets.Visual_Behavior_Tree.Editor +{ + public class TreeValidator + { + private List checkNodes; + private GUIStyle errorHighlightStyle; + + public TreeValidator(GUIStyle errorStyle) + { + errorHighlightStyle = errorStyle; + } + + public bool IsValidTreeByNodes(List nodes) + { + checkNodes = nodes; + return HasExactlyOneRootNode() && NoChildHasTwoParents(); + } + + private bool HasExactlyOneRootNode() + { + var rootNodes = checkNodes.FindAll(node => node.inPoint.connections.Count() == 0); + + if(rootNodes.Count > 1) + { + Debug.LogError("Behavior Tree Is INVALID! You cannot have more than one root node (node with no inConnections)! Check Highlighted nodes."); + HighlightErrorNodes(rootNodes); + return false; + } + + return true; + } + + private bool NoChildHasTwoParents() + { + var errorChildNodes = checkNodes.FindAll(node => node.inPoint.connections.Count() > 1); + + if(errorChildNodes.Count > 0) + { + Debug.LogError("Behavior Tree Is INVALID! You cannot have more than one parent node for a child! Check Highlighted nodes."); + + HighlightErrorNodes(errorChildNodes); + return false; + } + + return true; + } + + private void HighlightErrorNodes(List errorNodes) + { + foreach(var node in errorNodes) + { + node.style = errorHighlightStyle; + } + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/TreeValidator.cs.meta b/Assets/Visual Behavior Tree/Editor/TreeValidator.cs.meta new file mode 100644 index 0000000..2c165f2 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/TreeValidator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 54a09d70d14018b499150b3616af1d05 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/TypeDependantDrawer.cs b/Assets/Visual Behavior Tree/Editor/TypeDependantDrawer.cs deleted file mode 100644 index e923285..0000000 --- a/Assets/Visual Behavior Tree/Editor/TypeDependantDrawer.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Assets.Scripts.AI; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; -using UnityEditor; -using UnityEngine; - -namespace Assets.Editor -{ - public static class TypeDependantDrawer - { - private static float parameterBuffer = 10f; - - public static void DrawAllFields(dynamic element, Rect rect) - { - DrawFieldsFlowLayout(new GUIContent(""), element, rect); - } - - private static GUIContent MakeLabel(FieldInfo field) - { - GUIContent guiContent = new GUIContent(); - guiContent.text = field.Name; - object[] descriptions = field.GetCustomAttributes(typeof(DescriptionAttribute), true); - - if (descriptions.Length > 0) - { - //just use the first one. - guiContent.tooltip = (descriptions[0] as DescriptionAttribute).Description; - } - - return guiContent; - } - - - private static void DrawFieldsFlowLayout(GUIContent label, dynamic target, Rect rect) - { - Type type = Assembly.GetAssembly(typeof(BehaviorTreeElement)).GetType(target.ElementType); - FieldInfo[] fields = type.GetFields(); - - var items = new List(); - foreach (FieldInfo field in fields) - { - items.Add(field.Name); - } - - var style = EditorStyles.objectField; - style.stretchWidth = false; - style.fixedWidth = EditorGUIUtility.fieldWidth + EditorGUIUtility.labelWidth + 4; - - var boxes = EditorGUIUtility.GetFlowLayoutedRects(rect, style, 4, 4, items); - for(int i = 0; i < items.Count; ++i) - { - using (new GUILayout.AreaScope(boxes[i],"", EditorStyles.boldLabel)) - { - if (fields[i].FieldType == typeof(int)) - { - fields[i].SetValue(target, EditorGUILayout.IntField( - MakeLabel(fields[i]), (int)fields[i].GetValue(target))); - } - else if (fields[i].FieldType == typeof(float)) - { - fields[i].SetValue(target, EditorGUILayout.FloatField( - MakeLabel(fields[i]), (float)fields[i].GetValue(target))); - } - else if (fields[i].FieldType == typeof(string)) - { - fields[i].SetValue(target, EditorGUILayout.TextField( - MakeLabel(fields[i]), (string)fields[i].GetValue(target))); - } - } - } - } - - public static float GetTotalHeightOfProperties(dynamic element) - { - Type type = Assembly.GetAssembly(typeof(BehaviorTreeElement)).GetType(element.ElementType); - var newHeight = 4 + EditorGUIUtility.singleLineHeight * type.GetFields().Length / 2; - return newHeight + parameterBuffer; - } - } -} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/TypeDependantDrawer.cs.meta b/Assets/Visual Behavior Tree/Editor/TypeDependantDrawer.cs.meta deleted file mode 100644 index bf33a24..0000000 --- a/Assets/Visual Behavior Tree/Editor/TypeDependantDrawer.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 90308faa417a3b74c8637363e3fce29d -timeCreated: 1519165561 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor.meta new file mode 100644 index 0000000..a18f4f7 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0faed3662ae17fd4b86faff984d970f1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection.meta new file mode 100644 index 0000000..de04682 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 00ee8b101a97cd84a9e9dd9925bd31f5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.cs new file mode 100644 index 0000000..7ea84a0 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor +{ + public class Connection : VisualElement + { + public ConnectionPoint inPoint; + public ConnectionPoint outPoint; + public Action OnClickRemoveConnection; + + readonly Button removeButton; + + public float lineWidth = 3; + + public Connection(ConnectionPoint inPoint, ConnectionPoint outPoint, Action onClickRemoveConnection) + { + this.inPoint = inPoint; + this.outPoint = outPoint; + this.OnClickRemoveConnection = onClickRemoveConnection; + + this.AddToClassList("Connection"); + + var styleSheet = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.uss"); + this.styleSheets.Add(styleSheet); + + removeButton = new Button(); + removeButton.AddToClassList("ConnectionButton"); + removeButton.clicked += OnClicked; + + this.Add(removeButton); + + this.generateVisualContent += OnGenerateVisualContent; + } + + void OnClicked() + { + OnClickRemoveConnection?.Invoke(this); + } + + void OnGenerateVisualContent(MeshGenerationContext cxt) + { + MeshWriteData mesh = cxt.Allocate(4, 6); + Vertex[] vertices = new Vertex[4]; + + float inX = inPoint.worldBound.center.x; + float leftIn = inX - lineWidth; + float rightIn = inX + lineWidth; + + float outX = outPoint.worldBound.center.x; + float leftOut = outX - lineWidth; + float rightOut = outX + lineWidth; + float top = inPoint.worldBound.center.y - 59; + float bottom = outPoint.worldBound.center.y - 59; + + removeButton.style.top = ((top + bottom) / 2) - removeButton.layout.height/2; + removeButton.style.left = ((inX + outX) / 2) - (removeButton.layout.width / 2) - 2; + + vertices[0].position = new Vector3(leftIn, top, Vertex.nearZ); + vertices[1].position = new Vector3(rightIn, top, Vertex.nearZ); + vertices[2].position = new Vector3(leftOut, bottom, Vertex.nearZ); + vertices[3].position = new Vector3(rightOut, bottom, Vertex.nearZ); + + var color = this.resolvedStyle.color; + + vertices[0].tint = color; + vertices[1].tint = color; + vertices[2].tint = color; + vertices[3].tint = color; + mesh.SetAllVertices(vertices); + if(top > bottom) + mesh.SetAllIndices(new ushort[] { 0, 2, 1, 2, 3, 1}); + else + mesh.SetAllIndices(new ushort[] { 2, 0, 3, 0, 1, 3 }); + + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.cs.meta new file mode 100644 index 0000000..d85007a --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2718362afbceb9b42a23d9bbe4007881 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.uss b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.uss new file mode 100644 index 0000000..9f25011 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.uss @@ -0,0 +1,4 @@ +.Connection { + color: green; + position: absolute; +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.uss.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.uss.meta new file mode 100644 index 0000000..b75f250 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Connection/Connection.uss.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e82b6090bd4c66543a46bb994a2843f7 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} + disableValidation: 0 diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint.meta new file mode 100644 index 0000000..d31d280 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 60427dc6d8bd0a947a9ce519271163d3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.cs new file mode 100644 index 0000000..86b9a1e --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.cs @@ -0,0 +1,74 @@ +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; +using UnityEditor.UIElements; +using System; +using System.Collections.Generic; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor +{ + public enum ConnectionPointType { In, Out } + + public class ConnectionPoint : Button, IEquatable + { + public ConnectionPointType Type; + + public Action OnClickConnectionPoint; + internal List connections = new List(); + internal EditorNode node; + + public ConnectionPoint() + { + VisualElement root = this; + + var styleSheet = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uss"); + root.styleSheets.Add(styleSheet); + } + + public ConnectionPoint(EditorNode node, ConnectionPointType type, Action onClickConnectionPoint) + { + this.node = node; + + VisualElement root = this; + + var styleSheet = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uss"); + root.styleSheets.Add(styleSheet); + + OnClickConnectionPoint = onClickConnectionPoint; + this.clicked += OnClicked; + + connections = new List(); + } + + private void OnClicked() + { + OnClickConnectionPoint?.Invoke(this); + } + + public override bool Equals(object obj) + { + return Equals(obj as ConnectionPoint); + } + + public bool Equals(ConnectionPoint other) + { + return other != null && + Type == other.Type && + EqualityComparer>.Default.Equals(OnClickConnectionPoint, other.OnClickConnectionPoint) && + EqualityComparer>.Default.Equals(connections, other.connections) && + EqualityComparer.Default.Equals(node, other.node); + } + + public override int GetHashCode() + { + int hashCode = 97315638; + hashCode = hashCode * -1521134295 + Type.GetHashCode(); + hashCode = hashCode * -1521134295 + EqualityComparer>.Default.GetHashCode(OnClickConnectionPoint); + hashCode = hashCode * -1521134295 + EqualityComparer>.Default.GetHashCode(connections); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(node); + return hashCode; + } + + + } +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.cs.meta new file mode 100644 index 0000000..5e8c374 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f0c10ff80b46ee343a4226fbbfc5eda3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uss b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uss new file mode 100644 index 0000000..d637471 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uss @@ -0,0 +1,5 @@ +Label { + font-size: 20px; + -unity-font-style: bold; + color: rgb(68, 138, 255); +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uss.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uss.meta new file mode 100644 index 0000000..abb8ea3 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uss.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 295231c78eb84284f915ae5a74d479e5 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} + disableValidation: 0 diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uxml b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uxml new file mode 100644 index 0000000..7e2121d --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uxml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uxml.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uxml.meta new file mode 100644 index 0000000..3013886 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/ConnectionPoint/ConnectionPoint.uxml.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 86e9177be92736d4894a1ef97d7c34e1 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window.meta new file mode 100644 index 0000000..e14b48b --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 28967b4ae251bf541a5b21e5c420a3d4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorManagerSelector.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorManagerSelector.cs new file mode 100644 index 0000000..02165c2 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorManagerSelector.cs @@ -0,0 +1,34 @@ +using Assets.Scripts.AI; +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor.UIElements; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Debug_Window +{ + public class BehaviorManagerSelector : VisualElement + { + public BehaviorManagerSelector(Func onSelectedChanged) + { + this.AddToClassList("Selector"); + var dropdown = new PopupField(GetDropdownList(),0); + dropdown.label = "Manager"; + this.Add(dropdown); + dropdown.formatSelectedValueCallback += onSelectedChanged; + } + + private List GetDropdownList() + { + var menuItems = new List(); + menuItems.Add("None"); + + var managers = from manager in UnityEngine.Object.FindObjectsOfType() + select manager.GetInstanceID() + "-" + manager.name; + + menuItems.AddRange(managers); + + return menuItems; + } + } +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorManagerSelector.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorManagerSelector.cs.meta new file mode 100644 index 0000000..4cf2551 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorManagerSelector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4b4f70a7600ef144f9c89256998d4e1a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorTreeSelector.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorTreeSelector.cs new file mode 100644 index 0000000..c3bed26 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorTreeSelector.cs @@ -0,0 +1,43 @@ +using Assets.Scripts.AI; +using Assets.Scripts.AI.Components; +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Debug_Window +{ + public class BehaviorTreeSelector : VisualElement + { + public BehaviorManager RootManager; + public BehaviorTreeSelector(BehaviorManager manager, Func onSelectedChanged) + { + this.AddToClassList("Selector"); + RootManager = manager; + var dropdown = new PopupField(GetDropdownList(),0); + dropdown.label = "Tree"; + this.Add(dropdown); + dropdown.formatSelectedValueCallback += onSelectedChanged; + dropdown.formatListItemCallback += FormatItem; + } + + private List GetDropdownList() + { + var menuItems = new List(); + + var trees = from tree in RootManager.rootList + select tree.Key; + + menuItems.AddRange(trees); + + return menuItems; + } + + private string FormatItem(BehaviorTreeElement element) + { + return element.GetInstanceID() + "-" + element.Name; + } + } +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorTreeSelector.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorTreeSelector.cs.meta new file mode 100644 index 0000000..f3e9525 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/BehaviorTreeSelector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1b98ba5e907b19048b6078e1c401b28e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.cs new file mode 100644 index 0000000..078dc13 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.cs @@ -0,0 +1,139 @@ +using Assets.Scripts.AI; +using Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Debug_Window; +using Assets.Visual_Behavior_Tree.Scripts; +using System.Collections.Generic; +using System.Linq; +using UniRx; +using UnityEditor; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor +{ + public class DebugWindow : EditorWindow + { + List nodes = new List(); + + List connections = new List(); + + BehaviorManager selectedManager; + + [MenuItem("Testing/Behavior Debug Window")] + public static void Open() + { + DebugWindow wnd = GetWindow(); + wnd.titleContent = new GUIContent("Behavior Node Debugger"); + } + + private void OnEnable() + { + VisualElement root = rootVisualElement; + + var visualTree = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uxml"); + VisualElement uxmlRoot = visualTree.CloneTree(); + + var toolbar = uxmlRoot.Q("Toolbar"); + var dropdown = new BehaviorManagerSelector(OnSelectedManagerChanged); + + toolbar.Add(dropdown); + + root.Add(uxmlRoot); + + var container = rootVisualElement.Q("TabContainer"); + + //container.AddManipulator(new BehaviorEditorDragger(this)); + + var styleSheet = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uss"); + root.styleSheets.Add(styleSheet); + + this.SetAntiAliasing(4); + } + + private string OnSelectedManagerChanged(string selected) + { + var toolbar = rootVisualElement.Q("Toolbar"); + var selector = rootVisualElement.Q("TreeSelector"); + if (selector != null) toolbar.Remove(selector); + + + var idAndName = selected.Split('-'); + if (idAndName.Length > 1) + { + var matchedManager = from manager in UnityEngine.Object.FindObjectsOfType() + where manager.GetInstanceID() == int.Parse(idAndName[0]) + select manager; + selectedManager = matchedManager.First(); + + var treeDropdown = new BehaviorTreeSelector(selectedManager, OnSelectedTreeChanged); + treeDropdown.name = "TreeSelector"; + + toolbar.Add(treeDropdown); + } + + return selected; + } + + private string OnSelectedTreeChanged(BehaviorTreeElement selected) + { + Debug.Log(selected.name); + var asset = selectedManager.rootList[selected]; + LoadNodesFromAssetAndRoot(asset, selected); + + return selected.GetInstanceID() + "-" + selected.Name; + } + + private void LoadNodesFromAssetAndRoot(TreeNodeAsset asset, BehaviorTreeElement root) + { + var container = rootVisualElement.Q("TabContainer"); + if (nodes != null) + foreach (var node in nodes) + { + container.Remove(node); + } + + if (connections != null) + foreach (var connection in connections) + { + container.Remove(connection); + connection.MarkDirtyRepaint(); + } + + UIETreeLoader loader = new UIETreeLoader(); + var rootNode = loader.LoadFromAssetAndRoot(asset, root); + nodes = loader.GetNodes(OnClickInPoint, OnClickOutPoint, OnClickAddNode, OnClickRemoveNode); + connections = loader.GetConnectionsFromRoot(rootNode, OnClickRemoveConnection); + + foreach (var node in nodes) + { + container.Add(node); + } + + foreach (var connection in connections) + { + container.Add(connection); + connection.MarkDirtyRepaint(); + } + } + + private void OnClickRemoveNode(EditorNode obj) + {} + + private void OnClickAddNode(EditorNode node) + {} + + private void OnGUI() + { + rootVisualElement.Q("TabContainer").style.height = new StyleLength(position.height); + } + + private void OnClickInPoint(ConnectionPoint inPoint) + {} + + private void OnClickOutPoint(ConnectionPoint outPoint) + {} + + private void OnClickRemoveConnection(Connection obj) + {} + } +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.cs.meta new file mode 100644 index 0000000..8cd1686 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1096fa4f3fd25e742a56feb8ba7560f0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uss b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uss new file mode 100644 index 0000000..dcfa31f --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uss @@ -0,0 +1,31 @@ +#Toolbar +{ + height: 40px; + width: auto; + background-color: rgb(21, 132, 67); + + display: flex; + flex-direction: row; +} + +#TabContainer +{ + background-color: rgba(242, 246, 250,1); + width: auto; + height: auto; + overflow: hidden; +} + +.EditorNode { + width: auto; + height: auto; + position: absolute; +} + +.Connection { + position: absolute; +} + +.Selector { + align-self: flex-end; +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uss.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uss.meta new file mode 100644 index 0000000..35739d3 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uss.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 716dd544288b7d14c8416eec9cba1aed +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} + disableValidation: 0 diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uxml b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uxml new file mode 100644 index 0000000..06dc1c7 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uxml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uxml.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uxml.meta new file mode 100644 index 0000000..8b0a1ca --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Debug Window/DebugWindow.uxml.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a850434b6f383fb45a505323764b0e59 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window.meta new file mode 100644 index 0000000..ad6e9c6 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7d1ce5b06cce02541a1911a19d14e9b1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.cs new file mode 100644 index 0000000..ec2716c --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.cs @@ -0,0 +1,268 @@ +using Assets.Scripts.AI; +using Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Manipulators; +using Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Util; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor +{ + public class BehaviorEditorWindow : EditorWindow + { + public List nodes = new List(); + public List connections = new List(); + + private ConnectionPoint selectedInPoint; + private ConnectionPoint selectedOutPoint; + + [MenuItem("Testing/Behavior Editor Window")] + public static void ShowExample() + { + BehaviorEditorWindow wnd = GetWindow(); + wnd.titleContent = new GUIContent("Behavior Node Editor"); + } + + private void OnEnable() + { + VisualElement root = rootVisualElement; + + var visualTree = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uxml"); + VisualElement uxmlRoot = visualTree.CloneTree(); + + root.Add(uxmlRoot); + + var container = rootVisualElement.Q("GridContainer"); + + container.AddManipulator(new ContextualMenuManipulator(ContextMenu)); + container.AddManipulator(new BehaviorEditorDragger(this)); + + var saveButton = (Button)rootVisualElement.Q("SaveButton"); + saveButton.clicked += SaveAllNodesToFile; + + var loadButton = (Button)rootVisualElement.Q("LoadButton"); + loadButton.clicked += LoadNodesFromFile; + + var styleSheet = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uss"); + root.styleSheets.Add(styleSheet); + + this.SetAntiAliasing(4); + } + + private void ContextMenu(ContextualMenuPopulateEvent evt) + { + foreach (Type type in + Assembly.GetAssembly(typeof(BehaviorTreeElement)).GetTypes() + .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(BehaviorTreeElement)))) + { + var menuStrings = type.ToString().Split('.'); + evt.menu.AppendAction(menuStrings[menuStrings.Length - 2] + + "/" + menuStrings.Last(), OnMenuAction); + } + } + + void OnMenuAction(DropdownMenuAction action) + { + if (nodes == null) + { + nodes = new List(); + } + + DeselectAllNodes(); + + string selectedName = action.name.Split('/').Last(); + var typeName = from type in typeof(BehaviorTreeElement).Assembly.GetTypes() + where type.Name.Contains(selectedName) + select type; + + var treeElement = (BehaviorTreeElement)CreateInstance(typeName.First()); + treeElement.ID = 0; + treeElement.Name = selectedName; + treeElement.ElementType = typeName.First().ToString(); + + Rect contentRect = new Rect(action.eventInfo.localMousePosition, Vector2.zero); + + EditorNode item = new EditorNode(treeElement, contentRect, OnClickInPoint, OnClickOutPoint, OnClickAddNode, OnClickRemoveNode); + OnClickAddNode(item); + } + + private void OnClickAddNode(EditorNode node) + { + nodes.Add(node); + rootVisualElement.Q("GridContainer").Add(node); + } + + private void OnGUI() + { + rootVisualElement.Q("GridContainer").style.height = new StyleLength(position.height); + } + + private void OnClickInPoint(ConnectionPoint inPoint) + { + selectedInPoint = inPoint; + + if (selectedOutPoint != null) + { + if (!selectedOutPoint.node.Equals(selectedInPoint.node)) + { + CreateConnection(); + } + ClearConnectionSelection(); + } + } + + private void OnClickOutPoint(ConnectionPoint outPoint) + { + selectedOutPoint = outPoint; + + if (selectedInPoint != null) + { + if (!selectedOutPoint.node.Equals(selectedInPoint.node)) + { + CreateConnection(); + } + ClearConnectionSelection(); + } + } + + private void OnClickRemoveConnection(Connection connection) + { + connection.inPoint.connections.Remove(connection); + connection.outPoint.connections.Remove(connection); + rootVisualElement.Q("GridContainer").Remove(connection); + connections.Remove(connection); + } + + private void CreateConnection() + { + if (connections == null) + { + connections = new List(); + } + + var connection = new Connection(selectedInPoint, selectedOutPoint, OnClickRemoveConnection); + var container = rootVisualElement.Q("GridContainer"); + connection.MarkDirtyRepaint(); + container.Add(connection); + + selectedInPoint.connections.Add(connection); + selectedOutPoint.connections.Add(connection); + connections.Add(connection); + } + + private void ClearConnectionSelection() + { + selectedInPoint = null; + selectedOutPoint = null; + } + + private void SaveAllNodesToFile() + { + DeselectAllNodes(); + + if (IsValidTree()) + { + var path = EditorUtility.SaveFilePanelInProject( + "Save behavior tree", + "New Behavior Tree.asset", + "asset", + "Save behavior tree asset"); + + TreeSaver saver = new TreeSaver(); + saver.SaveTree(nodes, path); + } + } + + protected void LoadNodesFromFile() + { + var container = rootVisualElement.Q("GridContainer"); + if(nodes != null) + foreach (var node in nodes) + { + container.Remove(node); + } + + if(connections != null) + foreach (var connection in connections) + { + container.Remove(connection); + connection.MarkDirtyRepaint(); + } + + var path = EditorUtility.OpenFilePanel( + "Load behavior tree", + "", + "asset"); + + UIETreeLoader loader = new UIETreeLoader(); + var root = loader.LoadFromPath(path); + nodes = loader.GetNodes(OnClickInPoint, OnClickOutPoint, OnClickAddNode, OnClickRemoveNode); + connections = loader.GetConnectionsFromRoot(root, OnClickRemoveConnection); + + foreach(var node in nodes) + { + container.Add(node); + } + + foreach(var connection in connections) + { + container.Add(connection); + connection.MarkDirtyRepaint(); + } + } + + private bool IsValidTree() + { + return new UIETreeValidator().IsValidTreeByNodes(nodes); + } + + private void OnClickRemoveNode(EditorNode node) + { + var container = rootVisualElement.Q("GridContainer"); + if (connections != null) + { + List connectionsToRemove = new List(); + + for (int i = 0; i < connections.Count; i++) + { + if (connections[i].inPoint.Equals(node.inPoint) || connections[i].outPoint.Equals(node.outPoint)) + { + connectionsToRemove.Add(connections[i]); + } + } + + for (int i = 0; i < connectionsToRemove.Count; i++) + { + var connection = connectionsToRemove[i]; + + if (connection.inPoint.connections.Contains(connection)) + { + connection.inPoint.connections.Remove(connection); + } + + if (connection.outPoint.connections.Contains(connection)) + { + connection.outPoint.connections.Remove(connection); + } + connections.Remove(connection); + container.Remove(connection); + } + } + container.Remove(node); + nodes.Remove(node); + } + + private void DeselectAllNodes() + { + foreach(var node in nodes) + { + node.RemoveFromClassList("Selected"); + node.RemoveFromClassList("Error"); + } + } + } +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.cs.meta new file mode 100644 index 0000000..ac96a89 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d1cfbc453e905db49b76a5e5c4a93cd5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uss b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uss new file mode 100644 index 0000000..2915a28 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uss @@ -0,0 +1,27 @@ +.EditorNode { + width: auto; + height: auto; + position: absolute; +} + +.Connection { + position: absolute; +} + +#Toolbar +{ + height: 40px; + width: auto; + background-color: rgb(21, 132, 67); + + display: flex; + flex-direction: row; +} + +#GridContainer +{ + background-color: rgba(242, 246, 250,1); + width: auto; + height: auto; + overflow: hidden; +} \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uss.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uss.meta new file mode 100644 index 0000000..9968747 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uss.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 83d0f06b8f9cba74ab7e17f359d0fd75 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} + disableValidation: 0 diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uxml b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uxml new file mode 100644 index 0000000..4bfc5fd --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uxml @@ -0,0 +1,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uxml.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uxml.meta new file mode 100644 index 0000000..2ff6241 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Editor Window/BehaviorEditorWindow.uxml.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 83a634a8f233c3848aac4f37df6f998b +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators.meta new file mode 100644 index 0000000..3e734d6 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3b8a981e9552f1141b0abf4c01c5763e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/BehaviorEditorDragger.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/BehaviorEditorDragger.cs new file mode 100644 index 0000000..19db81e --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/BehaviorEditorDragger.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Manipulators +{ + public class BehaviorEditorDragger : MouseManipulator + { + private Vector2 last; + protected bool isActive; + + private BehaviorEditorWindow Window; + + public BehaviorEditorDragger(BehaviorEditorWindow window) + { + Window = window; + } + + protected override void RegisterCallbacksOnTarget() + { + target.RegisterCallback(OnMouseDown); + target.RegisterCallback(OnMouseMove); + target.RegisterCallback(OnMouseUp); + } + + protected override void UnregisterCallbacksFromTarget() + { + target.UnregisterCallback(OnMouseDown); + target.UnregisterCallback(OnMouseMove); + target.UnregisterCallback(OnMouseUp); + } + + private void OnMouseDown(MouseDownEvent evt) + { + if (isActive) + { + isActive = false; + evt.StopImmediatePropagation(); + return; + } + + last = evt.localMousePosition; + + isActive = true; + target.CaptureMouse(); + evt.StopPropagation(); + } + + private void OnMouseMove(MouseMoveEvent evt) + { + if (!isActive || !target.HasMouseCapture()) + return; + + Vector2 diff = evt.localMousePosition - last; + + foreach(var node in Window.nodes) + { + node.style.left = node.layout.x + diff.x; + node.style.top = node.layout.y + diff.y; + } + + foreach(var connection in Window.connections) + { + connection.MarkDirtyRepaint(); + } + + last = evt.localMousePosition; + evt.StopPropagation(); + + + } + + private void OnMouseUp(MouseUpEvent evt) + { + if (!isActive || !target.HasMouseCapture() || !CanStopManipulation(evt)) + return; + + isActive = false; + target.ReleaseMouse(); + evt.StopPropagation(); + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/BehaviorEditorDragger.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/BehaviorEditorDragger.cs.meta new file mode 100644 index 0000000..f168af5 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/BehaviorEditorDragger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fe5d2c5cb85e55744969da6f4251812a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeResizer.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeResizer.cs new file mode 100644 index 0000000..effddfb --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeResizer.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Manipulators +{ + public class EditorNodeResizer : MouseManipulator + { + private EditorNode Node; + + public EditorNodeResizer(EditorNode node) + { + Node = node; + } + private Vector2 start; + protected bool isActive; + + protected override void RegisterCallbacksOnTarget() + { + target.RegisterCallback(OnMouseDown); + target.RegisterCallback(OnMouseMove); + target.RegisterCallback(OnMouseUp); + } + + protected override void UnregisterCallbacksFromTarget() + { + target.UnregisterCallback(OnMouseDown); + target.UnregisterCallback(OnMouseMove); + target.UnregisterCallback(OnMouseUp); + } + + private void OnMouseDown(MouseDownEvent evt) + { + if (isActive) + { + isActive = false; + evt.StopImmediatePropagation(); + return; + } + + start = evt.localMousePosition; + + isActive = true; + target.CaptureMouse(); + evt.StopPropagation(); + } + + private void OnMouseMove(MouseMoveEvent evt) + { + if (!isActive || !target.HasMouseCapture()) + return; + + Vector2 diff = evt.mousePosition - Node.worldBound.position; + + var rootContainer = Node.Q("RootContainer"); + + Node.style.width = diff.x; + Node.style.height = diff.y; + + rootContainer.style.width = diff.x; + rootContainer.style.height = diff.y; + + var inConnections = Node.inPoint.connections; + + foreach (var connection in inConnections) + { + connection.MarkDirtyRepaint(); + } + + if (Node.TreeElement.CanHaveChildren) + { + var outConnections = Node.outPoint.connections; + + foreach (var connection in outConnections) + { + connection.MarkDirtyRepaint(); + } + } + + evt.StopPropagation(); + } + + private void OnMouseUp(MouseUpEvent evt) + { + if (!isActive || !target.HasMouseCapture() || !CanStopManipulation(evt)) + return; + + isActive = false; + target.ReleaseMouse(); + evt.StopPropagation(); + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeResizer.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeResizer.cs.meta new file mode 100644 index 0000000..d04cd87 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeResizer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3a60970ed4d74c34a9cf65da04a05bad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeSelector.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeSelector.cs new file mode 100644 index 0000000..5fc5485 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeSelector.cs @@ -0,0 +1,44 @@ +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Manipulators +{ + public class EditorNodeSelector : MouseManipulator + { + protected bool isSelected; + + private EditorNode Node; + + public EditorNodeSelector(EditorNode node) + { + Node = node; + } + + protected override void RegisterCallbacksOnTarget() + { + target.RegisterCallback(OnMouseDown); + } + + protected override void UnregisterCallbacksFromTarget() + { + target.UnregisterCallback(OnMouseDown); + } + + private void OnMouseDown(MouseDownEvent evt) + { + var root = Node.Q("RootContainer"); + + if (isSelected) + { + root.RemoveFromClassList("Selected"); + isSelected = false; + evt.StopImmediatePropagation(); + return; + } + + root.AddToClassList("Selected"); + + isSelected = true; + evt.StopPropagation(); + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeSelector.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeSelector.cs.meta new file mode 100644 index 0000000..4572fd4 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/EditorNodeSelector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dd55a3ac7d8767e43aaedddf06d91ca6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/NodeDragger.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/NodeDragger.cs new file mode 100644 index 0000000..ae76f8d --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/NodeDragger.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Manipulators +{ + public class NodeDragger : MouseManipulator + { + private Vector2 start; + protected bool isActive; + + protected override void RegisterCallbacksOnTarget() + { + target.RegisterCallback(OnMouseDown); + target.RegisterCallback(OnMouseMove); + target.RegisterCallback(OnMouseUp); + } + + protected override void UnregisterCallbacksFromTarget() + { + target.UnregisterCallback(OnMouseDown); + target.UnregisterCallback(OnMouseMove); + target.UnregisterCallback(OnMouseUp); + } + + private void OnMouseDown(MouseDownEvent evt) + { + if (isActive) + { + isActive = false; + evt.StopImmediatePropagation(); + return; + } + + start = evt.localMousePosition; + + isActive = true; + target.CaptureMouse(); + evt.StopPropagation(); + } + + private void OnMouseMove(MouseMoveEvent evt) + { + if (!isActive || !target.HasMouseCapture()) + return; + + Vector2 diff = evt.localMousePosition - start; + + target.style.left = target.layout.x + diff.x; + target.style.top = target.layout.y + diff.y; + var node = target as EditorNode; + var inConnections = node.inPoint.connections; + + foreach(var connection in inConnections) + { + connection.MarkDirtyRepaint(); + } + + if(node.TreeElement.CanHaveChildren) + { + var outConnections = node.outPoint.connections; + + foreach (var connection in outConnections) + { + connection.MarkDirtyRepaint(); + } + } + + evt.StopPropagation(); + } + + private void OnMouseUp(MouseUpEvent evt) + { + if (!isActive || !target.HasMouseCapture() || !CanStopManipulation(evt)) + return; + + isActive = false; + target.ReleaseMouse(); + evt.StopPropagation(); + } + } +} diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/NodeDragger.cs.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/NodeDragger.cs.meta new file mode 100644 index 0000000..72b51e2 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Manipulators/NodeDragger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 61803fcbe811d0b4dbbb10eff627d39e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Node.meta b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Node.meta new file mode 100644 index 0000000..31b1bc0 --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2bf1808656155414e863f450eebba4aa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Node/EditorNode.cs b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Node/EditorNode.cs new file mode 100644 index 0000000..8c94ceb --- /dev/null +++ b/Assets/Visual Behavior Tree/Editor/UIENodeEditor/Node/EditorNode.cs @@ -0,0 +1,162 @@ +using Assets.Scripts.AI; +using Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Manipulators; +using Assets.Visual_Behavior_Tree.Editor.UIENodeEditor.Node.EditorResizer; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Assets.Visual_Behavior_Tree.Editor.UIENodeEditor +{ + public class EditorNode : VisualElement + { + public BehaviorTreeElement TreeElement; + + public SerializedObject ElementObject; + + public ConnectionPoint inPoint; + public ConnectionPoint outPoint; + + private Action OnClickAddNode; + private Action OnClickRemoveNode; + + public EditorNode(BehaviorTreeElement wrappedElement, Rect content, Action onClickInPoint, Action onClickOutPoint, Action onClickAddNode, Action onClickRemoveNode) + { + var styleSheet = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/Node/EditorNode.uss"); + this.styleSheets.Add(styleSheet); + + inPoint = new ConnectionPoint(this, ConnectionPointType.In, onClickInPoint); + outPoint = new ConnectionPoint(this, ConnectionPointType.Out, onClickOutPoint); + + this.AddToClassList("EditorNode"); + if(content.width > 0) this.style.width = content.width; + if(content.height > 0) this.style.height = content.height; + this.style.left = content.position.x; + this.style.top = content.position.y; + + this.AddManipulator(new NodeDragger()); + this.AddManipulator(new EditorNodeSelector(this)); + this.AddManipulator(new ContextualMenuManipulator(ContextMenu)); + + TreeElement = wrappedElement; + ElementObject = new SerializedObject(wrappedElement); + + OnClickAddNode = onClickAddNode; + OnClickRemoveNode = onClickRemoveNode; + + ReBindAllProperties(); + } + + private void ContextMenu(ContextualMenuPopulateEvent evt) + { + foreach (Type type in + Assembly.GetAssembly(typeof(BehaviorTreeElement)).GetTypes() + .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(BehaviorTreeElement)))) + { + var menuStrings = type.ToString().Split('.'); + evt.menu.AppendAction("Change/" + menuStrings[menuStrings.Length - 2] + + "/" + menuStrings.Last(), OnMenuChangeAction); + evt.menu.AppendAction("Remove", OnMenuRemoveAction); + } + } + + private void OnMenuRemoveAction(DropdownMenuAction obj) + { + OnClickRemoveNode(this); + } + + void OnMenuChangeAction(DropdownMenuAction action) + { + string selectedName = action.name.Split('/').Last(); + var typeName = from type in typeof(BehaviorTreeElement).Assembly.GetTypes() + where type.Name.Contains(selectedName) + select type; + + OnClickRemoveNode(this); + + var treeElement = (BehaviorTreeElement)ScriptableObject.CreateInstance(typeName.First()); + treeElement.ID = 0; + treeElement.Name = selectedName; + treeElement.ElementType = typeName.First().ToString(); + this.TreeElement = treeElement; + ElementObject = new SerializedObject(TreeElement); + + OnClickAddNode(this); + ReBindAllProperties(); + } + + internal void ReBindAllProperties() + { + this.Clear(); + this.Bind(ElementObject); + + var visualTree = AssetDatabase.LoadAssetAtPath("Assets/Visual Behavior Tree/Editor/UIENodeEditor/Node/EditorNode.uxml"); + VisualElement uxmlRoot = visualTree.Instantiate(); + this.Add(uxmlRoot); + + var rootContainer = uxmlRoot.Q("RootContainer"); + + rootContainer.style.width = this.style.width; + rootContainer.style.height = this.style.height; + + var parentContainer = uxmlRoot.Q("ParentConnectorContainer"); + inPoint.AddToClassList("NodeButton"); + parentContainer.Insert(1, inPoint); + + var typeLabel = this.Q