// Invoke a static method with a positional and default value for a named arg.
 static bool TestInvokeStaticMethodWithArgAndNamedArgDefault()
 {
     return(CheckValue("Hello There Bob",
                       (string)VersionHandler.InvokeStaticMethod(
                           typeof(Greeter), "GenericHelloWithCustomerNameAndPronoun",
                           new object[] { "Bob" }, null)));
 }
 // Invoke a static method with a default value of a named arg.
 static bool TestInvokeStaticMethodWithNamedArgDefault()
 {
     return(CheckValue("Hello There",
                       (string)VersionHandler.InvokeStaticMethod(typeof(Greeter),
                                                                 "GenericHelloWithPronoun",
                                                                 null, null)));
 }
 // Invoke an overloaded static method with an int arg.
 static bool TestInvokeStaticMethodWithIntArg()
 {
     return(CheckValue("Hello customer #1337",
                       (string)VersionHandler.InvokeStaticMethod(typeof(Greeter),
                                                                 "GenericHelloWithCustomerName",
                                                                 new object[] { 1337 }, null)));
 }
Esempio n. 4
0
        /// <summary>
        /// Register a method to call when the Version Handler has enabled all plugins in the
        /// project.
        /// </summary>
        static Runner()
        {
            // Disable stack traces for more condensed logs.
            try {
                foreach (var logType in
                         new [] { UnityEngine.LogType.Log, UnityEngine.LogType.Warning })
                {
                    // Unity 2017 and above have the Application.SetStackTraceLogType to configure
                    // stack traces per log level.
                    VersionHandler.InvokeStaticMethod(
                        typeof(UnityEngine.Application), "SetStackTraceLogType",
                        new object[] { logType, UnityEngine.StackTraceLogType.None });
                }
            } catch (Exception) {
                // Fallback to the legacy method.
                UnityEngine.Application.stackTraceLogType = UnityEngine.StackTraceLogType.None;
            }

            UnityEngine.Debug.Log("Set up callback on Version Handler completion.");
            Google.VersionHandler.UpdateCompleteMethods = new [] {
                "Google.IntegrationTester:Google.IntegrationTester.Runner:VersionHandlerReady"
            };
            UnityEngine.Debug.Log("Enable plugin using the Version Handler.");
            Google.VersionHandler.UpdateNow();
        }
 // Invoke a static method with a named arg.
 static bool TestInvokeStaticMethodWithNamedArg()
 {
     return(CheckValue("Hello Miss",
                       (string)VersionHandler.InvokeStaticMethod(
                           typeof(Greeter), "GenericHelloWithPronoun",
                           null, new Dictionary <string, object> {
         { "pronoun", "Miss" }
     })));
 }
 // Invoke a static method with a positional and named arg.
 static bool TestInvokeStaticMethodWithArgAndNamedArg()
 {
     return(CheckValue("Hello Mrs Smith",
                       (string)VersionHandler.InvokeStaticMethod(
                           typeof(Greeter), "GenericHelloWithCustomerNameAndPronoun",
                           new object[] { "Smith" },
                           new Dictionary <string, object> {
         { "pronoun", "Mrs" }
     })));
 }
    // Invoke a static method with a positional and named interface arg.
    static bool TestInvokeStaticMethodWithArgAndNamedInterfaceArg()
    {
        IEnumerable <string> suffixes = new string[] { "BSc", "Hons", "PhD", "Kt", "MPerf" };

        return(CheckValue("Hello Angie BSc Hons PhD Kt MPerf",
                          (string)VersionHandler.InvokeStaticMethod(
                              typeof(Greeter), "GenericHelloWithCustomerNameAndSuffixes",
                              new object[] { "Angie" },
                              new Dictionary <string, object> {
            { "suffixes", suffixes }
        })));
    }
        /// <summary>
        /// CocoaPodsを更新する
        /// Google/SignInをCocoaPodsに追加する
        /// </summary>
        private static void UpdateCocoaPods()
        {
            Type iosResolver = VersionHandler.FindClass(
                "Google.IOSResolver", "Google.IOSResolver");

            if (iosResolver == null)
            {
                return;
            }

            VersionHandler.InvokeStaticMethod(
                iosResolver, "AddPod",
                new object[] { "Google/SignIn" },
                namedArgs: null//new Dictionary<string, object> (){}
                );
        }
 // Invoke a static method with no arguments.
 static bool TestInvokeStaticMethodWithNoArgs()
 {
     return(CheckValue("Hello",
                       (string)VersionHandler.InvokeStaticMethod(typeof(Greeter), "GenericHello",
                                                                 null, null)));
 }
Esempio n. 10
0
        /// <summary>
        /// Registers the dependencies.
        /// </summary>
        public static void RegisterDependencies()
        {
            // Setup the resolver using reflection as the module may not be
            // available at compile time.
            Type playServicesSupport = VersionHandler.FindClass(
                "Google.JarResolver", "Google.JarResolver.PlayServicesSupport");

            if (playServicesSupport == null)
            {
                return;
            }

            if (svcSupport == null)
            {
                svcSupport = (PlayServicesSupport)VersionHandler.InvokeStaticMethod(
                    playServicesSupport, "CreateInstance",
                    new object[]
                {
                    "GooglePlayGames",
                    EditorPrefs.GetString("AndroidSdkRoot"),
                    "ProjectSettings"
                });
            }

            VersionHandler.InvokeInstanceMethod(
                svcSupport, "DependOn",
                new object[]
            {
                "com.google.android.gms", "play-services-games",
                PluginVersion.PlayServicesVersionConstraint
            },
                new Dictionary <string, object>
            {
                { "packageIds", new[] { "extra-google-m2repository" } }
            });

            VersionHandler.InvokeInstanceMethod(
                svcSupport, "DependOn",
                new object[]
            {
                "com.google.android.gms", "play-services-nearby",
                PluginVersion.PlayServicesVersionConstraint
            },
                new Dictionary <string, object>
            {
                { "packageIds", new[] { "extra-google-m2repository" } }
            });

            // Auth is needed for getting the token and email.
            VersionHandler.InvokeInstanceMethod(
                svcSupport, "DependOn",
                new object[]
            {
                "com.google.android.gms", "play-services-auth",
                PluginVersion.PlayServicesVersionConstraint
            },
                new Dictionary <string, object>
            {
                { "packageIds", new[] { "extra-google-m2repository" } }
            });

            // if google+ is needed, add it
            if (GameInfo.RequireGooglePlus())
            {
                VersionHandler.InvokeInstanceMethod(
                    svcSupport, "DependOn",
                    new object[]
                {
                    "com.google.android.gms", "play-services-plus",
                    PluginVersion.PlayServicesVersionConstraint
                },
                    new Dictionary <string, object>
                {
                    { "packageIds", new[] { "extra-google-m2repository" } }
                });
            }

            VersionHandler.InvokeInstanceMethod(
                svcSupport, "DependOn",
                new object[] { "com.android.support", "support-v4", "23.1+" },
                new Dictionary <string, object>
            {
                { "packageIds", new[] { "extra-android-m2repository" } }
            });
        }