public IEnumerator FadeTo(float targetAlpha, float duration, callBackDel callbackFunc, String Text) { if (panelImage == null) { panelImage = GameObject.FindGameObjectWithTag(Tags.fadePanel).GetComponent <Image>(); textElmt = panelImage.gameObject.GetComponentInChildren <Text>(); } float currentAlpha = panelImage.color.a; textElmt.text = Text; float alphaSpeed = 0.0f; while (Math.Abs(currentAlpha - targetAlpha) >= 0.01f) { currentAlpha = Mathf.SmoothDamp(currentAlpha, targetAlpha, ref alphaSpeed, duration); //(currentAlpha, targetAlpha, Time.fixedDeltaTime/duration); var tempColor = panelImage.color; var tempTxtColor = textElmt.color; tempColor.a = currentAlpha; tempTxtColor.a = currentAlpha; panelImage.color = tempColor; textElmt.color = tempTxtColor; yield return(null); } if (callbackFunc != null) { callbackFunc(); } }
public void FadeIn(callBackDel callbackFunc, float duration, String Text) { StopAllCoroutines(); StartCoroutine(FadeTo(1.0f, duration, callbackFunc, Text)); }
public void FadeIn(float duration, callBackDel callbackFunc) { FadeIn(callbackFunc, duration, ""); }
public void FadeIn(callBackDel callbackFunc, String Text) { FadeIn(callbackFunc, standardTime, Text); }
public void FadeIn(callBackDel callbackFunc) { FadeIn(callbackFunc, standardTime, ""); }