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; }
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; }
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; }
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(); }
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(); }