Esempio n. 1
0
 void Start()
 {
     threadPool = new Kayac.SimpleThreadPool();
     mode       = Mode.Gpu;
     UpdateThreadCountText();
     threadSlider.value = threadPool.threadCount;
     Reset();
     prevFrameTime = DateTime.Now;
 }
Esempio n. 2
0
    void Update()
    {
        var now       = DateTime.Now;
        var deltaTime = (float)(now - prevFrameTime).Ticks / (float)TimeSpan.TicksPerSecond;

        prevFrameTime = now;
        avgDeltaTime *= 0.9f;
        avgDeltaTime += deltaTime * 0.1f;
        var fps = 1f / avgDeltaTime;

        fpsText.text = fps.ToString("F1");
        bool changed = false;

        if (gpuToggle.isOn && (mode == Mode.Cpu))
        {
            changed = true;
            mode    = Mode.Gpu;
        }
        else if (!gpuToggle.isOn && (mode == Mode.Gpu))
        {
            changed = true;
            mode    = Mode.Cpu;
        }
        var newSizeLog = Mathf.RoundToInt(sizeSlider.value);

        if (newSizeLog != sizeLog)
        {
            sizeLog = newSizeLog;
            changed = true;
        }
        if (changed)
        {
            Reset();
        }
        UpdateTexture();

        var newThreadCount = Mathf.RoundToInt(threadSlider.value);

        if (newThreadCount != threadPool.threadCount)
        {
            UpdateThreadCountText();
            threadPool.Dispose();
            threadPool = new Kayac.SimpleThreadPool(newThreadCount);
        }
    }