Example #1
0
        /// <summary>
        /// this method signals a cleanup (duh) and notifies event listeners
        /// </summary>
        private void cleanup()
        {
            if (_instance == null)
            {
                return;
            }

            if (onTransitionComplete != null)
            {
                onTransitionComplete();
            }

            _transitionKitDelegate = null;

            // if we are keeping TK alive we only need to free resources and not delete ourself completely
            if (keepTransitionKitInstance)
            {
                GetComponent <MeshRenderer>().material.mainTexture = null;
                GetComponent <MeshFilter>().mesh = null;
                gameObject.SetActive(false);
                transitionKitCamera.enabled = false;
            }
            else
            {
                Destroy(gameObject);
                _instance = null;
            }
        }
Example #2
0
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;
            transitionKit.material.color = backgroundColor;
            transitionKit.material.SetTexture("_MaskTex", maskTexture);

            if (nextScene >= 0)
            {
                SceneManager.LoadSceneAsync(nextScene);
            }

            // this does the zoom/rotation
            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration)));

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }

            // now that the new scene is loaded we zoom the mask back out
            transitionKit.makeTextureTransparent();

            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration, true)));
        }
Example #3
0
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;
            transitionKit.material.color = fadeToColor;

            if (nextScene >= 0)
            {
                SceneManager.LoadSceneAsync(nextScene);
            }

            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration)));

            transitionKit.makeTextureTransparent();

            if (fadedDelay > 0)
            {
                yield return(new WaitForSeconds(fadedDelay));
            }

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }

            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration, true)));
        }
Example #4
0
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            if (nextScene >= 0)
            {
                //Application.LoadLevelAsync( nextScene );
                SceneManager.LoadSceneAsync(nextScene);
            }

            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;

            var startValue = pixellateMin;
            var endValue   = pixellateMax;

            transitionKit.material.SetFloat("_WidthAspectMultiplier", 1f / Camera.main.aspect);

            var elapsed = 0f;

            while (elapsed < duration)
            {
                elapsed += transitionKit.deltaTime;
                var step = Mathf.Pow(elapsed / duration, 2f);
                transitionKit.material.SetFloat("_CellSize", Mathf.Lerp(startValue, endValue, step));

                yield return(null);
            }

            if (pixelatedDelay > 0)
            {
                yield return(new WaitForSeconds(pixelatedDelay));
            }

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }

            var desiredScale = Vector3.zero;

            switch (finalScaleEffect)
            {
            case PixelateFinalScaleEffect.ToPoint:
                desiredScale = new Vector3(0f, 0f, transitionKit.transform.localScale.z);
                break;

            case PixelateFinalScaleEffect.Zoom:
                desiredScale = new Vector3(transitionKit.transform.localScale.x * 5f, transitionKit.transform.localScale.y * 5f, transitionKit.transform.localScale.z);
                break;

            case PixelateFinalScaleEffect.Horizontal:
                desiredScale = new Vector3(transitionKit.transform.localScale.x, 0, transitionKit.transform.localScale.z);
                break;

            case PixelateFinalScaleEffect.Vertical:
                desiredScale = new Vector3(0, transitionKit.transform.localScale.y, transitionKit.transform.localScale.z);
                break;
            }

            yield return(transitionKit.StartCoroutine(animateScale(transitionKit, duration * 0.5f, desiredScale)));
        }
Example #5
0
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;

            if (nextScene >= 0)
            {
                Application.LoadLevelAsync(nextScene);
            }

            var elapsed = 0f;

            while (elapsed < duration)
            {
                elapsed += Time.deltaTime;
                var step       = Mathf.Pow(elapsed / duration, 2f);
                var blurAmount = Mathf.Lerp(blurMin, blurMax, step);

                transitionKit.material.SetFloat("_BlurSize", blurAmount);

                yield return(null);
            }

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }
        }
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;
            transitionKit.material.color = squareColor;
            transitionKit.material.SetFloat("_Smoothness", smoothness);
            transitionKit.material.SetVector("_Size", squareSize);

            if (nextScene >= 0)
            {
                Application.LoadLevelAsync(nextScene);
            }

            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration)));

            transitionKit.makeTextureTransparent();

            if (fadedDelay > 0)
            {
                yield return(new WaitForSeconds(fadedDelay));
            }

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }

            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration, true)));
        }
Example #7
0
        public IEnumerator animateScale(TransitionKit transitionKit, float duration, Vector3 desiredScale)
        {
            var originalScale = transitionKit.transform.localScale;

            var elapsed = 0f;

            while (elapsed < duration)
            {
                elapsed += transitionKit.deltaTime;
                var step = Mathf.Pow(elapsed / duration, 2f);
                transitionKit.transform.localScale = Vector3.Lerp(originalScale, desiredScale, step);

                yield return(null);
            }
        }
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;

            // set some material properties
            transitionKit.material.SetFloat("_Speed", speed);
            transitionKit.material.SetFloat("_Amplitude", amplitude);

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                SceneManager.LoadSceneAsync(nextScene);
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }

            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration)));
        }
Example #9
0
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;

            // set some material properties
            transitionKit.material.SetFloat("_Size", size);
            transitionKit.material.SetFloat("_WindVerticalSegments", windVerticalSegments);

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                Application.LoadLevelAsync(nextScene);
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }

            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration)));
        }
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;

            // set some material properties
            transitionKit.material.SetFloat("_Perspective", perspective);
            transitionKit.material.SetFloat("_Depth", depth);
            transitionKit.material.SetInt("_Direction", runEffectInReverse ? 1 : 0);

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                SceneManager.LoadSceneAsync(nextScene);
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }

            yield return(transitionKit.StartCoroutine(transitionKit.tickProgressPropertyInMaterial(duration, false)));
        }
        public IEnumerator onScreenObscured(TransitionKit transitionKit)
        {
            transitionKit.transitionKitCamera.clearFlags = CameraClearFlags.Nothing;

            if (nextScene >= 0)
            {
                //Application.LoadLevelAsync( nextScene );
                SceneManager.LoadSceneAsync(nextScene);
            }

            // we dont transition back to the new scene unless it is loaded
            if (nextScene >= 0)
            {
                yield return(transitionKit.StartCoroutine(transitionKit.waitForLevelToLoad(nextScene)));
            }

            var transitionDistance = 10f;             // 2x our camera.orthoSize so we move the slices off screen
            var elapsed            = 0f;
            var mesh  = transitionKit.GetComponent <MeshFilter>().mesh;
            var verts = mesh.vertices;

            while (elapsed < duration)
            {
                elapsed += transitionKit.deltaTime;
                var step   = Mathf.Pow(elapsed / duration, 2f);
                var offset = Mathf.Lerp(0, transitionDistance, step);

                // transition our TriangleSlices
                for (var i = 0; i < _triangleSlices.Length; i++)
                {
                    // odd ones move down, even up
                    var sign = (i % 2 == 0) ? -1f : 1f;
                    _triangleSlices[i].shiftVerts(new Vector3(0, offset * sign), verts);
                }

                // reassign our verts
                mesh.vertices = verts;

                yield return(null);
            }
        }