Пример #1
0
        public static void LoadScene(string __target, SceneTrans_SO __data, params string[] __parameter)
        {
            if (_isBusy)
            {
                return;
            }
            _isBusy = true;

            #region singleton
            if (_singleton == null)
            {
                _singleton = CreateCanvas().AddComponent <SceneDirector>();
                _canvas    = _singleton.GetComponent <Canvas>();
            }
            #endregion

            // create transition object
            Trans trans = null;
            switch (__data.twnProperty)
            {
            case SceneTrans_SO.TwnProperty.alpha:
                trans = new TransAlpha(__data);
                break;

            case SceneTrans_SO.TwnProperty.position:
                trans = new TransPos(__data);
                break;

            case SceneTrans_SO.TwnProperty.rotation:
                trans = new TransRot(__data);
                break;

            case SceneTrans_SO.TwnProperty.scale:
                trans = new TransScale(__data);
                break;
            }



            // Init Load Scene
            trans.StartTransition(() => {
                SceneManager.LoadSceneAsync(__target).completed += (asyncOperation) =>
                {
                    onLoadEnd?.Invoke(__parameter);
                    trans.ExitTransition(() => {
                        trans.Clear();
                        _isBusy = false;
                    });
                };
            });
        }
Пример #2
0
            public TransScale(SceneTrans_SO __data)
            {
                // Now we have cover prefab, so we need to spawn it
                _cover = Instantiate(__data.cover, _canvas.transform);

                _twnNormData = new TwnVector(
                    __target: _cover,
                    __origin: __data.refStart.GetComponent <RectTransform>().localScale,
                    __key: "cover",
                    __vector2: __data.refEnd.GetComponent <RectTransform>().localScale,
                    __time: __data.twnTime,
                    __tweenType: __data.leanTweenType);
                _twner = new ScaleTwn(_twnNormData);
            }
Пример #3
0
            public TransAlpha(SceneTrans_SO __data)
            {
                // Now we have cover prefab, so we need to spawn it
                _cover = Instantiate(__data.cover, _canvas.transform);

                _twnColorData = new TwnColor(
                    __target: _cover,
                    __origin: new Color(0, 0, 0, __data.refStart.GetComponent <CanvasGroup>().alpha),
                    __key: "cover",
                    __color: new Color(0, 0, 0, __data.refEnd.GetComponent <CanvasGroup>().alpha),
                    __targetType: TwnColor.TargetType.canvasGroup,
                    __time: __data.twnTime,
                    __tweenType: __data.leanTweenType);
                _twner = new ColorTwn(_twnColorData);
            }