Min
Returns the smallest of two or more values.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
Min(float, float)
Returns the smallest of two or more values.
public static float Min(float a, float b)
Parameters
Returns
Type | Description |
|---|---|
| float |
Examples
using UnityEngine;public class ScriptExample : MonoBehaviour{ void Start() { // Prints 0 Debug.Log(Mathf.Min(0, Mathf.Infinity)); // Prints -Infinity Debug.Log(Mathf.Min(0, -Mathf.Infinity)); // Prints -Infinity Debug.Log(Mathf.Min(-Mathf.Infinity, Mathf.Infinity)); // Prints -1 Debug.Log(Mathf.Min(0, 1, 5, -1, 8, 10)); }}
Min(float[])
Returns the smallest of two or more values.
public static float Min(params float[] values)
Parameters
Returns
Type | Description |
|---|---|
| float |
Examples
using UnityEngine;public class ScriptExample : MonoBehaviour{ void Start() { // Prints 0 Debug.Log(Mathf.Min(0, Mathf.Infinity)); // Prints -Infinity Debug.Log(Mathf.Min(0, -Mathf.Infinity)); // Prints -Infinity Debug.Log(Mathf.Min(-Mathf.Infinity, Mathf.Infinity)); // Prints -1 Debug.Log(Mathf.Min(0, 1, 5, -1, 8, 10)); }}
Min(int, int)
Returns the smallest of two or more values.
public static int Min(int a, int b)
Parameters
Returns
Type | Description |
|---|---|
| int |
Examples
using UnityEngine;public class ScriptExample : MonoBehaviour{ void Start() { // prints 1 Debug.Log(Mathf.Min(1, 2)); }}
Min(int[])
Returns the smallest of two or more values.
public static int Min(params int[] values)
Parameters
Returns
Type | Description |
|---|---|
| int |
Examples
using UnityEngine;public class ScriptExample : MonoBehaviour{ void Start() { // prints 1 Debug.Log(Mathf.Min(1, 2)); }}