// Replicate the "DoSetup" method of the GPGSAndroidSetupUI class. void SetupAndroidGPGS(string webClientId, string folder, string className, string resourceXmlData, string nearbySvcId, bool requiresGooglePlus) { // Create the folder to store the generated cs file if it doesn't exist. FileIO.EnsureFolderExists(folder); // Invoke GPGSAndroidSetupUI's PerformSetup method via reflection. // In GPGPS versions below 0.9.37, this method has a trailing bool parameter (requiresGooglePlus), // while in version 0.9.37 and newer this parameter has been removed. So we need to use reflection // to detect the method's parameter list and invoke it accordingly. Type gpgsAndroidSetupClass = typeof(GPGSAndroidSetupUI); string methodName = "PerformSetup"; bool isSetupSucceeded = false; // GPGS 0.9.37 and newer: PerformSetup has no trailing bool parameter MethodInfo newPerformSetup = gpgsAndroidSetupClass.GetMethod(methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, new Type[] { typeof(string), typeof(string), typeof(string), typeof(string), typeof(string) }, new ParameterModifier[0]); if (newPerformSetup != null) { isSetupSucceeded = (bool)newPerformSetup.Invoke(null, new object[] { webClientId, folder, className, resourceXmlData, nearbySvcId }); } else { // GPGS 0.9.36 and older: PerformSetup has a trailing bool parameter MethodInfo oldPerformSetup = gpgsAndroidSetupClass.GetMethod(methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, new Type[] { typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(bool) }, new ParameterModifier[0]); if (oldPerformSetup != null) { isSetupSucceeded = (bool)oldPerformSetup.Invoke(null, new object[] { webClientId, folder, className, resourceXmlData, nearbySvcId, requiresGooglePlus }); } } if (isSetupSucceeded) { GPGSAndroidSetupUI.CheckBundleId(); EditorUtility.DisplayDialog( GPGSStrings.Success, GPGSStrings.AndroidSetup.SetupComplete, GPGSStrings.Ok); GPGSProjectSettings.Instance.Set(GPGSUtil.ANDROIDSETUPDONEKEY, true); } else { GPGSUtil.Alert( GPGSStrings.Error, "Invalid or missing XML resource data. Make sure the data is" + " valid and contains the app_id element"); } }
// Replicate the "DoSetup" method of the GPGSAndroidSetupUI class. void SetupAndroidGPGS(string webClientId, string folder, string className, string resourceXmlData, string nearbySvcId, bool requiresGooglePlus) { // Create the folder to store the generated cs file if it doesn't exist. SgLib.Editor.FileIO.EnsureFolderExists(folder); if (GPGSAndroidSetupUI.PerformSetup(webClientId, folder, className, resourceXmlData, nearbySvcId, requiresGooglePlus)) { GPGSAndroidSetupUI.CheckBundleId(); EditorUtility.DisplayDialog( GPGSStrings.Success, GPGSStrings.AndroidSetup.SetupComplete, GPGSStrings.Ok); GPGSProjectSettings.Instance.Set(GPGSUtil.ANDROIDSETUPDONEKEY, true); } else { GPGSUtil.Alert( GPGSStrings.Error, "Invalid or missing XML resource data. Make sure the data is" + " valid and contains the app_id element"); } }