Version: 2020.2

JobsUtility.JobWorkerCount

切换到手册
public static int JobWorkerCount ;

描述

可用于 Unity JobQueue 的当前工作线程数目。

默认情况下,此属性采用 JobWorkerMaximumCount 的值。可在运行时设置此属性的值,以便动态减小可用于 Unity 作业队列的工作线程数。这有节能效果,或者减少共享或虚拟机上的 CPU 负载。如果有作为服务器运行的游戏的多个实例,需要防止任何实例独占机器资源,这将很有用。

You cannot set this value below 0, or above the value of the JobWorkerMaximumCount property. Trying to do so will throw an "out of range" exception.

On some platforms (eg. Android) Unity will automatically adjust this value at runtime in response to the operating system indicating that the number of available cores has changed. This can occur if the device has gone into, or come out of, power-saving mode. However if you set this property manually to any valid value, Unity will stop any automatic adjustment (thus ignoring any requests from the operating system). You can restore the automatic adjustment mode by calling ResetJobWorkerCount.