예제 #1
0
        static void Main(string[] args)
        {
            var faded = new FadeMethods();

            faded.Setup();
            faded.flafla2();
            faded.Vector1();
            var image = new ImageFill();

            image.GlobalSetup();
            image.IterationSetup();
            image.OriginalGenerator();
            image.NewGenerator();



            //var summary1 = BenchmarkRunner.Run<FadeMethods>();
            var summary2 = BenchmarkRunner.Run <ImageFill>();
        }
예제 #2
0
    // Show / Hide fade animation coroutine
    private IEnumerator FadeAnimation(FadeMethods method, float FadeDuration)
    {
        if (this.panel == null)
        {
            yield break;
        }

        // Check if we are trying to fade in and the window is already shown
        if (method == FadeMethods.In && this.panel.alpha == 1f)
        {
            yield break;
        }
        else if (method == FadeMethods.Out && this.panel.alpha == 0f)
        {
            yield break;
        }

        // Define that animation is in progress
        this.animationCurrentMethod = method;

        // Get the timestamp
        float startTime = Time.time;

        // Determine Fade in or Fade out
        if (method == FadeMethods.In)
        {
            // Calculate the time we need to fade in from the current alpha
            float internalDuration = (FadeDuration - (FadeDuration * this.panel.alpha));

            // Update the start time
            startTime -= (FadeDuration - internalDuration);

            // Fade In
            while (Time.time < (startTime + internalDuration))
            {
                float RemainingTime = (startTime + FadeDuration) - Time.time;
                float ElapsedTime   = FadeDuration - RemainingTime;

                // Update the alpha by the percentage of the time elapsed
                this.panel.alpha = (ElapsedTime / FadeDuration);

                yield return(0);
            }

            // Make sure it's 1
            this.panel.alpha = 1.0f;

            if (this.onShowComplete != null)
            {
                this.onShowComplete();
            }
        }
        else if (method == FadeMethods.Out)
        {
            // Calculate the time we need to fade in from the current alpha
            float internalDuration = (FadeDuration * this.panel.alpha);

            // Update the start time
            startTime -= (FadeDuration - internalDuration);

            // Fade Out
            while (Time.time < (startTime + internalDuration))
            {
                float RemainingTime = (startTime + FadeDuration) - Time.time;

                // Update the alpha by the percentage of the remaing time
                this.panel.alpha = (RemainingTime / FadeDuration);

                yield return(0);
            }

            // Make sure it's 0
            this.panel.alpha = 0.0f;

            if (this.onHideComplete != null)
            {
                this.onHideComplete();
            }

            this.contentHolder.gameObject.SetActive(false);
        }

        // No longer animating
        this.animationCurrentMethod = FadeMethods.None;
    }