Beispiel #1
0
        void OnGUI()
        {
            EditorGUILayout.PropertyField(script);
            EditorGUILayout.BeginHorizontal();
            localPath = EditorGUILayout.TextField("ExportTo", localPath);
            if (GUILayout.Button("选择路径", GUILayout.Width(60)))
            {
                var path = EditorUtility.SaveFolderPanel("选择保存路径", localPath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    localPath = path;
                    PlayerPrefs.SetString(Perfer_buildPath, localPath);
                    this.Repaint();
                }
            }
            EditorGUILayout.EndHorizontal();
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                targetPath = EditorGUILayout.TextField("CopyTo", targetPath);
                if (GUILayout.Button("选择路径", GUILayout.Width(60)))
                {
                    var path = EditorUtility.SaveFolderPanel("选择本地路径", targetPath, "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        targetPath = path;
                        PlayerPrefs.SetString(Perfer_localPath, targetPath);
                        this.Repaint();
                    }
                }
                if (GUILayout.Button("Copy", GUILayout.Width(60)))
                {
                    FileUtil.DeleteFileOrDirectory(GetFullPath(targetPath));
                    FileUtil.CopyFileOrDirectory(GetFullPath(localPath), (targetPath));
                }
            }
            buildTarget = (BuildTarget)EditorGUILayout.EnumPopup("BuildTarget", buildTarget);


            #region 全局打包
            buildOption = (BuildAssetBundleOptions)EditorGUILayout.EnumMaskField("Options", buildOption);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("GlobleBulid"))
            {
                ABBUtility.BuildProjectsAssetBundle(GetFullPath(localPath), buildOption, buildTarget);
            }
            #endregion
        }
Beispiel #2
0
        void OnGUI()
        {
            EditorGUILayout.PropertyField(script);
            EditorGUILayout.BeginHorizontal();
            buildpath = EditorGUILayout.TextField("ExportTo", buildpath);
            if (GUILayout.Button("选择路径"))
            {
                var path = EditorUtility.SaveFolderPanel("选择保存路径", buildpath, "");
                if (!string.IsNullOrEmpty(path))
                {
                    buildpath = path;
                    PlayerPrefs.SetString(Perfer_buildPath, buildpath);
                    this.Repaint();
                }
            }
            EditorGUILayout.EndHorizontal();

            buildTarget = (BuildTarget)EditorGUILayout.EnumPopup("BuildTarget", buildTarget);

            assetBundleName = EditorGUILayout.TextField("AbName", assetBundleName);
            GUILayout.FlexibleSpace();
            using (var hor = new EditorGUILayout.VerticalScope())
            {
                if (GUILayout.Button("BuildAllSelected"))
                {
                    ABBUtility.BuildSelectAssets(assetBundleName, buildpath, allObject, buildTarget);
                }
                if (GUILayout.Button("BuildSelectedScenes"))
                {
                    ABBUtility.BuildSelectAssets(assetBundleName, buildpath, selectionScene, buildTarget);
                }
                if (GUILayout.Button("BuildSelectedGameObjects"))
                {
                    ABBUtility.BuildSelectAssets(assetBundleName, buildpath, selectionGameObject, buildTarget);
                }
                else if (GUILayout.Button("BuildSelectedMaterials"))
                {
                    ABBUtility.BuildSelectAssets(assetBundleName, buildpath, selectionMaterial, buildTarget);
                }
                else if (GUILayout.Button("BuildSelectedTextures"))
                {
                    ABBUtility.BuildSelectAssets(assetBundleName, buildpath, selectionTexture, buildTarget);
                }
            }
        }
        void OnLoadButtonClicked()
        {
            if (!System.IO.Directory.Exists(artAssetsFolder))
            {
                EditorUtility.DisplayDialog("文件夹未选择", "请选择文件夹后重试", "ok");
                return;
            }
            List <string> allFiles = new List <string>();

            switch (artType)
            {
            case ArtType.Texture:
                ABBUtility.Recursive(artAssetsFolder, "jpg", deepSet, action: (x) => { allFiles.Add(x); });
                ABBUtility.Recursive(artAssetsFolder, "png", deepSet, action: (x) => { allFiles.Add(x); });
                ABBUtility.Recursive(artAssetsFolder, "tga", deepSet, action: (x) => { allFiles.Add(x); });
                ABBUtility.Recursive(artAssetsFolder, "dds", deepSet, action: (x) => { allFiles.Add(x); });
                break;

            case ArtType.Model:
                ABBUtility.Recursive(artAssetsFolder, "fbx", deepSet, action: (x) => { allFiles.Add(x); });
                break;

            case ArtType.Prefab:
                ABBUtility.Recursive(artAssetsFolder, "prefab", deepSet, action: (x) => { allFiles.Add(x); });
                break;

            case ArtType.Material:
                ABBUtility.Recursive(artAssetsFolder, "mat", deepSet, action: (x) => { allFiles.Add(x); });
                break;

            default:
                break;
            }
            string path;
            string appendname;

            assetFind.Clear();
            foreach (var item in allFiles)
            {
                path       = item.Replace(Application.dataPath, "Assets");
                appendname = item.Replace(artAssetsFolder + "/", "");
                assetFind.Add(new BundleAbleAsset(path, appendname));
            }
        }
