SystemInfo.processorCount 处理器数量

static var processorCount : int

Description描述

Number of processors present (Read Only).

当前处理器的数量。(只读)

如果是双核CPU,返回的就是2,四核CPU返回的就是4。

This is number of processors as reported by the operating system. The processors could be separate processors, cores of the same processor, or logical processors (e.g. in case of one Hyper-Threaded CPU, this would report two CPUs since that's what it looks like to the system).

这是由操作系统报告的处理器数量。该处理器可以是独立处理器,核心相同的处理器,或逻辑处理器(例如,在一个超线程的CPU,这可以报告为两个CPU)。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		print(SystemInfo.processorCount);
	}
}
// Prints "4" on a quad-core CPU.
//打印当前CPU的核心数
print (SystemInfo.processorCount);

参见: SystemInfo.processorType.

Page last updated: 2011-3-18