Пример #1
0
        private static string GetModuleName(ModulePackageName name)
        {
            string[] packageNames = { "core", "ngui", "framework" };

            int index = 3;

            switch (name)
            {
            case ModulePackageName.CORE:
                index = 0;
                break;

            case ModulePackageName.NGUI:
                index = 1;
                break;
            }
            return(packageNames[index]);
        }
Пример #2
0
        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);
        }