示例#1
0
    //Add a fade in operation by method
    public void AddFadeIn(float duration)
    {
        FadeOperation fadeIn = new FadeOperation(FadeOption.FadeIn, duration);

        fadeIn.ConfigureFade(canvasGroup);
        fadeOperations.Add(fadeIn);
    }
示例#2
0
    //Add a fade in operation by method
    public void AddFadeOut(float duration)
    {
        FadeOperation fadeOut = new FadeOperation(FadeOption.FadeOut, duration);

        fadeOut.ConfigureFade(canvasGroup);
        fadeOperations.Add(fadeOut);
    }
示例#3
0
    void Update()
    {
        if (fadeOperations.Count == 0)
        {
            OpsHasFinished = true;
            return;
        }

        OpsHasFinished = false;
        FadeOperation fadeOp = fadeOperations [0];

        fadeOp.Update();

        if (fadeOp.fadeDone)
        {
            UpdateFadeStatus(fadeOp);
            fadeOperations.Remove(fadeOp);

            //if there are more operations go to the next otherwise stop
            if (fadeOperations.Count > 0)
            {
                fadeOperations[0].ConfigureFade(canvasGroup);
            }
        }
    }
示例#4
0
 void UpdateFadeStatus(FadeOperation fadeOp)
 {
     if (fadeOp.fadeOption == FadeOption.FadeIn)
     {
         isFadeIn = true;
     }
     else
     {
         isFadeIn = false;
     }
 }
示例#5
0
        void targetForm_Load(object sender, EventArgs e)
        {
            //Check to see if the form is about to be shown

            //Make sure that we are dealing with a layered window
            EnsureLayeredWindow();
            //Set the fade oparetion
            _fadeOperation = FadeOperation.FadeIn;
            //Start the transition
            _timer.Enabled = true;
        }
示例#6
0
        void targetForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!e.Cancel && e.CloseReason == CloseReason.UserClosing)
            {
                //Make sure that we are not already in a fading process.
                //This can happen if the fade in operation is not finished before the user closes the form
                if (_isFading)
                {
                    _timer.Enabled = false;
                    e.Cancel       = false;
                }
                else
                {
                    //Set the fade operation
                    _fadeOperation = FadeOperation.FadeOut;
                    //Start the transition
                    _timer.Enabled = true;

                    e.Cancel = true;
                }
            }
        }
示例#7
0
    void Update()
    {
        if (currentOperation != null)
        {
            currentOperation.elapsedTime += Time.deltaTime;
            Color imgColor = img.color;
            switch (currentOperation.fadeDirection)
            {
            case FadeDirection.FadeIn:
                imgColor.a = currentOperation.elapsedTime / currentOperation.duration;
                break;

            case FadeDirection.FadeOut:
                imgColor.a = 1 - currentOperation.elapsedTime / currentOperation.duration;
                break;
            }
            img.color = imgColor;
            if (currentOperation.elapsedTime >= currentOperation.duration)
            {
                currentOperation.complete = true;
                currentOperation          = null;
            }
        }
    }
示例#8
0
 public FadeOperation SetFade(FadeDirection direction, float duration)
 {
     currentOperation = new FadeOperation(direction, duration);
     return(currentOperation);
 }
示例#9
0
 public static IEnumerator FadeInOut(FadeOperation _op)
 {
     yield return(new WaitForEndOfFrame());
 }