Ejemplo n.º 1
0
 static void CheckForUpdate()
 {
     FuseSDKUpdater.CheckForUpdates(true);
 }
Ejemplo n.º 2
0
    private void UpdateAllSettings()
    {
        if (File.Exists(Application.dataPath + "/Plugins/FuseSDK.NET-Stub.dll"))
        {
            AssetDatabase.DeleteAsset("Assets/Plugins/FuseSDK.NET-Stub.dll");
        }

        if (File.Exists(Application.dataPath + "/Plugins/FuseSDK.NET.dll"))
        {
            AssetDatabase.DeleteAsset("Assets/Plugins/FuseSDK.NET.dll");
        }

        if (File.Exists(Application.dataPath + "/FuseSDK/FuseSDK_UnityEditor.cs"))
        {
            AssetDatabase.DeleteAsset("Assets/FuseSDK/FuseSDK_UnityEditor.cs");
        }

#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7)
        string currentVersion, _;
        if (!FuseSDKUpdater.ReadVersionFile(out currentVersion, out _))
        {
            return;
        }

        var versionMeta = AssetImporter.GetAtPath(VERSION_PATH);

        List <PluginImporter> iosPlugins =
            Directory.GetFiles(Application.dataPath + "/Plugins/iOS")
            .Select(file => file.Substring(file.LastIndexOfAny(new char[] { '\\', '/' }) + 1))
            .Where(file => !file.EndsWith(".meta"))
            .Where(file => file.Contains("FuseSDK") || file.Contains("libFuse") || file.Contains("FuseUnity") || file.Contains("NSData-Base64"))
            .Select(file => PluginImporter.GetAtPath("Assets/Plugins/iOS/" + file) as PluginImporter)
            .Where(plugin => plugin != null)
            .ToList();

        foreach (var plugin in iosPlugins)
        {
            plugin.SetCompatibleWithAnyPlatform(false);
            plugin.SetCompatibleWithPlatform(BuildTarget.iOS, true);
            if (plugin.assetPath.EndsWith(".m"))
            {
                string flags = plugin.GetPlatformData(BuildTarget.iOS, "CompileFlags");
                if (!flags.Contains(IOS_PLUGIN_M_FLAGS))
                {
                    plugin.SetPlatformData(BuildTarget.iOS, "CompileFlags", flags + " " + IOS_PLUGIN_M_FLAGS);
                }
            }
            else if (plugin.assetPath.EndsWith(".a"))
            {
                string flags = plugin.GetPlatformData(BuildTarget.iOS, "CompileFlags");
                if (!flags.Contains(IOS_PLUGIN_A_FLAGS))
                {
                    plugin.SetPlatformData(BuildTarget.iOS, "CompileFlags", flags + " " + IOS_PLUGIN_A_FLAGS);
                }
                var    frameworks = plugin.GetPlatformData(BuildTarget.iOS, "FrameworkDependencies").Split(';');
                string combined   = frameworks.Union(IOS_PLUGIN_A_FRAMEWORKS).Where(f => !string.IsNullOrEmpty(f)).Aggregate((accum, f) => accum + ";" + f) + ";";
                plugin.SetPlatformData(BuildTarget.iOS, "FrameworkDependencies", combined);
            }

            plugin.SaveAndReimport();
        }

#if !UNITY_5_0 && !UNITY_5_1
        PlayerSettings.iOS.allowHTTPDownload = true;
#endif

        List <PluginImporter> androidPlugins =
            Directory.GetFiles(Application.dataPath + "/Plugins/Android")
            .Union(Directory.GetDirectories(Application.dataPath + "/Plugins/Android", "res"))
            .Select(file => file.Substring(file.LastIndexOfAny(new char[] { '\\', '/' }) + 1))
            .Where(file => !file.EndsWith(".meta"))
            .Where(file => file.Contains("FuseSDK") || file.Contains("FuseUnity") || file.Contains("android-support-v4.jar") || file.Contains("google-play-services.jar") || file == "res")
            .Select(file => PluginImporter.GetAtPath("Assets/Plugins/Android/" + file) as PluginImporter)
            .Where(plugin => plugin != null)
            .ToList();

        foreach (var plugin in androidPlugins)
        {
            plugin.SetCompatibleWithAnyPlatform(false);
            plugin.SetCompatibleWithPlatform(BuildTarget.Android, true);
            plugin.SaveAndReimport();
        }

        UpdateAndroidManifest();

        versionMeta.userData = currentVersion + "#" + PlayerSettings.bundleIdentifier;
        versionMeta.SaveAndReimport();
#endif
    }
