// [MenuItem("test/Mock Download Resources")] public static void DownloadRes() { // var url = "https://res.wx.qq.com/wechatgame/product/webpack/userupload/20200609/193724/res.zip"; var url = WXConfig.moduleCDNPrefix + PluginHub.frameworkVersion + "/Bridge.zip"; // Debug.Log(url); var dist = new DirectoryInfo(Path.Combine(Application.dataPath, "__wx__tmp__res~")); // Debug.Log(dist); if (!dist.Exists) { dist.Create(); } ProjectCreator.downloadAndUnpackWebURL(dist.FullName, url); }
private static void InitCoreResource(string cacheDir, string packageName, string destPath) { // 源码版本不下载资源 if (PluginHub.distribution == "Debug") { return; } string path = Path.Combine(cacheDir, packageName); var url = WXConfig.moduleCDNPrefix + PluginHub.frameworkVersion + "/" + packageName + ".zip"; ProjectCreator.downloadAndUnpackWebURL(cacheDir, url); wxFileUtil.CopyDirectory(path, destPath); AssetDatabase.Refresh(); wxFileUtil.DeleteDirectory(path); }
private static bool InstallModule(ModulePackageName name, string version = null) { try { // 如果版本传空,则直接使用当前版本 if (version == null) { version = PluginHub.frameworkVersion; } var dir = Path.Combine(Application.dataPath, "__wx__tmp__download~"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string modulePackageName = GetModulePackageName(name); if (modulePackageName == null) { Debug.LogError("微信小游戏工具未支持当前版本的Unity"); return(false); } string path = Path.Combine(dir, GetModulePackageName(name)); string url = "https://dldir1.qq.com/WechatWebDev/plugins/BeefBallEngine-unitytool/" + version + "/" + GetModulePackageName(name); bool success = ProjectCreator.downloadFromWebURl(path, url); if (success) { AssetDatabase.ImportPackage(path, false); AssetDatabase.Refresh(); File.Delete(path); } Directory.Delete(dir); } catch (Exception e) { Debug.LogError(e); return(false); } return(true); }