Mathf.NextPowerOfTwo

切换到手册
public static int NextPowerOfTwo (int value);

描述

返回大于或等于参数的下一个 2 的幂。

using UnityEngine;

public class ExampleClass : MonoBehaviour { void Start() { //Prints 8 to the console Debug.Log(Mathf.NextPowerOfTwo(7));

//Prints 256 to the console Debug.Log(Mathf.NextPowerOfTwo(139));

//Prints 256 to the console Debug.Log(Mathf.NextPowerOfTwo(256)); } }