Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 计算主资源或共享资源的完整包名
        /// </summary>
        public void CalculateFullBundleName()
        {
            if (CollectorType == ECollectorType.None)
            {
                if (IsRawAsset)
                {
                    throw new Exception("Should never get here !");
                }

                if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
                {
                    if (IsShaderAsset)
                    {
                        string shareBundleName = $"{AssetBundleCollectorSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
                        _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
                        return;
                    }
                }

                if (_referenceBundleNames.Count > 1)
                {
                    var bundleNameList = _referenceBundleNames.ToList();
                    bundleNameList.Sort();
                    string combineName     = string.Join("|", bundleNameList);
                    var    combineNameHash = HashUtility.StringSHA1(combineName);
                    var    shareBundleName = $"share_{combineNameHash}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
                    _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
                }
            }
            else
            {
                if (IsRawAsset)
                {
                    string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.RawFileVariant}";
                    _mainBundleName = EditorTools.GetRegularPath(mainBundleName).ToLower();
                }
                else
                {
                    string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
                    _mainBundleName = EditorTools.GetRegularPath(mainBundleName).ToLower();;
                }
            }
        }
        private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
        {
            // 如果自动收集所有的着色器
            if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
            {
                System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
                if (assetType == typeof(UnityEngine.Shader))
                {
                    string bundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
                    return(EditorTools.GetRegularPath(bundleName).ToLower());
                }
            }

            // 根据规则设置获取资源包名称
            {
                IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
                string    bundleName       = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
                return(EditorTools.GetRegularPath(bundleName).ToLower());
            }
        }