Example #1
0
        public static void PackLuaResource()
        {
            Dictionary <string, AssetBundleBuild> assetBundleBuilds = new Dictionary <string, AssetBundleBuild>();

            //PackUtils.PackEffect(ref assetBundleBuilds);
            PackUtils.PackAtlas(ref assetBundleBuilds);
            PackUtils.PackUIPrefab(ref assetBundleBuilds);
            PackUtils.PackMode(ref assetBundleBuilds);
            if (assetBundleBuilds.Count <= 0)
            {
                return;
            }
            if (System.IO.Directory.Exists(PackUtils.GetBundlePath("Resources")) == false)
            {
                System.IO.Directory.CreateDirectory(PackUtils.GetBundlePath("Resources"));
            }
            BuildPipeline.BuildAssetBundles(PackUtils.GetBundlePath("/Resources"), new List <AssetBundleBuild>(assetBundleBuilds.Values).ToArray(), BuildAssetBundleOptions.ChunkBasedCompression, PackUtils.GetBuildTarget());
            AssetDatabase.Refresh();
            WLGame.BuildPackage.CreateResourcesLuaConfig(assetBundleBuilds);
            WLGame.BuildPackage.CreateResourcesXmlConfig(assetBundleBuilds);
            WLGame.BuildPackage.CreateUIResourceInfoXmlConfig(assetBundleBuilds);
            string resourceFolder = PackUtils.GetBundlePath("Resources");
            string zipPath        = Application.dataPath + "/Package/" + ResManager.RESOURCE_PATH + ".bytes";

            ZipHelper.ZipDir(resourceFolder, zipPath, 0);
            AssetDatabase.Refresh();
            UnityEngine.Object asset = AssetDatabase.LoadAssetAtPath("Assets/Package/" + ResManager.RESOURCE_PATH + ".bytes", typeof(TextAsset));
            BuildPipeline.BuildAssetBundle(asset, null, ResManager.RESOURCE_EDITOR_PATH, BuildAssetBundleOptions.ChunkBasedCompression, PackUtils.GetBuildTarget());
            AssetDatabase.Refresh();
        }
Example #2
0
        public static void GenAssetsMD5()
        {
            XmlDocument    xmldoc  = new XmlDocument();
            XmlDeclaration xmldecl = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");

            xmldoc.AppendChild(xmldecl);

            //加入一个根元素
            XmlElement xmlRootElem = xmldoc.CreateElement("", "AssetsMD5", "");

            xmldoc.AppendChild(xmlRootElem);

            List <string> fileList = PackUtils.GetFilesFormFolder("/StreamingAssets/", "*.*", true);

            for (int i = 0; i < fileList.Count; i++)
            {
                string filePath = fileList[i].Replace("Assets/StreamingAssets/", "");
                string fileMD5  = ResUtils.GetFileMD5(Application.dataPath + "/StreamingAssets/" + filePath);

                XmlNode    root = xmldoc.SelectSingleNode("AssetsMD5");
                XmlElement xe1  = xmldoc.CreateElement("File");
                xe1.SetAttribute("path", filePath);
                xe1.SetAttribute("md5", fileMD5);
                root.AppendChild(xe1);
            }

            //保存创建好的XML文档
            string xmlFilePath = Application.dataPath + "/Resources/AssetsMD5.xml";

            xmldoc.Save(xmlFilePath);
        }
Example #3
0
        public static void PackAllScenes()
        {
            List <string> fileList = PackUtils.GetFilesFormFolder("/Package/Scenes/", "*.unity", false);

            for (int i = 0; i < fileList.Count; i++)
            {
                string bundleName = PackUtils.GetFileNameFormPath(fileList[i]);
                //PackUtils.PackScene(fileList[i], "Scenes/" + bundleName);
            }
        }
Example #4
0
        public static void PackSelectScene()
        {
            UnityEngine.Object[] selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
            if (selection.Length <= 0)
            {
                return;
            }

            List <string> pathList = PackUtils.GetFilesFormObjects(selection, ".unity");

            for (int i = 0; i < pathList.Count; i++)
            {
                string bundleName = PackUtils.GetFileNameFormPath(pathList[i]);
                PackUtils.PackScene(pathList[i], bundleName);
            }
        }
