Legacy Documentation: Version 5.6 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Mathf.NextPowerOfTwo

public static int NextPowerOfTwo(int value);

Description

Returns the next power of two value.

using UnityEngine;
using System.Collections;

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