Beispiel #1
0
    void Run(int sample)
    {
        var decoder = new MG.GIF.Decoder();

        var sw = new Stopwatch();

        sw.Start();

        foreach (var file in mFiles)
        {
            decoder.Load(file);

            var img = decoder.NextImage();

            while (img != null)
            {
                img = decoder.NextImage();
            }
        }

        sw.Stop();

        mSum        += sw.ElapsedMilliseconds;
        mSumSquares += sw.ElapsedMilliseconds * sw.ElapsedMilliseconds;

        var average  = (float)mSum / mCount;
        var variance = mSumSquares / mCount - average * average;

        UnityEngine.Debug.Log($"[{sample:00}]: av <color=yellow>{average:0.0}</color>ms, sd <color=yellow>{Mathf.Sqrt( variance ):0.0}</color> - {sw.ElapsedMilliseconds}ms");

        Text.text = $"[{sample:00}] {average:0.0}";
    }
Beispiel #2
0
    void Start()
    {
        if (string.IsNullOrWhiteSpace(Filename))
        {
            return;
        }

        var path = Path.Combine(Application.streamingAssetsPath, Filename);

        using (var decoder = new MG.GIF.Decoder(File.ReadAllBytes(path)))
        {
            var img = decoder.NextImage();

            while (img != null)
            {
                mFrames.Add(img.CreateTexture());
                mFrameDelay.Add(img.Delay / 1000.0f);
                img = decoder.NextImage();
            }
        }

        GetComponent <Renderer>().material.mainTexture = mFrames[0];
    }