Esempio n. 1
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);
            }
        }
Esempio n. 2
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();
        }