Unity 中的自动 2D URP 质量设置

问题描述 投票:0回答:1

所以我见过其他游戏自动为你设置质量级别,但我自己无法做到。 那么还有办法吗?

我找到了一个旧脚本,但它不起作用(我想知道为什么) 这是旧的片段:

public static void AutoChooseQualityLevel()
    {
        var shaderLevel = SystemInfo.graphicsShaderLevel;
        var vRam = SystemInfo.graphicsMemorySize;
        var cpuCount = SystemInfo.processorCount;
        var fillrate = 0;
        if (shaderLevel < 10)
            fillrate = 1000;
        else if (shaderLevel < 20)
            fillrate = 1300;
        else if (shaderLevel < 30)
            fillrate = 2000;
        else
            fillrate = 3000;
        if (cpuCount >= 6)
            fillrate *= 3;
        else if (cpuCount >= 3)
            fillrate *= 2;
        if (vRam >= 512)
            fillrate *= 2;
        else if (vRam <= 128)
            fillrate /= 2;
 
        var resX = Screen.currentResolution.width;
        var resY = Screen.currentResolution.height;
        const float targetFps = 60.0f;
        var fillNeed = (resX * resY + 400f*300f) * (targetFps / 1000000.0f);
        var levelMultiplier = new float[] { 5.0f, 30.0f, 80.0f, 130.0f, 200.0f, 320.0f };
 
        var maxQuality = QualitySettings.names.Length - 1;
        var level = 0;
        while (level < maxQuality && fillrate > fillNeed * levelMultiplier[level+1])
            ++level;
 
        var quality = QualitySettings.names[level];
        qualityLevel = quality;
    }
c# unity-game-engine 2d
1个回答
0
投票

斯基比迪

厕所

西格玛

对于

真实

© www.soinside.com 2019 - 2024. All rights reserved.