Ejemplo n.º 3
0
    private void UpdateAllSettings()
    {
        foreach (var file in DELETED_FILES)
        {
            try
            {
                if (File.Exists(Application.dataPath + file))
                {
                    AssetDatabase.DeleteAsset("Assets" + file);
                }
            }
            catch
            { }
        }

        PlayerSettings.Android.forceSDCardPermission   = true;
        PlayerSettings.Android.forceInternetPermission = true;

        string currentVersion, _;

        if (!FuseSDKUpdater.ReadVersionFile(out currentVersion, out _))
        {
            return;
        }

        foreach (var dir in Directory.GetDirectories(Application.dataPath + IOS_NATIVE_LIBS))
        {
            try
            {
                if (!dir.Contains(currentVersion))
                {
                    Directory.Delete(dir, true);
                    File.Delete(dir.TrimEnd('/', '\\') + ".meta");
                }
            }
            catch
            { }
        }

        foreach (var dir in Directory.GetDirectories(Application.dataPath + ANDROID_NATIVE_LIBS))
        {
            try
            {
                if (!dir.Contains(currentVersion))
                {
                    Directory.Delete(dir, true);
                    File.Delete(dir.TrimEnd('/', '\\') + ".meta");
                }
            }
            catch
            { }
        }

        List <PluginImporter> iosPlugins =
            Directory.GetFiles(Application.dataPath + IOS_NATIVE_LIBS, "*", SearchOption.AllDirectories)
            .Where(file => !file.EndsWith(".meta"))
            .Select(file => PluginImporter.GetAtPath("Assets" + file.Substring(Application.dataPath.Length)) as PluginImporter)
            .Where(plugin => plugin != null)
            .ToList();

        iosPlugins.AddRange(
            Directory.GetDirectories(Application.dataPath + IOS_NATIVE_LIBS, "*.framework", SearchOption.AllDirectories)
            .Select(path => PluginImporter.GetAtPath("Assets" + path.Substring(Application.dataPath.Length)) as PluginImporter)
            .Where(plugin => plugin != null)
            );

        foreach (var plugin in iosPlugins)
        {
            plugin.SetCompatibleWithAnyPlatform(false);
            plugin.SetCompatibleWithPlatform(BuildTarget.iOS, true);
            if (plugin.assetPath.EndsWith(".m"))
            {
                string flags = plugin.GetPlatformData(BuildTarget.iOS, "CompileFlags");
                if (!flags.Contains(IOS_PLUGIN_M_FLAGS))
                {
                    plugin.SetPlatformData(BuildTarget.iOS, "CompileFlags", flags + " " + IOS_PLUGIN_M_FLAGS);
                }
            }
            else if (plugin.assetPath.EndsWith(".a"))
            {
                string flags = plugin.GetPlatformData(BuildTarget.iOS, "CompileFlags");
                if (!flags.Contains(IOS_PLUGIN_A_FLAGS))
                {
                    plugin.SetPlatformData(BuildTarget.iOS, "CompileFlags", flags + " " + IOS_PLUGIN_A_FLAGS);
                }
                var    frameworks = plugin.GetPlatformData(BuildTarget.iOS, "FrameworkDependencies").Split(';');
                string combined   = frameworks.Union(IOS_PLUGIN_A_FRAMEWORKS).Where(f => !string.IsNullOrEmpty(f)).Aggregate((accum, f) => accum + ";" + f) + ";";
                plugin.SetPlatformData(BuildTarget.iOS, "FrameworkDependencies", combined);
            }

            plugin.SaveAndReimport();
        }

        UpdateAndroidManifest();

        //If there are different bundleIds for Android and iOS this will cause settings to update everytime the target is changed
        var versionMeta = AssetImporter.GetAtPath(VERSION_PATH);

#if UNITY_5_6_OR_NEWER
        versionMeta.userData = currentVersion + "#" + PlayerSettings.applicationIdentifier;
#else
        versionMeta.userData = currentVersion + "#" + PlayerSettings.bundleIdentifier;
#endif
        versionMeta.SaveAndReimport();
    }
