Ejemplo n.º 1
0
    void OnLostFocus()
    {
        // update config file
        UserHookConfig.saveConfigFile(appId, appKey);

        AssetDatabase.Refresh();
    }
    protected static bool updateManifest()
    {
        try {
            UserHookConfig config = UserHookConfig.Instance;

            // find and replace variables in manifest files
            string androidDir = Path.Combine(Directory.GetCurrentDirectory(), "Assets/Plugins/Android");
            if (Directory.Exists(androidDir))
            {
                string[] subdirs = Directory.GetDirectories(androidDir);

                for (int i = 0; i < subdirs.Length; i++)
                {
                    // manifest files that start with "_" have variables that need to be merged
                    string manifestPath = Path.Combine(subdirs [i], "_AndroidManifest.xml");
                    if (File.Exists(manifestPath))
                    {
                        string contents = File.ReadAllText(manifestPath);
                        if (contents.IndexOf("${applicationId}") > -1)
                        {
                            contents = contents.Replace("${applicationId}", PlayerSettings.bundleIdentifier);
                        }

                        if (contents.IndexOf("${userhookAppId}") > -1)
                        {
                            contents = contents.Replace("${userhookAppId}", config.appId);
                        }

                        if (contents.IndexOf("${userhookAppKey}") > -1)
                        {
                            contents = contents.Replace("${userhookAppKey}", config.appKey);
                        }


                        // write final manifest file with merged variables
                        File.WriteAllText(Path.Combine(subdirs [i], "AndroidManifest.xml"), contents);
                    }
                }

                AssetDatabase.Refresh();

                return(true);
            }
            else
            {
                EditorUtility.DisplayDialog("User Hook Error", "Missing Android plugins directory at Assets/Plugins/Android", "Close");
                return(false);
            }
        } catch (Exception e) {
            EditorUtility.DisplayDialog("User Hook Error", "Error preparing for build:" + e.Message, "Close");
            return(false);
        }
    }
Ejemplo n.º 3
0
    public static void Init()
    {
        UserHookKeyWindow window = (UserHookKeyWindow)EditorWindow.GetWindow(typeof(UserHookKeyWindow));


        UserHookConfig config = UserHookConfig.Instance;

        window.appId  = config.appId;
        window.appKey = config.appKey;

        window.Show();
    }
Ejemplo n.º 4
0
    protected void Init()
    {
        UserHookConfig config = UserHookConfig.Instance;

                #if UNITY_EDITOR
        nativeInstance = new UserHookNativeDummy();
                #elif UNITY_IOS
        nativeInstance = new UserHookiOS();
                #elif UNITY_ANDROID
        nativeInstance = new UserHookAndroid();
                #else
        nativeInstance = new UserHookNativeDummy();
                #endif

        nativeInstance.SetApplicationIdAndKey(config.appId, config.appKey);
    }