Exemplo n.º 1
0
        private static void Init()
        {
            dispatcher = new GameObject("TPFader");
            Canvas canvas = dispatcher.AddComponent <Canvas>();

            fadeLayout = new FadeLayout {
                Image        = dispatcher.AddComponent <Image>(),
                CanvasGrouup = dispatcher.AddComponent <CanvasGroup>()
            };

            fadeLayout.Image.rectTransform.sizeDelta = new Vector2(Screen.width, Screen.height);
            fadeLayout.Image.raycastTarget           = false;

            fadeLayout.CanvasGrouup.interactable       = false;
            fadeLayout.CanvasGrouup.blocksRaycasts     = false;
            fadeLayout.CanvasGrouup.ignoreParentGroups = true;
            fadeLayout.CanvasGrouup.alpha = 0;

            canvas.renderMode = RenderMode.ScreenSpaceOverlay;
            if (canvas.sortingOrder <= 1)
            {
                canvas.sortingOrder = 16;
            }
            UnityEngine.Object.DontDestroyOnLoad(dispatcher);
        }
        public void Fade(float time, FadeInfo fadeInfo, FadeLayout state)
        {
            state.CanvasGrouup.alpha = TPMath.PingPong(time * 2, 1f);

            if (time >= 0.5f && !string.IsNullOrEmpty(fadeInfo.FadeToScene))
            {
                SceneManager.LoadScene(fadeInfo.FadeToScene);
            }
        }
Exemplo n.º 3
0
 public void Fade(float time, FadeInfo fadeInfo, FadeLayout state)
 {
     if (!asyncLoad.isDone)
     {
         SetProgress(asyncLoad.progress);
         if (asyncLoad.progress >= 0.9f)
         {
             SetProgress(1f);
             if (TryLoadScene())
             {
                 fadeInfo.FadeAnim.AllowBreak = true;
             }
         }
     }
 }
Exemplo n.º 4
0
        public void InitializeFade(FadeInfo fadeInfo, FadeLayout state)
        {
            if (!layout)
            {
                layout = Object.Instantiate(ProgressPrefab);

                LoadingBar          = Object.Instantiate(LoadingBar, layout.transform);
                LoadingImage        = Object.Instantiate(LoadingImage, layout.transform);
                LoadingProgressText = Object.Instantiate(LoadingProgressText, layout.transform);
                LoadingText         = Object.Instantiate(LoadingText, layout.transform);

                asyncLoad = SceneManager.LoadSceneAsync(fadeInfo.FadeToScene);
                asyncLoad.allowSceneActivation = false;
            }
            layout.SetActive(true);
        }
Exemplo n.º 5
0
 public void CleanUp(FadeInfo fadeInfo, FadeLayout state)
 {
     layout.SetActive(false);
 }
 public void CleanUp(FadeInfo fadeInfo, FadeLayout state)
 {
 }
 public void InitializeFade(FadeInfo fadeInfo, FadeLayout state)
 {
     state.Image.sprite = FadeTexture;
     state.Image.color  = FadeColor;
 }