コード例 #1
0
        /// <summary>
        /// Bundle的信息
        /// </summary>
        /// <param name="node"></param>
        /// <param name="allTree"></param>
        public AssetBundleInfo(AssetDependenctGraph.Node node, Dictionary <string, AssetDependenctGraph.Node> allTree, SortedList <string, AssetBundleInfo> __sortedBundleTree)
        {
            this.selfNode = node;

            Tree = allTree;

            sortedBundleTree = __sortedBundleTree;

            var info = new FileInfo(node.NodePath);

            //检测是否必须单独进行打包
            if (AssetPathRule.IsMustBuild(node.NodePath))
            {
                alone_set = true;
            }

            size = info.Length;

            lastWriteTime = info.LastWriteTime;

            //查询构建被引用了多少次
            BuildBeDependenctCount(this.selfNode);

            //this.guid = AssetDatabase.AssetPathToGUID(BuildUtils.GetAssetRelativePath(this.selfNode.NodePath));

            //guid = AssetDatabase.AssetPathToGUID(this.selftree.assetPath);
            //var extension = Path.GetExtension(this.selfNode.NodePath);

            //获取资源打包的类型数据
            type = AssetFileType.GetAssetBundleBuildType(this.selfNode.NodePath, Path.GetExtension(this.selfNode.NodePath));
        }
コード例 #2
0
        /// <summary>
        /// 是否为目录资源打包
        /// </summary>
        /// <returns></returns>
        public static bool IsDirectoryBuild(AssetBundleBuildType type)
        {
            for (int i = 0; i < DirectoryTypes.Length; i++)
            {
                if (DirectoryTypes[i] == type)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        public static int IndexOf(AssetBundleBuildType[] bundles, AssetBundleBuildType type)
        {
            for (int i = 0; i < bundles.Length; i++)
            {
                if (bundles[i] == type)
                {
                    return(i);
                }
            }

            return(-1);
        }
        /// <summary>
        /// 设置目标目录的打包类型
        /// </summary>
        /// <param name="buildType"></param>
        private static void SetTargetDirAtildType(AssetBundleBuildType buildType)
        {
            var projectInfo       = ProjectInfoDati.GetActualInstance();
            var assetbundleEditor = AssetBundleEditorDati.GetActualInstance();

            locAppId = projectInfo.DevelopProjectName;

            if (string.IsNullOrEmpty(locAppId))
            {
                UnityEditorUtility.DisplayError("未设置项目名称");
                return;
            }

            //appHelper = locU3DApp.Helper;

            if (assetbundleEditor == null)
            {
                Debug.LogError($"项目的 AssetBundleSetting 实例未创建 !");
                return;
            }

            var dirs = UnityEditorUtility.GetSelectDirs();

            foreach (var dir in dirs)
            {
                if (!dir.StartsWith(projectInfo.ProjectAssetDatabaseDir))
                {
                    Debug.LogError($"目标目录不是一个有效的AssetBundle打包目录!");
                    return;
                }
                assetbundleEditor.SetBuildAtTargetBuildType(dir, buildType);
                if (buildType == AssetBundleBuildType.BuildAtDirTree) // 清理所有子目录的打包配置
                {
                    var sonDirs = IOUtility.GetAllDir(dir, null, true, false);
                    foreach (var sonDir in sonDirs)
                    {
                        assetbundleEditor.CleanBuildSettingAtDir(sonDir);
                    }
                    Debug.Log($"目录{dir}已设置为目录树打包,其所有子目录的打包配置都已被清空!");
                }
            }
            AssetBundleEditorDati.GetSingleDati().Save();
        }
コード例 #5
0
        /// <summary>
        /// 是否为目录打包
        /// </summary>
        /// <param name="url"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        static AssetBundleBuildType IsDirectoryPackage(string url, AssetBundleBuildType type)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(type);
            }

            if (type == AssetBundleBuildType.FBX)
            {
                if (AssetPathRule.IsDirectoryBuild(url))
                {
                    return(AssetBundleBuildType.Animation_FBX);
                }

                return(type);
            }
            else
            {
                return(type);
            }
        }
