예제 #1
0
        private IEnumerator FadeRoutine(ProjectionRenderer Projection, float UpdateRate)
        {
            //Execution check
            if (executing || fade == null)
            {
                yield break;
            }
            else
            {
                executing = true;
            }

            //Cache alpha & scale
            float   originalAlpha = GetAlpha(Projection);
            Vector3 originalScale = Projection.transform.localScale;

            //Setup wrap mode
            switch (wrapMode)
            {
            case FadeWrapMode.Loop:
                fade.postWrapMode = WrapMode.Loop;
                break;

            case FadeWrapMode.PingPong:
                fade.postWrapMode = WrapMode.PingPong;
                break;

            case FadeWrapMode.Once:
            case FadeWrapMode.Clamp:
                fade.postWrapMode = WrapMode.ClampForever;
                break;
            }

            //Perform fade
            float timeElapsed = 0;

            while ((wrapMode != FadeWrapMode.Clamp && wrapMode != FadeWrapMode.Once) || timeElapsed <= fadeLength)
            {
                ApplyFade(Projection, originalAlpha, originalScale, timeElapsed / fadeLength);

                //Update time elapsed
                timeElapsed += UpdateRate;
                yield return(new WaitForSeconds(UpdateRate));
            }

            //Apply final value
            if (wrapMode == FadeWrapMode.Clamp)
            {
                ApplyFade(Projection, originalAlpha, originalScale, 1);
            }

            //Destroy
            if (wrapMode == FadeWrapMode.Once)
            {
                Projection.Destroy();
            }

            //No longer executing
            executing = false;
        }
예제 #2
0
        public override void Perform()
        {
            //Execution check
            if (!executing || fade == null)
            {
                return;
            }

            //Perform fade
            if ((wrapMode != FadeWrapMode.Clamp && wrapMode != FadeWrapMode.Once) || timeElapsed <= fadeLength)
            {
                //Update time elapsed
                timeElapsed += UpdateRate;

                //Apply fade
                ApplyFade(projection, timeElapsed / fadeLength);
                return;
            }

            //Apply final value
            if (wrapMode == FadeWrapMode.Clamp)
            {
                ApplyFade(projection, 1);
            }

            //Destroy
            if (wrapMode == FadeWrapMode.Once)
            {
                projection.Destroy();
            }

            //No longer executing
            executing = false;
        }
예제 #3
0
        public IEnumerator CullRoutine(ProjectionRenderer Projection, float UpdateRate)
        {
            //Execution check
            if (executing)
            {
                yield break;
            }
            else
            {
                executing = true;
            }

            //Perform fade
            float timeElapsed = 0;

            while (timeElapsed < cullTime)
            {
                //Update time elapsed
                timeElapsed += UpdateRate;

                //Reset time elapsed if visible
                if (Projection.Renderer.isVisible)
                {
                    timeElapsed = 0;
                }

                yield return(new WaitForSeconds(UpdateRate));
            }

            //Destroy projection
            Projection.Destroy();

            //No longer executing
            executing = false;
        }
예제 #4
0
        private void Update()
        {
            //Calculate count
            int count = (collumns * rows) - (skipFirst + skipLast);

            //Increment time
            if (!paused)
            {
                time += Time.deltaTime * speed;
            }
            if (time > count)
            {
                if (destroyOnComplete)
                {
                    projection.Destroy();
                    return;
                }
                else
                {
                    time -= count;
                }
            }

            //Calculate current frame
            int frame = skipFirst + Mathf.FloorToInt(time);

            //Calculate frame size
            Vector2 size = new Vector2(1.0f / collumns, 1.0f / rows);

            //Calculate current row & collumn
            int row     = frame / collumns;
            int collumn = frame % collumns;

            //Calculate offset
            float x = size.x * collumn;
            float y = size.y * row;

            if (!invertY)
            {
                y = 1 - size.y - y;
            }

            //Set tiling
            projection.Tiling = new Vector2(size.x, size.y);

            //Set offset
            projection.Offset = new Vector2(x, y);

            //Update projection with new properties
            projection.UpdateProperties();
        }
예제 #5
0
파일: Cull.cs 프로젝트: micodemo1/MonoNoke
        public override void Perform()
        {
            //Perform cull check
            if (timeElapsed < cullTime)
            {
                //Update time elapsed
                timeElapsed += UpdateRate;

                //Reset time elapsed if visible
                if (projection.Renderer.isVisible)
                {
                    timeElapsed = 0;
                }
                return;
            }

            //Destroy projection
            projection.Destroy();
        }