public CrossFadeAlpha ( float alpha, float duration, bool ignoreTimeScale ) : void | ||
alpha | float | |
duration | float | |
ignoreTimeScale | bool | |
return | void |
void Start() { rectTransform = GetComponent<RectTransform>(); //Create shadows shadow = Instantiate(Resources.Load("UI/Shadows/Shadow-3") as GameObject).GetComponent<Graphic>(); shadowHover = Instantiate(Resources.Load("UI/Shadows/Shadow-5") as GameObject).GetComponent<Graphic>(); //Set parents shadow.transform.SetParent(transform.parent); shadowHover.transform.SetParent(transform.parent); //Set names shadow.transform.name = transform.name + " Shadow"; shadowHover.transform.name = transform.name + " Hover Shadow"; //Order transforms shadow.transform.SetAsLastSibling(); shadowHover.transform.SetAsLastSibling(); transform.SetAsLastSibling(); //Hide at first FadeOut(0f); shadow.CrossFadeAlpha(0f, 0f, false); shadowHover.CrossFadeAlpha(0f, 0f, false); //Fade in FadeIn(fadeDuration); shadow.CrossFadeAlpha(1f, fadeDuration, false); }
public static void CrossFadeAlphaFixed(this UnityEngine.UI.Graphic img, float alpha, float duration, bool ignoreTimeScale) { //Make the alpha 1 Color fixedColor = img.color; fixedColor.a = 1; img.color = fixedColor; //Set the 0 to zero then duration to 0 img.CrossFadeAlpha(0f, 0f, true); //Finally perform CrossFadeAlpha img.CrossFadeAlpha(alpha, duration, ignoreTimeScale); }
IEnumerator FadeOutMask(Graphic g) { g.CrossFadeAlpha(0f, fadeDuration, true); yield return new WaitForSeconds(fadeDuration); g.gameObject.SetActive(false); }
private void GraphicComponentCreated(UnityEngine.UI.Graphic c, JSON.Object obj) { if (obj.ContainsKey("fadeIn")) { c.canvasRenderer.SetAlpha(0f); c.CrossFadeAlpha(1f, obj.GetFloat("fadeIn", 0), true); } }
// ------------------- public void ExecuteAction(ActionType action) { UnityEngine.UI.Graphic targetGr = this.GetActionGraphic(action); // Play a sound effect... if ((action == ActionType.LEFT_STAB) || (action == ActionType.RIGHT_STAB)) { this.PlaySound(this.soundStab); } else if ((action == ActionType.DODGE_LEFT) || (action == ActionType.DODGE_RIGHT)) { this.PlaySound(this.soundDodge); } else { this.PlaySound(this.soundSlash); } // Play animation... if (this.animator != null) { this.SetActionTriggerState(action); } // Show and fade out graphic... if (targetGr != null) { Color c = targetGr.color; c.a = 1.0f; targetGr.color = c; targetGr.CrossFadeAlpha(1, 0, true); targetGr.CrossFadeAlpha(0, this.fadeDur, true); } }
/// <summary> /// Play the appropriate effect. /// </summary> private void PlayEffect(bool instant) { if (graphic == null) { return; } #if UNITY_EDITOR if (!Application.isPlaying) { graphic.canvasRenderer.SetAlpha(m_IsOn ? 1f : 0f); } else #endif graphic.CrossFadeAlpha(m_IsOn ? 1f : 0f, instant ? 0f : 0.1f, true); }
static public int CrossFadeAlpha(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.UI.Graphic self = (UnityEngine.UI.Graphic)checkSelf(l); System.Single a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); System.Boolean a3; checkType(l, 4, out a3); self.CrossFadeAlpha(a1, a2, a3); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
static void Show(Graphic g) { g.CrossFadeAlpha(1f, 0f, false); }
static void Hide(Graphic g) { g.CrossFadeAlpha(0f, 0f, false); }
void FadeOut(Graphic graphic) { graphic.CrossFadeAlpha(0.01f, 2.0f, false); }
void FadeIn(Graphic graphic) { graphic.CrossFadeAlpha(10.0f, 0.0f, false); }
// Use this for initialization void Start() { graphic.CrossFadeAlpha(0, 2f, true); Invoke("StartGame", 3); }