NeoAsync is a growing toolset to manage asynchronous tasks when programming in Unity3D
Unity3D
NeoAsync is a growing toolset to manage asynchronous tasks when programming in Unity3D
If you don't have access to Microsoft VisualStudio you can just use Unity3D and its compiler. Or use your VisualStudio installation in combination with Visual Studio Tools for Unity to compile a DLL-file, which can be included into your project.
Assets\NeoAsync into your projectUnityVS.NeoAsync.sln
CoroutineStarter
Allows starting a Unity-based coroutine from any instance.
class SomeClass {
public void Do(){
CoroutineStarter.Instance.Add(doLazy());
}
private IEnumerator doLazy(){
yield return UnityEngine.WaitForSeconds(5f);
UnityEngine.Debug.Log("This should be invoked as a coroutine");
}
}
Provides a generic cache for any kind of objects which loading might need some time and can be referenced by a string key.
class SomeClass{
private readonly Cache<UnityEngine.GameObject> cache;
public SomeClass(){
cache = new Cache<UnityEngine.GameObject>(resolveGameObject);
}
public void Do(){
cache.Get("MyBigGameObject", (go) => go.transform.position = UnityEngine.Vector3.zero);
}
private GameObject resolveGameObject(string key){
UnityEngine.Resources.Load<GameObject>(key);
}
}
Allows easy time-driven callbacks:
// In the best case inject a Timing instance
[Inject]
public ITiming Timing { get; set; }
// Than in your functions created a deferred call
IDeferred after = Timing.After(5, () => UnityEngine.Debug.Log("This will be invoked in 5 seconds"));
// You can abort the call (if not already executed)
after.Abort();
// Also a interval-based variant is available for convience
Timing.Every(5, () => UnityEnging.Debug.Log("This will be invoked EVERY 5 seconds"));
By using an Dependency-Injection pattern / framework (e.g. Strange) unit-testing the timing behavior is so easy.
You can run the tests using the offical Unity Testing Tools. Just install the Unity package and use the Unit Test Runner.