Version: 2017.1

Mathf.ClosestPowerOfTwo

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

描述

返回最接近的 2 的幂值。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { Debug.Log(Mathf.ClosestPowerOfTwo(7)); Debug.Log(Mathf.ClosestPowerOfTwo(19)); } }