Skip to main content

IsVersionGreaterOrEqual

public static bool IsVersionGreaterOrEqual(int[] version, int[] checkedVersion)
ParameterTypeDefaultDescription
versionint[]The version to check if it is more recent or not, passed in as a table of up to 3 ints [major, minor, patch]
checkedVersionint[]The reference version, passed in as a table of up to 3 ints [major, minor, patch]

Returns: true if greater or equal, false if not

Convert a version (formatted as "1.2.3", or in other words "major.minor.patch") as string into a table of 3 ints [major, minor, patch].


public static bool IsVersionGreaterOrEqual(
int major,
int minor,
int patch,
int checkedMajor,
int checkedMinor,
int checkedPatch
)
ParameterTypeDefaultDescription
majorintThe reference Major # to check if greater
minorintThe reference Minor # to check if greater
patchintThe reference Patch # to check if greater
checkedMajorintThe reference Major # to check against
checkedMinorintThe reference Minor # to check against
checkedPatchintThe reference Patch # to check against

Returns: true if greater or equal, false if not

Convert a version (formatted as "1.2.3", or in other words "major.minor.patch") as string into a table of 3 ints [major, minor, patch].


Example Usage

using UnityEngine;
using MikeDaBird.EZRecolor;

class ExampleVersionChecking : MonoBehavior{
string version1 = "1.0.5";
string version2 = "1.0.6";
string version3 = "1.1.6";
string version4 = "2.0.5";

void Start(){
Debug.Log(EZRecolor.IsVersionGreaterOrEqual(EZRecolor.ParseVersion(version2), EZRecolor.ParseVersion(version1)));
// 1.0.6 >= 1.0.5 = true

Debug.Log(EZRecolor.IsVersionGreaterOrEqual(EZRecolor.ParseVersion(version1), EZRecolor.ParseVersion(version2)));
// 1.0.5 >= 1.0.6 = false

Debug.Log(EZRecolor.IsVersionGreaterOrEqual(EZRecolor.ParseVersion(version1), EZRecolor.ParseVersion(version1)));
// 1.0.5 >= 1.0.5 = true

Debug.Log(EZRecolor.IsVersionGreaterOrEqual(EZRecolor.ParseVersion(version3), EZRecolor.ParseVersion(version2)));
// 1.1.6 >= 1.0.6 = true

Debug.Log(EZRecolor.IsVersionGreaterOrEqual(EZRecolor.ParseVersion(version4), EZRecolor.ParseVersion(version1)));
// 2.0.5 >= 1.0.5 = true
}
}