11using System . Collections ;
2+ using System . Text . RegularExpressions ;
23using UnityEngine . Networking ;
34using UnityEngine ;
45
@@ -20,20 +21,18 @@ IEnumerator getUpdate(){
2021
2122 string currentVersion = Application . version . TrimEnd ( 'A' ) ;
2223 string webVersion = findRelease ( net . downloadHandler . text ) ;
23- string webVtrimmed = webVersion . TrimEnd ( 'A' ) ;
24-
25- if ( ! webVtrimmed . Equals ( currentVersion ) && ! currentVersion . Equals ( "" ) ) {
26- setNotifier ( webVersion ) ;
24+ if ( ! webVersion . Equals ( currentVersion ) && ! currentVersion . Equals ( "" ) ) {
25+ setNotifier ( webVersion + 'A' ) ;
2726 }
2827 }
2928
30- private string findRelease ( string src ) {
31- if ( src . Contains ( "v" ) && src . Contains ( " \" " ) ) {
32- int Start = src . IndexOf ( "v" , 0 ) + 1 ;
33- int End = src . IndexOf ( " \" " , Start ) ;
34- return src . Substring ( Start , End - Start ) ;
35- }
36- return "" ;
29+ private string findRelease ( string input )
30+ {
31+ Regex regex1 = new Regex ( " \" tag_name \" : \" (?:[^ \" ]| \" \" )* \" ," , RegexOptions . IgnoreCase ) ;
32+ Regex regex2 = new Regex ( "([0-9]+( \\ .[0-9]+)+)" , RegexOptions . IgnoreCase ) ;
33+ Match matchPre = regex1 . Match ( input ) ;
34+ Match matchFin = regex2 . Match ( matchPre . ToString ( ) ) ;
35+ return matchFin . Captures [ 0 ] . ToString ( ) ;
3736 }
3837
3938 private void setNotifier ( string webVersion ) {
0 commit comments