Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        static void ChangeAssetBundleName(string folder_full_name
                                          , AssetBundleBuildData.AssetBuild.Element element
                                          , System.Action <string> change_callback = null)
        {
            if (cancel_running_nametool_)
            {
                return;
            }
            if (element == null)
            {
                return;
            }

            DirectoryInfo dir = new DirectoryInfo(folder_full_name);

            if (!dir.Exists)
            {
                return;
            }

            if ((emAssetBundleNameRule)element.Rule == emAssetBundleNameRule.Ignore)
            {
                return;
            }

            //遍历文件,并设置其AssetBundleName
            FileInfo[] all_files = dir.GetFiles();
            foreach (var f in all_files)
            {
                AssetBundleBuildData.AssetBuild.Element child = element.FindFileElement(f.Name);
                emAssetBundleNameRule my_rule = child != null ? (emAssetBundleNameRule)child.Rule : emAssetBundleNameRule.None;

                if (!EditorCommon.IsIgnoreFile(f.Name) && my_rule != emAssetBundleNameRule.Ignore)
                {
                    if (my_rule == emAssetBundleNameRule.SingleFile)
                    {
                        SetAssetBundleName(f.FullName);
                    }
                    else
                    {
                        ClearAssetBundleName(f.FullName);
                    }
                }

                if (child != null)
                {
                    if (change_callback != null)
                    {
                        change_callback(f.FullName);
                    }
                }
            }

            //遍历文件夹
            DirectoryInfo[] all_dirs = dir.GetDirectories();
            foreach (DirectoryInfo d in all_dirs)
            {
                if (!EditorCommon.IsIgnoreFolder(d.Name))
                {
                    AssetBundleBuildData.AssetBuild.Element child = element.FindFolderElement(d.Name);
                    emAssetBundleNameRule my_rule = child != null ? (emAssetBundleNameRule)child.Rule : emAssetBundleNameRule.None;


                    if (my_rule == emAssetBundleNameRule.Folder)
                    {
                        SetAssetBundleName(d.FullName);
                    }
                    else
                    {
                        ClearAssetBundleName(d.FullName);
                    }


                    if (child != null)
                    {
                        if (change_callback != null)
                        {
                            change_callback(d.FullName);
                        }
                    }

                    ChangeAssetBundleName(d.FullName, child, change_callback);
                }
            }

            //刷新
            AssetDatabase.Refresh();
        }