コード例 #6
0
        /// <summary>
        /// 获取一个文件类型
        /// </summary>
        /// <param name="extension"></param>
        /// <returns></returns>
        public static AssetBundleBuildType GetAssetBundleBuildType(string path, string extension)
        {
            extension = extension.ToLower();

            var index = AssetFileType.ResourcesExtension.IndexOf(extension);

            if (index != -1)
            {
                if (AssetFileType.ResourceTypeMaping.Length > index)
                {
                    AssetBundleBuildType type = AssetFileType.ResourceTypeMaping[index];
                    type = IsDirectoryPackage(path, type);
                    return(type);
                }
                else
                {
                    return(AssetBundleBuildType.Unkown);
                }
            }

            return(AssetBundleBuildType.Unkown);
        }
        private static void SetSonDirAtildType(AssetBundleBuildType buildType, List <string> dirs)
        {
            locAppId  = UnityEditorUtility.GetLocAppIdAtSelectDir();
            locU3DApp = ProjectInfoDati.GetActualInstance();
            if (string.IsNullOrEmpty(locAppId))
            {
                UnityEditorUtility.DisplayError("所选择的目录不是一个应用下的有效目录!");
                return;
            }

            foreach (var dir in dirs)
            {
                if (!dir.StartsWith(locU3DApp.ProjectAssetDatabaseDir))
                //&& dir.StartsWith(appHelper.StreamingAssetsDir))
                {
                    Debug.LogError($"目标目录不是一个有效的AssetBundle打包目录!");
                    continue;
                }

                var assetbundleEditor = AssetBundleEditorDati.GetActualInstance();
                if (assetbundleEditor == null)
                {
                    Debug.Log($"应用{locAppId}没有AssetBundle打包配置!");
                    return;
                }

                assetbundleEditor.SetBuildAtTargetBuildType(dir, buildType);
                if (buildType == AssetBundleBuildType.BuildAtDirTree) // 清理所有子目录的打包配置
                {
                    var sonDirs = IOUtility.GetAllDir(dir, null, true, false);
                    foreach (var sonDir in sonDirs)
                    {
                        assetbundleEditor.CleanBuildSettingAtDir(sonDir);
                    }
                    Debug.Log($"目录{dir}已设置为目录树打包,其所有子目录的打包配置都已被清空!");
                }
            }
            AssetBundleEditorDati.GetSingleDati().Save();
        }
コード例 #8
0
        public void SetBuildAtTargetBuildType(string dir, AssetBundleBuildType buildType)
        {
            var locAppId   = UnityEditorUtility.GetLocAppIdAtSelectDir();
            var appSetting = ProjectInfoDati.GetActualInstance();

            if (locAppId == null)
            {
                Debug.LogError($"目标目录{dir}不是一个应用下的目录!");
                return;
            }

            if (!AssetBundleBuilder.IsLegalAssetBundleDir(dir))
            {
                Debug.LogError($"目标目录{dir}不是一个有效的AssetBundle目录!");
                return;
            }

            var existSetting = BundleDirSettings.Find(s => s.Dir == dir);

            if (existSetting == null)
            {
                existSetting = new AssetBundleBuildSetting
                {
                    BuildType = buildType,
                    Dir       = dir,
                    //LocAppId = Unity3DEditorUtility.GetLocAppIdAtSelectDir()
                };
                BundleDirSettings.Add(existSetting);
                BundleDirSettings = BundleDirSettings.OrderBy(s => s.Dir).ToList();
                Debug.Log($"目录{dir}当前不存在配置数据,已新建配置!");
            }
            else
            {
                existSetting.BuildType = buildType;
                Debug.Log($"目录{dir}已设置为基于{buildType}打包方式!");
            }
        }