// Start is called before the first frame update
    IEnumerator Start()
    {
        var cor = new CoroutineObj();

        cor.SetRunner(this);
        cor.StartCoroutine(E1());
        yield return(new WaitForSeconds(2));

        cor.StartCoroutine(E2());
    }
Esempio n. 2
0
    public static CoroutineObj StartSceneCoroutineTimer(CoroutineAction co)
    {
        GameObject   go  = new GameObject();
        CoroutineObj obj = go.AddComponent <CoroutineObj>();

        obj.StartCoroutine(co());
        go.name = "_Timer" + co.Target.ToString();
        return(obj);
    }
Esempio n. 3
0
    /// <summary>
    /// 会随着场景切换而清理的coroutine
    /// </summary>
    /// <param name="co">Co.</param>
    public static CoroutineObj StartSceneCoroutine <T1, T2>(CoroutineAction <T1, T2> co, T1 t1, T2 t2, bool destory = true)
    {
        GameObject   go  = new GameObject();
        CoroutineObj obj = go.AddComponent <CoroutineObj>();

        obj.StartCoroutine(co(t1, t2));
        go.name = "_co" + co.Target.ToString();
        if (destory)
        {
            optimized_Destory(go, 3f);
        }
        //else
        //    SceneManager.instance.clearOnChangeScene.Add(go);
        return(obj);
    }
Esempio n. 4
0
    public static CoroutineObj StartSceneCoroutine(CoroutineAction_Params co, bool destory = true, params object[] args)
    {
        GameObject   go  = new GameObject();
        CoroutineObj obj = go.AddComponent <CoroutineObj>();

        obj.StartCoroutine(co(args));
        go.name = "_co" + co.Target.ToString();
        if (destory)
        {
            optimized_Destory(go, 3f);
        }
        else
        {
            SceneManager.instance.clearOnChangeScene.Add(go);
        }
        return(obj);
    }
Esempio n. 5
0
    /// <summary>
    /// Async Load perfabs
    /// </summary>
    /// <param name="path"></param>
    /// <param name="Callback"></param>
    public void LoadGameObjectAsync(string path, Action <UnityEngine.GameObject> Callback)
    {
        if (SceneManager.couroutineObj == null)
        {
            Debug.Log(" 场景切换中,终止场景内的异步加载执行!");
            return;
        }
        CoroutineObj obj = SceneManager.couroutineObj.GetComponent <CoroutineObj>();

        obj.StartCoroutine(LoadAsync(path, (asset) =>
        {
            if (asset == null)
            {
                throw new UnityException("can not load game object:" + path);
            }
            GameObject go = (GameObject)Instantiate(asset);
            Callback(go);
        }));
    }