Пример #1
0
        /// <summary>
        /// 同步场景资源配置
        /// </summary>
        static void SyncSceneAssetConfig(AssetBundleBuildData.SceneBuild.Element element, ResourcesManifestData data
                                         , bool is_write)
        {
            string localPath = EditorCommon.AbsoluteToRelativePath(element.ScenePath);

            localPath = localPath.ToLower();

            // 场景文件与配置文件
            string[] files = new string[] { localPath, SceneConfig.GetSceneConfigPath(localPath).ToLower() };
            foreach (var path in files)
            {
                string key = EditorCommon.ConvertToAssetBundleName(path);
                ResourcesManifestData.AssetBundle ab_data;
                if (data.AssetBundles.TryGetValue(key, out ab_data))
                {
                    if (is_write)
                    {
                        ab_data.IsCompress    = element.IsCompress;
                        ab_data.IsNative      = element.IsNative;
                        ab_data.IsPermanent   = false;
                        ab_data.IsStartupLoad = false;
                    }
                    else
                    {
                        element.IsCompress = ab_data.IsCompress;
                        element.IsNative   = ab_data.IsNative;
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        ///   调整场景数据(匹配最新的场景目录,删除无用数据)
        /// </summary>
        static void MatchSceneRuleData(ref AssetBundleBuildData.SceneBuild old, Action <string> progress_report)
        {
            AssetBundleBuildData.SceneBuild rules = new AssetBundleBuildData.SceneBuild();
            DirectoryInfo assets = new DirectoryInfo(EditorCommon.SCENE_START_PATH);

            if (assets.Exists)
            {
                var files = assets.GetFiles("*.unity", SearchOption.AllDirectories);
                foreach (var f in files)
                {
                    string localName = EditorCommon.AbsoluteToRelativePath(f.FullName);
                    if (progress_report != null)
                    {
                        progress_report(f.FullName);
                    }
                    var scene = old.Scenes.Find((elem) =>
                    {
                        return(elem.ScenePath == f.FullName);
                    });
                    if (scene == null)
                    {
                        scene = new AssetBundleBuildData.SceneBuild.Element()
                        {
                            ScenePath = f.FullName
                        };
                    }
                    rules.Scenes.Add(scene);
                }

                old = rules;
            }
        }
Пример #3
0
        /// <summary>
        ///   设置AssetBundleName
        /// </summary>
        public static void ClearAssetBundleName(string full_name)
        {
            full_name = EditorCommon.AbsoluteToRelativePath(full_name);
            AssetImporter importer = AssetImporter.GetAtPath(full_name);

            if (importer != null && !string.IsNullOrEmpty(importer.assetBundleName))
            {
                importer.assetBundleName = "";
            }
        }
Пример #4
0
        /// <summary>
        ///   设置AssetBundleName
        /// </summary>
        public static void ClearAssetBundleName(string full_name)
        {
            full_name = EditorCommon.AbsoluteToRelativePath(full_name);
            AssetImporter importer = AssetImporter.GetAtPath(full_name);

            if (importer != null)
            {
                importer.assetBundleName = "";
                importer.SaveAndReimport();
            }
        }
Пример #5
0
        /// <summary>
        ///   设置AssetBundleName
        /// </summary>
        public static void SetAssetBundleName(string full_name)
        {
            full_name = EditorCommon.AbsoluteToRelativePath(full_name);
            AssetImporter importer = AssetImporter.GetAtPath(full_name);

            if (importer != null)
            {
                string str = full_name.ToLower();
                importer.assetBundleName = str + Common.EXTENSION;
                importer.SaveAndReimport();
            }
        }
        /// <summary>
        ///   设置AssetBundleName
        /// </summary>
        public static void SetAssetBundleName(string full_name)
        {
            full_name = EditorCommon.AbsoluteToRelativePath(full_name);
            AssetImporter importer = AssetImporter.GetAtPath(full_name);

            if (importer != null)
            {
                string str = EditorCommon.ConvertToAssetBundleName(full_name.ToLower());
                importer.assetBundleName    = str;
                importer.assetBundleVariant = "";
                importer.SaveAndReimport();
            }
        }
Пример #7
0
        /// <summary>
        ///   添加选中的资源数据至包中
        /// </summary>
        public void AddSelectionAsset(ResourcesPackagesData.Package pack)
        {
            if (pack == null)
            {
                return;
            }

            foreach (var id in Selection.instanceIDs)
            {
                string str       = AssetDatabase.GetAssetPath(id);
                string full_name = EditorCommon.RelativeToAbsolutePath(str);
                if (System.IO.File.Exists(full_name))
                {
                    if (!EditorCommon.IsIgnoreFile(str))
                    {
                        if (!pack.AssetList.Contains(str))
                        {
                            str = str.ToLower();
                            pack.AssetList.Add(str);
                        }
                    }
                }
                else if (System.IO.Directory.Exists(str))
                {
                    System.IO.DirectoryInfo dic = new System.IO.DirectoryInfo(str);
                    foreach (var file in dic.GetFiles("*", System.IO.SearchOption.AllDirectories))
                    {
                        string local = EditorCommon.AbsoluteToRelativePath(file.FullName);
                        if (!string.IsNullOrEmpty(local) && !EditorCommon.IsIgnoreFile(local))
                        {
                            if (!pack.AssetList.Contains(local))
                            {
                                local = local.ToLower();
                                pack.AssetList.Add(local);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 更改打包资源起始路径
        /// </summary>
        public void ModifyAssetStartPath(string build_start_path, Action <string> progress_report)
        {
            if (!Directory.Exists(build_start_path))
            {
                return;
            }

            int startIndex = Common.PROJECT_ASSET_ROOT_NAME.Length;

            build_start_path = EditorCommon.AbsoluteToRelativePath(build_start_path);
            string new_native_path = build_start_path.Substring(startIndex);
            string old_native_path = Data.BuildStartLocalPath.Substring(startIndex);

            List <string> new_native_folders = new List <string>(new_native_path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));
            List <string> old_native_folders = new List <string>(old_native_path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));

            AssetBundleBuildData.AssetBuild.Element root = null;
            CompareBuildData(ref root, Data.Assets.Root
                             , new_native_folders, old_native_folders
                             , EditorCommon.ASSET_START_PATH, progress_report);

            Data.Assets.Root         = root;
            Data.BuildStartLocalPath = build_start_path;
        }