Created
December 1, 2020 10:15
-
-
Save n0mimono/37695ce2ab990d6ccfbe372c94d6fb6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct UnityVersion | |
{ | |
public int stream; | |
public int number; | |
public int minor; | |
public string phase; | |
public int revision; | |
public UnityVersion(string unityVersion) | |
{ | |
var ms = System.Text.RegularExpressions.Regex.Matches(unityVersion, @"(\d+)|([abf])"); | |
try | |
{ | |
this.stream = int.Parse(ms[0].Value); | |
this.number = int.Parse(ms[1].Value); | |
this.minor = int.Parse(ms[2].Value); | |
this.phase = ms[3].Value; | |
this.revision = int.Parse(ms[4].Value); | |
} | |
catch (System.Exception) | |
{ | |
this.stream = 0; | |
this.number = 0; | |
this.minor = 0; | |
this.phase = string.Empty; | |
this.revision = 0; | |
} | |
} | |
public override string ToString() | |
{ | |
return $"{stream}.{number}.{minor}{phase}{revision}"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment