public IEnumerator InstantiateAsync() { var prefab = new GameObject(); GameObject clone = null; //Call instantiate from background thread var task = Task.Run(() => { clone = UnityTaskUtil.InstantiateAsync(prefab).Result; }); yield return(new WaitUntil(() => task.IsCompleted)); Assert.IsTrue(clone != null); }
public IEnumerator InstantiateAsync_WithParent() { var prefab = new GameObject(); var parent = new GameObject().transform; GameObject clone = null; //Call instantiate from background thread var task = Task.Run(() => { clone = UnityTaskUtil.InstantiateAsync(prefab, parent).Result; }); yield return(new WaitUntil(() => task.IsCompleted)); Assert.IsTrue(clone != null && clone.transform.parent == parent); }