Beispiel #4
0
        void LoadFolderAssetBundle(string path)
        {
            List <string> bundleObjs = new List <string>();

            ABBUtility.RecursiveSub(path, action: (x) => { bundleObjs.Add(x); });
            for (int i = 0; i < bundleObjs.Count; i++)
            {
                AssetImporter importer = AssetImporter.GetAtPath(FileUtil.GetProjectRelativePath(bundleObjs[i]));
                if (importer != null)
                {
                    if (!string.IsNullOrEmpty(importer.assetBundleName))
                    {
                        Object obj = AssetDatabase.LoadAssetAtPath <Object>(importer.assetPath);
                        importer.name = obj.name;
                        objectList.Add(importer, obj);
                        importerList.Add(importer);
                    }
                }
            }
        }
        private void DrawBottomTools()
        {
            var             buildObj  = target as ConfigBuildObj;
            GUIStyle        labStyle  = EditorStyles.miniBoldLabel;
            GUILayoutOption labLayout = GUILayout.Width(100);

            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("[目标平台]:", labStyle, labLayout);
                buildObj.buildTarget = (BuildTarget)EditorGUILayout.EnumPopup(buildObj.buildTarget);
            }
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("[打包选项]:", labStyle, labLayout);
                buildObj.buildOption = (BuildAssetBundleOptions)EditorGUILayout.EnumMaskField(buildObj.buildOption);
            }
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("[清空文件]:", labStyle, labLayout);
                buildObj.clearOld = EditorGUILayout.Toggle(buildObj.clearOld);
            }

            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                if (GUILayout.Button("生成AB(全部)", EditorStyles.toolbarDropDown))
                {
                    if (buildObj.clearOld)
                    {
                        FileUtil.DeleteFileOrDirectory(buildObj.LocalPath);
                    }

                    ConfigBuildObj bo = ScriptableObject.CreateInstance <ConfigBuildObj>();
                    StoreLayerNodeToAsset(nodeDic, bo);
                    ABBUtility.BuildGroupBundles(buildObj.LocalPath, GetBundleBuilds(buildObj.needBuilds), buildObj.buildOption, buildObj.buildTarget);
                }
                if (GUILayout.Button("生成AB(选中)", EditorStyles.toolbarDropDown))
                {
                    if (buildObj.clearOld)
                    {
                        FileUtil.DeleteFileOrDirectory(buildObj.LocalPath);
                    }

                    ConfigBuildObj bo = ScriptableObject.CreateInstance <ConfigBuildObj>();
                    StoreLayerNodeToAsset(nodeDic, bo, true);
                    ABBUtility.BuildGroupBundles(buildObj.LocalPath, GetBundleBuilds(buildObj.needBuilds), buildObj.buildOption, buildObj.buildTarget);
                }
            }
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("[拷贝到路径]:", GUILayout.Width(100));
                targetPath_prop.stringValue = EditorGUILayout.TextField(targetPath_prop.stringValue);
                if (GUILayout.Button("选择"))
                {
                    var path = EditorUtility.OpenFolderPanel("选择文件路径", targetPath_prop.stringValue, "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        targetPath_prop.stringValue = path;
                    }
                }
                if (GUILayout.Button("拷贝"))
                {
                    if (buildObj.LocalPath != buildObj.TargetPath && !string.IsNullOrEmpty(buildObj.TargetPath))
                    {
                        FileUtil.DeleteFileOrDirectory(buildObj.TargetPath);
                        FileUtil.CopyFileOrDirectory(buildObj.LocalPath, buildObj.TargetPath);
                    }
                }
            }
        }