コード例 #1
0
    void Update()
    {
        // 以下ベンチマーク
        _times[_timeIndex] = Time.realtimeSinceStartup;
        _timeIndex++;
        if (_timeIndex >= _times.Length)
        {
            _timeIndex = 0;
        }
        var latest = ((_timeIndex - 1) < 0) ? (_times.Length - 1) : (_timeIndex - 1);

        this.averageFrameTime = (_times[latest] - _times[_timeIndex]) / (_times.Length - 1);
        if (_running)
        {
            var targetMs = this.heavyMode ? (1000f / 24f) : (1000f / 40f);
            var accel    = (((targetMs * 0.001f) - Time.unscaledDeltaTime) * (_count + 1f) * 0.1f) - (_countVelocity * 0.5f);
            _countVelocity += accel;
            _count         += _countVelocity;
            _count          = Mathf.Clamp(_count, 0f, 10000f);
        }
        else
        {
            _count         = 0f;
            _countVelocity = 0f;
        }
        _fillRenderer.SetCount(_count);
        _fillRenderer.ManualUpdate();
    }
コード例 #2
0
ファイル: Main.cs プロジェクト: nkjzm/UnitySamples
    void Update()
    {
        _times[_timeIndex] = Time.realtimeSinceStartup;
        _timeIndex++;
        if (_timeIndex >= _times.Length)
        {
            _timeIndex = 0;
        }
        _counts[_countIndex] = _count;
        _countIndex++;
        if (_countIndex >= _counts.Length)
        {
            _countIndex = 0;
        }

        if (_fillTestToggle.isOn)
        {
            var accel = (((1f / 24f) - Time.unscaledDeltaTime) * (_count + 1f) * 0.1f) - (_countVelocity * 0.5f);
            _countVelocity += accel;
            _count         += _countVelocity;
            _count          = Mathf.Clamp(_count, 0f, 10000f);
            _fillRenderer.SetCount((int)_count);
            _fillRenderer.SetMaterial(_fillTestMaterials[_fillTestMaterialIndex]);
            _fillRenderer.ManualUpdate();
        }
        _titleRoot.SetActive(!_fillTestToggle.isOn && (_coroutine == null));
        if (_autoTest)
        {
            UpdateAutoTest();
            Screen.sleepTimeout = SleepTimeout.NeverSleep;
        }
        else
        {
            Screen.sleepTimeout = SleepTimeout.SystemSetting;
        }

        if (_fillTestToggle.isOn)
        {
            _fillModeText.text = _fillTestMaterials[_fillTestMaterialIndex].name;
        }
        else
        {
            _fillModeText.text = "FillTest";
        }
    }
コード例 #3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            StartCoroutine(_slack.CoPostScreenshot(null, null, null, null, 0, false, Kayac.TextureUtil.FileType.Jpeg));
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            _postProcess.bloomCombineStartLevel -= 1;
            Debug.Log(_postProcess.bloomCombineStartLevel);
        }
        if (Input.GetKeyDown(KeyCode.F2))
        {
            _postProcess.bloomCombineStartLevel += 1;
            Debug.Log(_postProcess.bloomCombineStartLevel);
        }


        _postProcess.enabled         = _enableToggle.isOn;
        _stdPostProcessLayer.enabled = _enableStdToggle.isOn;
        float speed = _speedSlider.value;

        speed = Mathf.Pow(10f, (speed - 0.5f) * 3);
        float dt = Time.deltaTime * speed;

        for (int i = 0; i < _objects.Length; i++)
        {
            Update(i, dt);
        }
        // 以下ベンチマーク
        _times[_timeIndex] = Time.realtimeSinceStartup;
        _timeIndex++;
        if (_timeIndex >= _times.Length)
        {
            _timeIndex = 0;
        }
        var latest = ((_timeIndex - 1) < 0) ? (_times.Length - 1) : (_timeIndex - 1);
        var avg    = (_times[latest] - _times[_timeIndex]) / (_times.Length - 1);

        _text.text = "FrameTime: " + (avg * 1000f).ToString("N2") + "\nCount: " + _count.ToString("N2") + " " + _postProcess.bloomCombineStartLevel;

        // ベンチマーク中は物描かない
        _objectsRoot.gameObject.SetActive(!_benchmarkToggle.isOn);
        if (_benchmarkToggle.isOn)
        {
            var targetMs = _24fpsToggle.isOn ? (1000f / 24f) : (1000f / 40f);
            var accel    = (((targetMs * 0.001f) - Time.unscaledDeltaTime) * (_count + 1f) * 0.1f) - (_countVelocity * 0.5f);
            _countVelocity += accel;
            _count         += _countVelocity;
            _count          = Mathf.Clamp(_count, 0f, 10000f);
        }
        else
        {
            _count         = 0f;
            _countVelocity = 0f;
        }
        _fillRenderer.SetCount(_count);
        _fillRenderer.ManualUpdate();
        if (_logToggle.isOn)
        {
            _logText.text = _log.Tail(10);
        }
        _logText.enabled = _logToggle.isOn;
    }
コード例 #4
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            StartCoroutine(slack.CoPostScreenshot(null, null, null, null, 0, false, Kayac.TextureUtil.FileType.Jpeg));
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            postProcess.BloomCombineStartLevel -= 1;
            Debug.Log(postProcess.BloomCombineStartLevel);
        }
        if (Input.GetKeyDown(KeyCode.F2))
        {
            postProcess.BloomCombineStartLevel += 1;
            Debug.Log(postProcess.BloomCombineStartLevel);
        }


        postProcess.enabled         = enableToggle.isOn;
        stdPostProcessLayer.enabled = enableStdToggle.isOn;
        float speed = speedSlider.value;

        speed = Mathf.Pow(10f, (speed - 0.5f) * 3);
        float dt = Time.deltaTime * speed;

        for (int i = 0; i < objects.Length; i++)
        {
            Update(i, dt);
        }
        // 以下ベンチマーク
        times[timeIndex] = Time.realtimeSinceStartup;
        timeIndex++;
        if (timeIndex >= times.Length)
        {
            timeIndex = 0;
        }
        var latest = ((timeIndex - 1) < 0) ? (times.Length - 1) : (timeIndex - 1);
        var avg    = (times[latest] - times[timeIndex]) / (times.Length - 1);

        text.text = "FrameTime: " + (avg * 1000f).ToString("N2") + "\nCount: " + count.ToString("N2") + " " + postProcess.BloomCombineStartLevel;

        // ベンチマーク中は物描かない
        objectsRoot.gameObject.SetActive(!benchmarkToggle.isOn);
        if (benchmarkToggle.isOn)
        {
            var targetMs = fps24Toggle.isOn ? (1000f / 24f) : (1000f / 40f);
            var accel    = (((targetMs * 0.001f) - Time.unscaledDeltaTime) * (count + 1f) * 0.1f) - (countVelocity * 0.5f);
            countVelocity += accel;
            count         += countVelocity;
            count          = Mathf.Clamp(count, 0f, 10000f);
        }
        else
        {
            count         = 0f;
            countVelocity = 0f;
        }
        fillRenderer.SetCount(count);
        fillRenderer.ManualUpdate();
        if (logToggle.isOn)
        {
            logText.text = log.Tail(10);
        }
        logText.enabled = logToggle.isOn;
    }