Example #5
0
        public static void CompressTexture()
        {
            string[] compressFolderArray =
            {
                "/Resources/Textrue/",
                "/Package/UI/",
            };

            for (int i = 0; i < compressFolderArray.Length; i++)
            {
                List <string> fileList = PackUtils.GetFilesFormFolder(compressFolderArray[i], "*.tga|*.psd|*.bmp|*.png|*.jpg", true);
#if UNITY_ANDROID
                PackUtils.CompressTexture(fileList.ToArray(), TextureImporterFormat.DXT5);
#elif UNITY_IPHONE
                PackUtils.CompressTexture(fileList.ToArray(), TextureImporterFormat.PVRTC_RGBA4);
#endif
            }
        }
Example #6
0
        public void InitPackage()
        {
            string packagePath = Application.dataPath + "/Editor/WLPlugIns/package.xml";

            XmlDocument packageDoc = new XmlDocument();

            packageDoc.Load(packagePath);

            //add package data,

#if UNITY_ANDROID
            XmlNodeList androidPacakages = packageDoc.SelectNodes("/PackageList/PackageAndroidList/package");
#elif UNITY_IPHONE
            XmlNodeList androidPacakages = packageDoc.SelectNodes("/PackageList/PackageIOSList/package");
#else
            XmlNodeList androidPacakages = packageDoc.SelectNodes("/PackageList/PackageAndroidList/package");
#endif


            foreach (XmlNode node in androidPacakages)
            {
                string tag        = node.Attributes["tag"].Value;
                string strId      = node.Attributes["id"].Value;
                string desc       = node.Attributes["desc"].Value;
                string appname    = node.Attributes["app"].Value;
                string identifier = node.Attributes["identifier"].Value;
                string pushkey    = node.Attributes["pushkey"].Value;
                int    id         = int.Parse(strId);
                _allPackageTags.Add(tag);
                _allPackageDataIds.Add(id);
                _allPackageDataDesces.Add(desc);
                _allPackageDataAppNames.Add(appname);
                _allPackageDataIdentifiers.Add(identifier);
                _allPackageDataPushKeys.Add(pushkey);
            }

            //init all scenes data
            List <string> fileList = PackUtils.GetFilesFormFolder("/Package/Scenes/", "*.unity", false);
            _allPackageScenes = fileList;
            foreach (string scene in _allPackageScenes)
            {
                _allPackageSceneDesces.Add(scene.Substring(scene.LastIndexOf("/") + 1, scene.IndexOf(".unity") - scene.LastIndexOf("/") - 1));
            }
        }
Example #7
0
        public static void PackSelectAsset()
        {
            UnityEngine.Object[] selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
            if (selection.Length == 0 || selection.Length > 1000)
            {
                Debug.LogError("selection unusual !!!");
                return;
            }

            List <string> pathList = PackUtils.GetFilesFormObjects(selection, "*.*");

            if (pathList.Count == 1)
            {
                string bundleName = PackUtils.GetFileNameFormPath(pathList[0]);
                PackUtils.PackAsset(pathList.ToArray(), bundleName);
            }
            else if (pathList.Count >= 1)
            {
                string bundleName = PackUtils.GetLastFolderFormPath(pathList[0]);
                PackUtils.PackAsset(pathList.ToArray(), bundleName + "_files");
            }
        }
Example #8
0
        public static void PackLuaZip()
        {
            string luaFolder = Application.dataPath + "/Package/Lua/";
            string zipPath   = Application.dataPath + "/Package/" + ResManager.LUA_PATH + ".bytes";

            ZipHelper.ZipDir(luaFolder, zipPath, 0);
            AssetDatabase.Refresh();
            UnityEngine.Object asset = AssetDatabase.LoadAssetAtPath("Assets/Package/" + ResManager.LUA_PATH + ".bytes", typeof(TextAsset));
            BuildPipeline.BuildAssetBundle(asset, null, Application.dataPath + "/StreamingAssets/" + ResManager.LUA_PATH + ".unity3d", BuildAssetBundleOptions.ChunkBasedCompression, PackUtils.GetBuildTarget());
            AssetDatabase.Refresh();
        }
Example #9
0
        public static void PackVesionBytes()
        {
            string zipPath = Application.dataPath + "/Package/" + ResManager.VERSIONS_PATH + ".bytes";

            ZipHelper.ZipDir(Application.dataPath + "/Package/Version/", zipPath, 0);
            AssetDatabase.Refresh();
            UnityEngine.Object[] assets = new UnityEngine.Object[2];
            assets[0] = AssetDatabase.LoadAssetAtPath("Assets/Package/Version/" + ResManager.PACKAGE + ".json", typeof(TextAsset));
            assets[1] = AssetDatabase.LoadAssetAtPath("Assets/Package/" + ResManager.VERSIONS_PATH + ".bytes", typeof(TextAsset));
            BuildPipeline.BuildAssetBundle(assets[0], assets, Application.dataPath + "/StreamingAssets/" + ResManager.VERSIONS_PATH + ".unity3d", BuildAssetBundleOptions.ChunkBasedCompression, PackUtils.GetBuildTarget());
            AssetDatabase.Refresh();
        }