Ejemplo n.º 4
0
    private bool DoSettingsNeedUpdate()
    {
        if (File.Exists(Application.dataPath + "/FuseSDK/FuseSDK_UnityEditor.cs") ||
            File.Exists(Application.dataPath + "/Plugins/FuseSDK.NET-Stub.dll") ||
            File.Exists(Application.dataPath + "/Plugins/FuseSDK.NET.dll"))
        {
            return(true);
        }

#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7)
        string currentVersion, metaVersion, bundleId;
        if (!FuseSDKUpdater.ReadVersionFile(out currentVersion, out metaVersion))
        {
            return(true);
        }

        var versionMeta = AssetImporter.GetAtPath(VERSION_PATH);
        var sp          = (versionMeta.userData ?? string.Empty).Split('#');
        metaVersion = (sp.Length < 1) ? string.Empty : sp[0];
        bundleId    = (sp.Length < 2) ? string.Empty : sp[1];

        string _         = null;
        int[]  actualVer = FuseSDKUpdater.ParseVersion(currentVersion, ref _);
        int[]  metaVer   = FuseSDKUpdater.ParseVersion(metaVersion, ref _);

        if (metaVer == null || bundleId != PlayerSettings.bundleIdentifier || FuseSDKUpdater.HowOldIsVersion(metaVer, actualVer) >= 0)
        {
            return(true);
        }

        List <PluginImporter> iosPlugins =
            Directory.GetFiles(Application.dataPath + "/Plugins/iOS")
            .Select(file => file.Substring(file.LastIndexOfAny(new char[] { '\\', '/' }) + 1))
            .Where(file => !file.EndsWith(".meta"))
            .Where(file => file.Contains("FuseSDK") || file.Contains("libFuse") || file.Contains("FuseUnity") || file.Contains("NSData-Base64"))
            .Select(file => PluginImporter.GetAtPath("Assets/Plugins/iOS/" + file) as PluginImporter)
            .Where(plugin => plugin != null)
            .ToList();

        foreach (var plugin in iosPlugins)
        {
            if (plugin.assetPath.EndsWith(".m"))
            {
                string flags = plugin.GetPlatformData(BuildTarget.iOS, "CompileFlags");
                if (!flags.Contains(IOS_PLUGIN_M_FLAGS))
                {
                    return(true);
                }
            }
            else if (plugin.assetPath.EndsWith(".a"))
            {
                string flags      = plugin.GetPlatformData(BuildTarget.iOS, "CompileFlags");
                var    frameworks = plugin.GetPlatformData(BuildTarget.iOS, "FrameworkDependencies").Split(';').Where(f => !string.IsNullOrEmpty(f));
                if (!flags.Contains(IOS_PLUGIN_A_FLAGS) || frameworks.Intersect(IOS_PLUGIN_A_FRAMEWORKS).Count() != IOS_PLUGIN_A_FRAMEWORKS.Length)
                {
                    return(true);
                }
            }
        }

        List <PluginImporter> androidPlugins =
            Directory.GetFiles(Application.dataPath + "/Plugins/Android")
            .Union(Directory.GetDirectories(Application.dataPath + "/Plugins/Android", "res"))
            .Select(file => file.Substring(file.LastIndexOfAny(new char[] { '\\', '/' }) + 1))
            .Where(file => !file.EndsWith(".meta"))
            .Where(file => file.Contains("FuseSDK") || file.Contains("FuseUnity") || file.Contains("android-support-v4.jar") || file.Contains("google-play-services.jar") || file == "res")
            .Select(file => PluginImporter.GetAtPath("Assets/Plugins/Android/" + file) as PluginImporter)
            .Where(plugin => plugin != null)
            .ToList();

        foreach (var plugin in androidPlugins)
        {
            if (!plugin.GetCompatibleWithPlatform(BuildTarget.Android))
            {
                return(true);
            }
        }
#endif

        return(false);
    }
