void Update() { switch (phase) { case GlowingPhase.GETTING_BIGGER: size += Time.deltaTime*flashduration; if (style == GlowingStyle.FADE_AND_FLASH || style == GlowingStyle.FADE) { fade += Time.deltaTime/2; } if (size >= 0.5f) { size = 0.5f; phase = GlowingPhase.MOVING; } break; case GlowingPhase.MOVING: pos += Time.deltaTime*flashduration; if (pos >= 1f) { pos = 1f; phase = GlowingPhase.GETTING_SMALLER; } break; case GlowingPhase.GETTING_SMALLER: size -= Time.deltaTime*flashduration; if (style == GlowingStyle.FADE_AND_FLASH || style == GlowingStyle.FADE) { fade -= Time.deltaTime/2; } if (size <= 0f) { size = 0f; phase = GlowingPhase.WAITING; } break; case GlowingPhase.WAITING: pos = 0f; size = 0f; if (style == GlowingStyle.FADE_AND_FLASH || style == GlowingStyle.FADE) { fade = 0f; } time_since_last_glow += Time.deltaTime; if (time_since_last_glow > speed) { time_since_last_glow = 0f; phase = GlowingPhase.GETTING_BIGGER; } break; } shader.SetFloat ("_ShineLocation", pos); shader.SetFloat ("_ShineWidth", size); if (style == GlowingStyle.FADE_AND_FLASH || style == GlowingStyle.FADE) { shader.SetColor ("_Color", new Color(1,1,1,fade)); } }
void Update() { switch (phase) { case GlowingPhase.GETTING_BIGGER: size += Time.deltaTime * flashduration; if (style == GlowingStyle.FADE_AND_FLASH || style == GlowingStyle.FADE) { fade += Time.deltaTime / 2; } if (size >= 0.5f) { size = 0.5f; phase = GlowingPhase.MOVING; } break; case GlowingPhase.MOVING: pos += Time.deltaTime * flashduration; if (pos >= 1f) { pos = 1f; phase = GlowingPhase.GETTING_SMALLER; } break; case GlowingPhase.GETTING_SMALLER: size -= Time.deltaTime * flashduration; if (style == GlowingStyle.FADE_AND_FLASH || style == GlowingStyle.FADE) { fade -= Time.deltaTime / 2; } if (size <= 0f) { size = 0f; phase = GlowingPhase.WAITING; } break; case GlowingPhase.WAITING: pos = 0f; size = 0f; if (style == GlowingStyle.FADE_AND_FLASH || style == GlowingStyle.FADE) { fade = 0f; } time_since_last_glow += Time.deltaTime; if (time_since_last_glow > speed) { time_since_last_glow = 0f; phase = GlowingPhase.GETTING_BIGGER; } break; } shader.SetFloat("_ShineLocation", pos); shader.SetFloat("_ShineWidth", size); if (style == GlowingStyle.FADE_AND_FLASH || style == GlowingStyle.FADE) { shader.SetColor("_Color", new Color(1, 1, 1, fade)); } }