Ejemplo n.º 1
0
        public DLCItem(DLCItemConfig config, AssetBundleManifest assetBundleManifest = null)
        {
            Config     = config;
            Name       = config.Name;
            IsActive   = config.IsActive;
            ABManifest = assetBundleManifest;

            BuildRuleData.Clear();
            CopyDirectory.Clear();

            foreach (var item in DLCConfig.Config)
            {
                BuildRuleData.Add(item.Clone() as BuildRuleConfig);
            }
            CopyDirectory.AddRange(DLCConfig.CopyDirectory.ToArray());

            //计算DLC的跟目录
            AssetsRootPath = CalcAssetRootPath(Name);
            //计算出绝对路径(拷贝文件使用)
            AbsRootPath = Path.Combine(Application.dataPath, AssetsRootPath.Replace("Assets/", ""));
            //计算出目标路径
            TargetPath = Path.Combine(Const.Path_StreamingAssets, Name);

            //计算Const路径
            ConstPath = Path.Combine(Const.RPath_Resources, Const.Dir_Const, Name + "Const.cs");
            //计算Manifest路径
            if (IsEditorMode)
            {
                ManifestPath = Path.Combine(AssetsRootPath, Const.Dir_Config);
            }
            else
            {
                ManifestPath = Path.Combine(TargetPath, Const.Dir_Config);
            }
            //计算Config路径
            if (IsEditorMode)
            {
                ConfigPath = Path.Combine(AssetsRootPath, Const.Dir_Config);
            }
            else
            {
                ConfigPath = Path.Combine(TargetPath, Const.Dir_Config);
            }
            //计算语言包路径
            if (IsEditorMode)
            {
                LanguagePath = Path.Combine(AssetsRootPath, Const.Dir_Language);
            }
            else
            {
                LanguagePath = Path.Combine(TargetPath, Const.Dir_Language);
            }
            //计算lua路径
            if (IsEditorMode)
            {
                LuaPath = Path.Combine(AssetsRootPath, Const.Dir_Lua);
            }
            else
            {
                LuaPath = Path.Combine(TargetPath, Const.Dir_Lua);
            }
            //计算Text路径
            if (IsEditorMode)
            {
                TextPath = Path.Combine(AssetsRootPath, Const.Dir_TextAssets);
            }
            else
            {
                TextPath = Path.Combine(TargetPath, Const.Dir_TextAssets);
            }
            //计算CS路径
            if (IsEditorMode)
            {
                CSPath = Path.Combine(AssetsRootPath, Const.Dir_CSharp);
            }
            else
            {
                CSPath = Path.Combine(TargetPath, Const.Dir_CSharp);
            }
            //计算Excel路径
            if (IsEditorMode)
            {
                ExcelPath = Path.Combine(AssetsRootPath, Const.Dir_Excel);
            }
            else
            {
                ExcelPath = Path.Combine(TargetPath, Const.Dir_Excel);
            }

            #region func
            GenerateCopyPath();
            GeneralPath();
            //建立拷贝路径
            void GenerateCopyPath()
            {
                AbsCopyDirectory.Clear();
                if (CopyDirectory != null)
                {
                    for (int i = 0; i < CopyDirectory.Count; ++i)
                    {
                        AbsCopyDirectory.Add(Path.Combine(AbsRootPath, CopyDirectory[i]));
                    }
                }
            }

            //建立打包路径
            void GeneralPath()
            {
                foreach (var item in BuildRuleData)
                {
                    string tempRootPath = AssetsRootPath;
                    if (!item.CustomRootPath.IsInv())
                    {
                        tempRootPath = item.CustomRootPath;
                    }
                    item.FullSearchPath = tempRootPath + "/" + item.Name;
                }
            }

            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 导出的初始化
        /// </summary>
        void Init()
        {
            //计算DLC的跟目录
            RootPath = DLCAssetMgr.GetDLCRootPath(Name);
            //计算出绝对路径(拷贝文件使用)
            AbsRootPath = Path.Combine(BaseConstMgr.Path_Project, RootPath.Replace("Assets/", ""));
            //计算出目标路径
            TargetPath = Path.Combine(BaseConstMgr.Path_StreamingAssets, Name);

            //计算语言包路径
            if (DLCConfig.IsEditorMode)
            {
                LanguagePath = Path.Combine(RootPath, BaseConstMgr.Dir_Language);
            }
            else
            {
                LanguagePath = Path.Combine(TargetPath, BaseConstMgr.Dir_Language);
            }
            //计算lua路径
            if (DLCConfig.IsEditorMode)
            {
                LuaPath = Path.Combine(RootPath, BaseConstMgr.Dir_Lua);
            }
            else
            {
                LuaPath = Path.Combine(TargetPath, BaseConstMgr.Dir_Lua);
            }

            #region func
            EnsureDirectories();
            GenerateCopyPath();
            GeneralPath();
            //确保DLC相关路径存在
            void EnsureDirectories()
            {
                if (DLCConfig.IsEditorMode)
                {
                    BaseFileUtils.EnsureDirectory(AbsRootPath);
                    foreach (var item in Data)
                    {
                        BaseFileUtils.EnsureDirectory(Path.Combine(AbsRootPath, item.SearchPath));
                    }
                    foreach (var item in CopyDirectory)
                    {
                        BaseFileUtils.EnsureDirectory(Path.Combine(AbsRootPath, item));
                    }
                }
            }

            //建立拷贝路径
            void GenerateCopyPath()
            {
                AbsCopyDirectory.Clear();
                if (CopyDirectory != null)
                {
                    for (int i = 0; i < CopyDirectory.Count; ++i)
                    {
                        AbsCopyDirectory.Add(Path.Combine(AbsRootPath, CopyDirectory[i]));
                    }
                }
            }

            //建立打包路径
            void GeneralPath()
            {
                foreach (var item in Data)
                {
                    var vals  = item.SearchPath.Replace('\\', '/');
                    var temps = vals.Split('/');
                    if (temps == null || temps.Length == 0)
                    {
                        CLog.Error("路径错误:{0}", item.SearchPath);
                    }
                    item.FinalDirectory = temps[temps.Length - 1];
                    if (item.FinalDirectory == null)
                    {
                        CLog.Error("错误");
                    }

                    string tempRootPath = RootPath;
                    if (!item.CustomRootPath.IsInvStr())
                    {
                        tempRootPath = item.CustomRootPath;
                    }
                    item.FullSearchPath = tempRootPath + "/" + item.SearchPath;
                }
            }

            #endregion
        }