Ejemplo n.º 1
0
    //异步加载场景

    IEnumerator LoadScene(string[] teammates, string[] enemys, int index)
    {
        AsyncOperation async         = SceneManager.LoadSceneAsync(index);
        GameObject     loadingWindow = GameObject.Find("Canvas").transform.Find("LoadingWindow").gameObject;

        loadingWindow.SetActive(true);
        loadingWindow.transform.Find("Slider").gameObject.GetComponent <Slider>().value = async.progress / 0.9f;
        async.allowSceneActivation = false;
        StartCoroutine(AllowSceneActivation(1f, async));
        while (!async.isDone)
        {
            loadingWindow.transform.Find("Slider").gameObject.GetComponent <Slider>().value = async.progress / 0.9f;
            yield return(null);
        }
        GetComponent <BattleManager>().Init();
        //加入战斗
        BattleManager battleManager = this.GetComponent <BattleManager>();

        foreach (string teammate in teammates)
        {
            battleManager.AddTeammates(teammate);
        }
        foreach (string enemy in enemys)
        {
            battleManager.AddEnemys(enemy);
        }
    }