示例#1
0
 protected override void Awake()
 {
     base.Awake();
     canvasGroup = GetComponent <CanvasGroup>();
     image       = GetComponent <Image>();
     FadeStarted = new FadeEvent();
     FadeEnded   = new FadeEvent();
     Debug.Log("Awake executed in Edit Mode!");
 }
示例#2
0
 void FadeToDark()
 {
     fader.alpha = Mathf.Lerp(fader.alpha, 1f, _fadeTime * Time.deltaTime);
     if (fader.alpha > 0.98)
     {
         if (_fadeInEvent != null)
         {
             _fadeInEvent();
             _fadeInEvent = null;
         }
         fader.alpha = 1f;
     }
 }
示例#3
0
    IEnumerator FadeSequence(FadeEvent e)
    {
        float    p        = 0;
        Material mat      = (e.renderer == null) ? e.sprite.material : e.renderer.material;
        Color    startCol = ((e.useCurrentAsStartCol) ? mat.color : e.startCol);

        while (p < 1)
        {
            p        += Time.deltaTime / e.duration;
            mat.color = Color.Lerp(startCol, e.targetCol, p);
            yield return(null);
        }
    }
示例#4
0
 private void ResetEvents()
 {
     OnFadeEnd = () =>
     {
         this.Enabled   = false;
         hasFadeStarted = false;
         ResetEvents();
     };
     OnFadeStart = () =>
     {
         hasFadeStarted = true;
     };
 }
示例#5
0
    void SetupBaseComponents()
    {
        canvasGroup = GetComponent <CanvasGroup>();
        image       = GetComponent <Image>();

        if (FadeStarted == null)
        {
            FadeStarted = new FadeEvent();
        }

        if (FadeEnded == null)
        {
            FadeEnded = new FadeEvent();
        }
    }
示例#6
0
    void HandleFadeEvent(BaseEvent anEvent)
    {
        FadeEvent fadeEvent = (FadeEvent)anEvent;

        myIsFadingIn = fadeEvent.myShouldFadeIn;
        myFadeTime   = fadeEvent.myFadeTime;
        if (myIsFadingIn == true)
        {
            myFadeDeltaTime = myFadeTime;
        }
        else
        {
            myFadeDeltaTime = 0;
        }
    }
示例#7
0
    void OnFadeEvent(FadeEvent eventdata)
    {
        //print("on");

        if (Fading != null)
        {
            StopCoroutine(Fading);
        }


        FadeColor = eventdata.newColor;
        FadeTime  = eventdata.time;

        if (!gameObject.activeInHierarchy)
        {
            return;
        }
        IsFading = true;

        if (sprite)
        {
            Fading = StartCoroutine(FadeToSprite(FadeColor, FadeTime));
        }
        else if (txt)
        {
            Fading = StartCoroutine(FadeToText(FadeColor, FadeTime));
        }
        else if (imgurd)
        {
            Fading = StartCoroutine(FadeToImage(FadeColor, FadeTime));
        }
        else if (pro)
        {
            Fading = StartCoroutine(FadeToTextMeshPro(FadeColor, FadeTime));
        }
        else if (progui)
        {
            Fading = StartCoroutine(FadeToTextMeshProUI(FadeColor, FadeTime));
        }
    }
示例#8
0
 //------------------------------------------------------------------------/
 // Procedures: Cross Fade
 //------------------------------------------------------------------------/
 private void SetFade(FadeEvent e)
 {
     continueInputEnabled = false;
     if (e.duration > 0.0f)
     {
         Invoke(Continue, e.duration);
     }
     else if (e.endOnAction)
     {
         this.Log("Continuing next frame (if there's no transitions queued up) ...");
         InvokeNextFrame(() =>
         {
             if (transitions.Empty())
             {
                 Continue();
             }
         });
     }
     else
     {
         this.Log("Indefinite fade set...");
     }
 }
示例#9
0
 public void ExitFading(FadeEvent fadeEvent = null)
 {
     _toLight      = true;
     _fadeOutEvent = fadeEvent;
 }
示例#10
0
 public void BeginFading(FadeEvent fadeEvent = null)
 {
     _toLight = false;
     gameObject.SetActive(true);
     _fadeInEvent = fadeEvent;
 }
示例#11
0
 private void OnCrossFadeEvent(FadeEvent e)
 {
     ProcessTransitionEvent(e, () => SetFade(e), null);
 }
示例#12
0
    IEnumerator FadeInCorou(float t = 1, bool ignoreTimeScale = false, bool isClickable = false, FadeEvent onEnd = null)
    {
        Color color = pnl.color;

        color.a           = 1;
        pnl.color         = color;
        pnl.raycastTarget = !isClickable;
        pnl.gameObject.SetActive(true);
        float tt = t;

        do
        {
            yield return(null);

            float time = ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;
            t        -= time;
            color.a  -= time / tt;
            pnl.color = color;
        } while (t > 0);
        pnl.gameObject.SetActive(false);
        if (onEnd != null)
        {
            onEnd.Invoke();
        }
    }
示例#13
0
 public void FadeIn(float t = 1, bool ignoreTimeScale = false, bool isClickable = false, FadeEvent onEnd = null)
 {
     Debug.Log("FadeIn");
     StartCoroutine(FadeInCorou(t, ignoreTimeScale, isClickable, onEnd));
 }