@@ -78,7 +78,8 @@ public void InitializeTracker() {
78
78
+ AddRequiredMPParameter ( Fields . TRACKING_ID , trackingCode )
79
79
+ AddRequiredMPParameter ( Fields . APP_ID , bundleIdentifier )
80
80
+ AddRequiredMPParameter ( Fields . CLIENT_ID , clientId )
81
- + AddRequiredMPParameter ( Fields . APP_VERSION , appVersion ) ;
81
+ + AddRequiredMPParameter ( Fields . APP_VERSION , appVersion )
82
+ + AddRequiredMPParameter ( Fields . USER_AGENT_OVERRIDE , GetUserAgent ( ) ) ;
82
83
if ( anonymizeIP ) {
83
84
url += AddOptionalMPParameter ( Fields . ANONYMIZE_IP , 1 ) ;
84
85
}
@@ -419,5 +420,70 @@ public void SetOptOut(bool optOut) {
419
420
this . optOut = optOut ;
420
421
}
421
422
423
+ string GetWindowsNTVersion ( string UnityOSVersionName )
424
+ {
425
+ //https://en.wikipedia.org/wiki/Windows_NT
426
+ if ( UnityOSVersionName . Contains ( "(5.1" ) )
427
+ return "Windows NT 5.1" ;
428
+ else if ( UnityOSVersionName . Contains ( "(5.2" ) )
429
+ return "Windows NT 5.2" ;
430
+ else if ( UnityOSVersionName . Contains ( "(6.0" ) )
431
+ return "Windows NT 6.0" ;
432
+ else if ( UnityOSVersionName . Contains ( "(6.1" ) )
433
+ return "Windows NT 6.1" ;
434
+ else if ( UnityOSVersionName . Contains ( "(6.2" ) )
435
+ return "Windows NT 6.2" ;
436
+ #if UNITY_4_6
437
+ else if ( UnityOSVersionName . Contains ( "( 6.3 ") )
438
+ {
439
+ // But on older versions of Unity on Windows 10, it returns "Windows 8.1 (6.3.10586) 64bit" for Windows 10.0.10586 64 bit
440
+ System . Text . RegularExpressions . Match regexResult = System . Text . RegularExpressions . Regex . Match ( UnityOSVersionName , @"Windows.*?\((\d{0,5}\.\d{0,5}\.(\d{0,5}))\)" ) ;
441
+ if ( regexResult . Success )
442
+ {
443
+ string buildNumberString = regexResult . Groups [ 2 ] . Value ;
444
+ // Fix a bug in older versions of Unity where Windows 10 isn't recognised properly
445
+ int buildNumber = 0 ;
446
+ Int32 . TryParse ( buildNumberString , out buildNumber ) ;
447
+ if ( buildNumber > 10000 )
448
+ {
449
+ return "Windows NT 10.0" ;
450
+ }
451
+ }
452
+ return "Windows NT 6.3" ;
453
+ }
454
+ #else
455
+ else if ( UnityOSVersionName . Contains ( "( 6.3 ") )
456
+ return "Windows NT 6.3" ;
457
+ else if ( UnityOSVersionName . Contains ( "( 10.0 ") )
458
+ return "Windows NT 10.0" ;
459
+ #endif
460
+ else
461
+ return "Unknown" ;
462
+ }
463
+
464
+ string GetUserAgent ( )
465
+ {
466
+ string str_userAgent ;
467
+ str_userAgent = "Unknown" ;
468
+ #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
469
+ str_userAgent = ( Application . platform == RuntimePlatform . OSXPlayer ? "Unity/" : "UnityEditor/" )
470
+ + Application . unityVersion
471
+ + " (Macintosh; "
472
+ + ( SystemInfo . processorType . Contains ( "Intel" ) ? "Intel " : "PPC " )
473
+ + SystemInfo . operatingSystem . Replace ( "." , "_" ) + ")"
474
+ + " Unity/" + Application . unityVersion
475
+ + " Unity/" + Application . unityVersion ;
476
+ #endif
477
+ #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
478
+ str_userAgent =
479
+ ( Application . platform == RuntimePlatform . WindowsPlayer ? "Unity/" : "UnityEditor/" ) + Application . unityVersion
480
+ + " (" + GetWindowsNTVersion ( SystemInfo . operatingSystem ) + ( SystemInfo . operatingSystem . Contains ( "64bit" ) ? "; WOW64)" : ")" )
481
+ + " Unity/" + Application . unityVersion
482
+ + " (KHTML, like Gecko) Unity/" + Application . unityVersion
483
+ + " Unity/" + Application . unityVersion ;
484
+ #endif
485
+ return str_userAgent ;
486
+ }
487
+
422
488
#endif
423
489
}
0 commit comments