Ejemplo n.º 1
0
    IEnumerator LoadAs()//Function that load main game async
    {
        AsyncOperation op = SceneManager.LoadSceneAsync(1);

        AnimSys.isLoading = true;
        slide.SetActive(true);//slider gets shown
        AnimSys.isAnimationDone = false;


        AnimSys.EnableDisableButton(button, false); //start button gets deactivated when is pressed for preventing problems
        AnimSys.EnableDisableButton(AnimSys.OptionButton, false);
        AnimSys.EnableDisableButton(AnimSys.MapButton, false);

        op.allowSceneActivation = false;

        AnimSys.PlayAnimation(AnimSys.LeftBackgroundOption, "LeftAnim", 0);
        AnimSys.PlayAnimation(AnimSys.RightBackgroundOption, "RightAnim", 0);


        while (!op.isDone)// while loading is not complete, fill loading bar percentage
        {
            float progress = Mathf.Clamp01(op.progress / .9f);
            slide.GetComponent <Slider>().value = progress * 4;
            if (op.progress >= 0.9f)
            {
                AnimSys.EnableDisableUI(AnimSys.LeftBackgroundOption, true, false);
                AnimSys.EnableDisableUI(AnimSys.RightBackgroundOption, true, false);

                AnimSys.PlayAnimation(AnimSys.LeftBackgroundOption, "LeftAnim", 1);
                AnimSys.PlayAnimation(AnimSys.RightBackgroundOption, "RightAnim", 1);



                if (AnimSys.isAnimationDone)
                {
                    op.allowSceneActivation = true;
                }
            }

            yield return(null);
        }
    }