Example #10
0
        public void OnGUI()
        {
            //GUILayout.BeginArea(new Rect(0, 0, 800, 600));
            GUILayout.BeginVertical();
            //选择渠道
            //GUILayout.Label("选择渠道");
            GUILayout.BeginHorizontal();
            _selectValue = EditorGUILayout.IntPopup("选择渠道:", _selectValue, _allPackageTags.ToArray(), _allPackageDataIds.ToArray());

            //Debug.LogError(_selectValue);

            GUILayout.EndHorizontal();

            //icon
            GUILayout.BeginHorizontal();
            string selectChannel    = _allPackageTags[_selectValue];
            string selectAppName    = _allPackageDataAppNames[_selectValue];
            string selectIdentifier = _allPackageDataIdentifiers[_selectValue];
            string selectDesc       = _allPackageDataDesces[_selectValue];
            string selectPushKey    = _allPackageDataPushKeys[_selectValue];

            //部分渠道sdk已经集成dataeye,用YJSDK_NO_DATAEYE进行处理
            if (selectChannel.Equals("YJSDK_NO_DATAEYE"))
            {
                selectChannel = "YJSDK";
            }

#if UNITY_ANDROID
            string iconPath = Application.dataPath + "/../OtherSdk/" + selectChannel.ToLower() + "/Android/icon.png";
#elif UNITY_IPHONE
            string iconPath = Application.dataPath + "/../OtherSdk/" + selectChannel.ToLower() + "/IOS/ios/icon.png";
#else
            string iconPath = Application.dataPath + "/../OtherSdk/" + selectChannel.ToLower() + "/Android/icon.png";
#endif
            if (iconPath != _iconPath)
            {
                _texture  = ShowIcon(iconPath);
                _iconPath = iconPath;
            }
            _texture = EditorGUILayout.ObjectField(selectChannel, _texture, typeof(Texture), false) as Texture;
            //EditorGUI.DrawPreviewTexture(EditorGUILayout.RectField(new Rect(0, 0, 64, 64)), texture);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            //当前svn版本
            GUILayout.Label("svn版本:", GUILayout.Width(400));
            GUILayout.Label(_oldSvnVersion + " 升级:" + _newSvnVersion);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            //当前版本
            GUILayout.Label("base版本:", GUILayout.Width(400));
            PackageVersion.baseVersion = GUILayout.TextField(PackageVersion.baseVersion);
            GUILayout.EndHorizontal();
            //当前lua版本
            GUILayout.BeginHorizontal();
            GUILayout.Label("lua版本:", GUILayout.Width(400));
            PackageVersion.luaVersion = GUILayout.TextField(PackageVersion.luaVersion);
            GUILayout.EndHorizontal();
            //当前config版本
            GUILayout.BeginHorizontal();
            GUILayout.Label("config版本:", GUILayout.Width(400));
            PackageVersion.configVersion = GUILayout.TextField(PackageVersion.configVersion);

            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();
            //程序名称
            GUILayout.Label("程序名称:" + selectAppName);
            //渠道报名
            GUILayout.Label("渠道包名:" + selectIdentifier);
            GUILayout.EndVertical();

            GUILayout.BeginHorizontal();

            _isRelease = GUILayout.Toggle(_isRelease, "正式版本");
            GUILayout.Space(10f);
            _isUpdateRes = GUILayout.Toggle(_isUpdateRes, "更新资源");
            GUILayout.Space(10f);
            _isSign = GUILayout.Toggle(_isSign, "进行签名");
            GUILayout.Space(10f);
            _isExported = GUILayout.Toggle(_isExported, "工程导出");
            GUILayout.Space(10f);
            _isPortrait = GUILayout.Toggle(_isPortrait, "竖屏");
            GUILayout.Space(10f);

            //Debug.LogError("_isRelease " + _isRelease);
            //Debug.LogError("_isSign " + _isSign);
            //Debug.LogError("_isUpdateRes " + _isUpdateRes);
            GUILayout.EndHorizontal();

            ChangeVersion(_isRelease, _isSign);
            //开始打包
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("构建选中渠道包", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("构建选中渠道包", "构建选中渠道包?", "确定", "取消"))
            {
                ChangeVersionCode();

                AndroidSign(_isSign, selectChannel);

                string scriptSymbols = ";" + selectDesc;

                if (_isRelease == false)
                {
                    scriptSymbols += ";DEBUG_TEST";
                }

                if (_isUpdateRes == false)
                {
                    scriptSymbols += ";DISABLE_UPDATE_RES";
                }

                StartBuild(selectChannel, scriptSymbols, selectAppName, selectIdentifier, _isPortrait, true, _isExported);
            }

            if (GUILayout.Button("构建所有渠道包", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("构建所有渠道包", "构建所有渠道包?", "确定", "取消"))
            {
                ChangeVersionCode();

                AndroidSign(_isSign, selectChannel);

                string scriptSymbols = ";" + selectDesc;

                if (_isRelease == false)
                {
                    scriptSymbols += ";DEBUG_TEST";
                }

                if (_isUpdateRes == false)
                {
                    scriptSymbols += ";DISABLE_UPDATE_RES";
                }

                for (int i = 0; i < _allPackageTags.Count; i++)
                {
                    StartBuild(_allPackageTags[i], scriptSymbols, selectAppName, _allPackageDataIdentifiers[i], _isPortrait);
                }
            }

            if (GUILayout.Button("切换选中渠道包", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("切换选中渠道包", "切换选中渠道包?", "确定", "取消"))
            {
                ChangeVersionCode();

                AndroidSign(_isSign, selectChannel);

                string scriptSymbols = ";" + selectDesc;

                if (_isRelease == false)
                {
                    scriptSymbols += ";DEBUG_TEST";
                }

                if (_isUpdateRes == false)
                {
                    scriptSymbols += ";DISABLE_UPDATE_RES";
                }

                StartBuild(selectChannel, scriptSymbols, selectAppName, selectIdentifier, _isPortrait, false);
            }

            GUILayout.EndHorizontal();

            GUILayout.Label("其他操作:");

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("压缩纹理", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("压缩纹理", "压缩纹理?", "确定", "取消"))
            {
                Debug.LogError("压缩纹理");
                //WLGame.PackMenu.CompressTexture();
                //string inputPath = Application.dataPath + "/Editor/WLPlugIns/input.txt";//Application.dataPath + "/Editor/WLPlugIns/package.xml";
                //string outputPath = Application.dataPath + "/Editor/WLPlugIns/output.txt";//Application.dataPath + "/Editor/WLPlugIns/package.xml";
                //string inputStr = File.ReadAllText(inputPath);
                //byte[] inputBytes = System.Text.Encoding.Unicode.GetBytes("UTF-8是一种多字节编码的字符集,表示一个Unicode字符时,它可以是1个至多个字节,在表示上有规律");//File.ReadAllBytes(inputPath);
                //byte[] outputBytes = System.Text.Encoding.Convert(System.Text.Encoding.Unicode,System.Text.Encoding.GetEncoding(950),inputBytes);
                //string outputStr = System.Text.Encoding.GetEncoding(950).GetString(outputBytes);
                //File.WriteAllText(outputPath, outputStr,System.Text.Encoding.GetEncoding(950));
                //string str = TCSCConvert.TCSCConvert.S2T("UTF-8是一种多字节编码的字符集,表示一个Unicode字符时,它可以是1个至多个字节,在表示上有规律");
                //Debug.LogError(str);
            }

            if (GUILayout.Button("打包配置文件", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("打包配置文件", "打包配置文件?", "确定", "取消"))
            {
                Debug.LogError("打包配置文件");
                WLGame.PackMenu.PackConfigFiles();
            }

            if (GUILayout.Button("打包LuaZip", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("打包LuaZip", "打包LuaZip?", "确定", "取消"))
            {
                Debug.LogError("打包LuaZip");
                WLGame.PackMenu.PackLuaZip();
            }

            if (GUILayout.Button("打包Lua资源", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("打包Lua资源", "打包Lua资源?", "确定", "取消"))
            {
                Debug.LogError("打包LuaActive资源");
                WLGame.PackMenu.PackLuaResource();
                ////UnityEngine.Object[] objects = AssetDatabase.LoadAllAssetsAtPath("Package/UI/Active");
                //List<string> fileList = WLGame.PackUtils.GetFilesFormFolder("Package/UI/Active", "*.*", true);

                //if (fileList.Count == 0 || fileList.Count > 1000)
                //{
                //    Debug.LogError("fileList unusual !!!");
                //    return;
                //}

                //if (fileList.Count == 1)
                //{
                //    string bundleName = WLGame.PackUtils.GetFileNameFormPath(fileList[0]);
                //    WLGame.PackUtils.PackAsset(fileList.ToArray(), bundleName);
                //}
                //else if (fileList.Count >= 1)
                //{
                //    string bundleName = WLGame.PackUtils.GetLastFolderFormPath(fileList[0]);
                //    WLGame.PackUtils.PackAsset(fileList.ToArray(), bundleName + "_files");
                //}


                //Debug.LogError("打包Luamine资源");
                ////UnityEngine.Object[] objects = AssetDatabase.LoadAllAssetsAtPath("Package/UI/Active");
                //fileList = WLGame.PackUtils.GetFilesFormFolder("Package/UI/mine", "*.*", true);

                //if (fileList.Count == 0 || fileList.Count > 1000)
                //{
                //    Debug.LogError("fileList unusual !!!");
                //    return;
                //}

                //if (fileList.Count == 1)
                //{
                //    string bundleName = WLGame.PackUtils.GetFileNameFormPath(fileList[0]);
                //    WLGame.PackUtils.PackAsset(fileList.ToArray(), bundleName);
                //}
                //else if (fileList.Count >= 1)
                //{
                //    string bundleName = WLGame.PackUtils.GetLastFolderFormPath(fileList[0]);
                //    WLGame.PackUtils.PackAsset(fileList.ToArray(), bundleName + "_files");
                //}
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            _selectScene = EditorGUILayout.IntPopup("选择场景:", _selectScene, _allPackageSceneDesces.ToArray(), null);
            if (GUILayout.Button("打包场景", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("打包场景", "打包场景?", "确定", "取消"))
            {
                string selectScene = _allPackageScenes[_selectScene];
                string bundleName  = PackUtils.GetFileNameFormPath(selectScene);
                PackUtils.PackScene(selectScene, bundleName);
                Debug.LogError("打包场景 " + selectScene);
            }
            //Debug.LogError(_allPackageScenes[_selectScene]);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("打包全部场景", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("打包全部场景", "打包全部场景?", "确定", "取消"))
            {
                Debug.LogError("打包全部场景");
                //WLGame.PackMenu.PackAllScenes();
                PackUtils.PackScene();
            }

            if (GUILayout.Button("打包版本", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("打包版本", "打包版本?", "确定", "取消"))
            {
                Debug.LogError("打包版本");
                //ChangePackage(selectChannel);
                WLGame.PackMenu.PackVesionBytes();
            }

            if (GUILayout.Button("配置推送", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("配置推送", "配置推送?", "确定", "取消"))
            {
                Debug.LogError("配置推送");
                AddConfForJPush.AddConfForJushByChannel(selectChannel, selectIdentifier, selectPushKey);
            }

            if (GUILayout.Button("修改预设", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("修改预设", "修改预设?", "确定", "取消"))
            {
                Debug.LogError("修改预设");
                string[] prefabStrings = AssetDatabase.FindAssets("t:prefab");
                //Debug.LogError("prefabObjs.Length " + prefabStrings.Length);

                /*
                 * for(int i = 0;i < prefabStrings.Length;i++)
                 * {
                 *  string guid = prefabStrings[i];
                 *  string assetPath = AssetDatabase.GUIDToAssetPath(guid);
                 *  //Debug.Log(assetPath);
                 *  GameObject prefabGO = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
                 *  UISprite[] sprites = prefabGO.GetComponentsInChildren<UISprite>(true);
                 *  if (sprites.Length > 0)
                 *  {
                 *      for (int j = 0; j < sprites.Length; j++)
                 *      {
                 *          UISprite sprite = sprites[j];
                 *          if (sprite == null)
                 *              continue;
                 *          Debug.LogError(assetPath + "----" + sprite.name + " " + sprite.type + " " + sprite.spriteName);
                 *          Debug.LogError(sprite);
                 *      }
                 *  }
                 * }
                 */
            }

            if (GUILayout.Button("生成脚本", GUILayout.Width(100)) && UnityEditor.EditorUtility.DisplayDialog("生成脚本", "生成脚本?", "确定", "取消"))
            {
                //CreateITextReader(Application.dataPath + "/Package/LocalConfig/resourceAsset.xml");
                //CreateITextReader(Application.dataPath + "/Package/LocalConfig/prefabAsset.xml");
                CreateITextReader(Application.dataPath + "/Package/LocalConfig/uIResInfoAsset.bytes");
            }

            GUILayout.EndHorizontal();

            //GUILayout.BeginHorizontal();
            //GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            //GUILayout.EndArea();
        }