Exemple #1
0
        public static BundleLabelAndVariant GetBundleLabelAndVariant(string assetPath)
        {
            string label;

            // 获取收集器
            AssetBundleCollectorSetting.Collector findWrapper = null;
            for (int i = 0; i < Setting.Collectors.Count; i++)
            {
                AssetBundleCollectorSetting.Collector wrapper = Setting.Collectors[i];
                if (assetPath.StartsWith(wrapper.CollectDirectory))
                {
                    findWrapper = wrapper;
                    break;
                }
            }

            // 如果没有找到收集器
            if (findWrapper == null)
            {
                IBundleLabel defaultLabel = new LabelByFilePath();
                label = defaultLabel.GetAssetBundleLabel(assetPath);
            }
            else
            {
                // 根据规则设置获取标签名称
                IBundleLabel bundleLabel = GetCollectorInstance(findWrapper.LabelClassName);
                label = bundleLabel.GetAssetBundleLabel(assetPath);
            }

            // 注意:如果资源所在文件夹的名称包含后缀符号,则为变体资源
            string folderName = Path.GetDirectoryName(assetPath);             // "Assets/Texture.HD/background.jpg" --> "Assets/Texture.HD"

            if (Path.HasExtension(folderName))
            {
                string extension             = Path.GetExtension(folderName);
                BundleLabelAndVariant result = new BundleLabelAndVariant();
                result.BundleLabel   = EditorTools.GetRegularPath(label.Replace(extension, string.Empty));
                result.BundleVariant = extension.RemoveFirstChar();
                return(result);
            }
            else
            {
                BundleLabelAndVariant result = new BundleLabelAndVariant();
                result.BundleLabel   = EditorTools.GetRegularPath(label);
                result.BundleVariant = PatchDefine.AssetBundleDefaultVariant;
                return(result);
            }
        }
Exemple #2
0
        /// <summary>
        /// 拷贝文件夹
        /// 注意:包括所有子目录的文件
        /// </summary>
        public static void CopyDirectory(string sourcePath, string destPath)
        {
            sourcePath = EditorTools.GetRegularPath(sourcePath);

            // If the destination directory doesn't exist, create it.
            if (Directory.Exists(destPath) == false)
            {
                Directory.CreateDirectory(destPath);
            }

            string[] fileList = Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories);
            foreach (string file in fileList)
            {
                string temp     = EditorTools.GetRegularPath(file);
                string savePath = temp.Replace(sourcePath, destPath);
                CopyFile(file, savePath, true);
            }
        }
Exemple #3
0
        /// <summary>
        /// 设置资源的标签和变种
        /// </summary>
        private void SetAssetBundleLabelAndVariant(AssetInfo assetInfo)
        {
            // 如果资源所在文件夹的名称包含后缀符号,则为变体资源
            string folderName = Path.GetDirectoryName(assetInfo.AssetPath);             // "Assets/Texture.HD/background.jpg" --> "Assets/Texture.HD"

            if (Path.HasExtension(folderName))
            {
                string extension = Path.GetExtension(folderName);
                string label     = AssetBundleCollectorSettingData.GetAssetBundleLabel(assetInfo.AssetPath);
                assetInfo.AssetBundleLabel   = EditorTools.GetRegularPath(label.Replace(extension, string.Empty));
                assetInfo.AssetBundleVariant = extension.RemoveFirstChar();
            }
            else
            {
                string label = AssetBundleCollectorSettingData.GetAssetBundleLabel(assetInfo.AssetPath);
                assetInfo.AssetBundleLabel   = EditorTools.GetRegularPath(label);
                assetInfo.AssetBundleVariant = PatchDefine.AssetBundleDefaultVariant;
            }
        }
 public BundleLabelAndVariant(string label, string variant)
 {
     BundleLabel   = EditorTools.GetRegularPath(label);
     BundleVariant = variant;
 }