private void Update() { switch (currentFadeType) { case FADETYPE.IN: currentColor.a = Mathf.Max(currentColor.a - Time.deltaTime / fadeInTime, 0.0f); if (currentColor.a == 0.0f) { currentFadeType = FADETYPE.NONE; } break; case FADETYPE.OUT: currentColor.a = Mathf.Min(currentColor.a + Time.deltaTime / fadeOutTime, 1.0f); if (currentColor.a == 1.0f) { currentFadeType = FADETYPE.NONE; // after fade out is finished reset the player Utils.ResetPlayer(); } break; case FADETYPE.NONE: break; default: break; } fadeImage.color = currentColor; }
// Update is called once per frame void Update() { // fade in or fade out based on the objects state if (FadeType == FADETYPE.IN) { AlphaValue -= 0.25f * Time.deltaTime; // limit the possible alpha value if (AlphaValue < 0.0f) { AlphaValue = 0.0f; FadeType = FADETYPE.NONE; } } else if (FadeType == FADETYPE.OUT) { AlphaValue += Time.deltaTime; // limit the possible alpha value if (AlphaValue > 1.0f) { AlphaValue = 1.0f; FadeType = FADETYPE.NONE; ChangeLevel(); } } else if (FadeType == FADETYPE.RESPAWN) { AlphaValue += (2.0f * Time.deltaTime); // limit the possible alpha value if (AlphaValue > 1.0f) { AlphaValue = 1.0f; FadeType = FADETYPE.IN; GameObject.Find("PlayerCharacter").GetComponent <PlayerMovement>().RespawnPlayerAtCheckpoint(); } } // set the objects new colour spriteRenderer.color = new Color(spriteRenderer.color.r, spriteRenderer.color.g, spriteRenderer.color.b, AlphaValue); }
/// <summary> /// Respawns the fade /// </summary> public void RespawnFade() { // set the respawn state FadeType = FADETYPE.RESPAWN; }
/// <summary> /// Set the fade out state /// </summary> public void FadeOut() { FadeType = FADETYPE.OUT; }
// Use this for initialization void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); FadeType = FADETYPE.IN; AlphaValue = 1.0f; }
public void triggerFadeIn() { currentColor.a = 1.0f; currentFadeType = FADETYPE.IN; }
public void triggerFadeOut() { currentColor.a = 0.0f; currentFadeType = FADETYPE.OUT; }
void Update() { Fadeings -= Time.deltaTime / (mode == FADEMODE.OUT ? SceneLoader.FadeOutTime : SceneLoader.FadeInTime); if (Fadeings < -1) { Fadeings = -1; } print("fadeings:::" + Fadeings_); vals += Time.deltaTime; if (type_ == FADETYPE.DX) { type_ = FADETYPE.Normal; if (mode == FADEMODE.IN) { //変化 } else { //変化 } } else if (type_ == FADETYPE.Normal) { targetUI.color = new Color(FadeColor.r, FadeColor.g, FadeColor.b, 1 - Mathf.Abs(Fadeings_)); } if (mode == FADEMODE.IN) { if (Fadeings_ <= -1f) { IsActive = false; Destroy(gameObject); IsFade = false; _name = ""; _index = -1; //Fadeings = -1; } } else { if (FadeHandle) { mode = FADEMODE.IN; } if (Fadeings_ <= 0) { //Fadeings = 0; if (_name != string.Empty) { SceneLoader.LoadN(_name); } else if (_index >= 0) { SceneLoader.LoadN(_index); } } } }