Ejemplo n.º 5
0
    private bool DoSettingsNeedUpdate()
    {
        foreach (var file in DELETED_FILES)
        {
            if (File.Exists(Application.dataPath + file))
            {
                return(true);
            }
        }

        if (Directory.GetDirectories(Application.dataPath + IOS_NATIVE_LIBS).Length > 1)
        {
            return(true);
        }

        if (Directory.GetDirectories(Application.dataPath + ANDROID_NATIVE_LIBS).Length > 1)
        {
            return(true);
        }

        if (!PlayerSettings.Android.forceSDCardPermission || !PlayerSettings.Android.forceInternetPermission)
        {
            return(true);
        }

        string currentVersion, metaVersion, bundleId;

        if (!FuseSDKUpdater.ReadVersionFile(out currentVersion, out metaVersion))
        {
            return(true);
        }

        var versionMeta = AssetImporter.GetAtPath(VERSION_PATH);
        var sp          = (versionMeta.userData ?? string.Empty).Split('#');

        metaVersion = (sp.Length < 1) ? string.Empty : sp[0];
        bundleId    = (sp.Length < 2) ? string.Empty : sp[1];

        string _ = null;

        int[] actualVer = FuseSDKUpdater.ParseVersion(currentVersion, ref _);
        int[] metaVer   = FuseSDKUpdater.ParseVersion(metaVersion, ref _);

        //If there are different bundleIds for Android and iOS this will cause settings to update everytime the target is changed
        string currentBundleId =
#if UNITY_5_6_OR_NEWER
            PlayerSettings.applicationIdentifier;
#else
            PlayerSettings.bundleIdentifier;
#endif
        if (metaVer == null || bundleId != currentBundleId || FuseSDKUpdater.HowOldIsVersion(metaVer, actualVer) >= 0)
        {
            return(true);
        }

        List <PluginImporter> iosPlugins =
            Directory.GetFiles(Application.dataPath + IOS_NATIVE_LIBS, "*", SearchOption.AllDirectories)
            .Where(file => !file.EndsWith(".meta"))
            .Select(file => PluginImporter.GetAtPath("Assets" + file.Substring(Application.dataPath.Length)) as PluginImporter)
            .Where(plugin => plugin != null)
            .ToList();

        iosPlugins.AddRange(
            Directory.GetDirectories(Application.dataPath + IOS_NATIVE_LIBS, "*.framework", SearchOption.AllDirectories)
            .Select(path => PluginImporter.GetAtPath("Assets" + path.Substring(Application.dataPath.Length)) as PluginImporter)
            .Where(plugin => plugin != null)
            );

        foreach (var plugin in iosPlugins)
        {
            if (!plugin.GetCompatibleWithPlatform(BuildTarget.iOS))
            {
                return(true);
            }

            if (plugin.assetPath.EndsWith(".m"))
            {
                string flags = plugin.GetPlatformData(BuildTarget.iOS, "CompileFlags");
                if (!flags.Contains(IOS_PLUGIN_M_FLAGS))
                {
                    return(true);
                }
            }
            else if (plugin.assetPath.EndsWith(".a"))
            {
                string flags      = plugin.GetPlatformData(BuildTarget.iOS, "CompileFlags");
                var    frameworks = plugin.GetPlatformData(BuildTarget.iOS, "FrameworkDependencies").Split(';').Where(f => !string.IsNullOrEmpty(f));
                if (!flags.Contains(IOS_PLUGIN_A_FLAGS) || frameworks.Intersect(IOS_PLUGIN_A_FRAMEWORKS).Count() != IOS_PLUGIN_A_FRAMEWORKS.Length)
                {
                    return(true);
                }
            }
        }

        return(false);
    }