您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

57 行
2.0 KiB

using System.Collections.Generic;
using UnityEditor;
using System.Linq;
namespace MetaCity.BundleKit.Editor
{
public static class SceneCollector
{
public static List<string> CollectSceneEntries()
{
var scenesGuids = AssetDatabase.FindAssets("t:scene", Constants.UserSceneFolderList.ToArray());
var bundleNames = new List<string>();
foreach (var sceneGuid in scenesGuids)
{
var assetPath = AssetDatabase.GUIDToAssetPath(sceneGuid);
bundleNames.Add(Utilities.CreateSceneBundleName(assetPath));
}
return bundleNames;
}
public static void CollectSceneBundles(List<MetacityBundle> tasks, List<BuildBundleConfig> sceneConfigs)
{
var scenesGuids = AssetDatabase.FindAssets("t:scene", Constants.UserSceneFolderList.ToArray());
var toBuildScenePaths = new List<string>();
foreach (var sceneGuid in scenesGuids)
{
var assetPath = AssetDatabase.GUIDToAssetPath(sceneGuid);
var config=sceneConfigs.FirstOrDefault(x=>x.bundleName==Utilities.CreateSceneBundleName(assetPath)&&x.needBuild);
if(config==null)
{
continue;
}
UnityEngine.Debug.Log($"Collect bundle:{config.bundleName} need to build");
toBuildScenePaths.Add(assetPath);
}
if (toBuildScenePaths.Count == 0)
{
return;
}
foreach (var path in toBuildScenePaths)
{
var builder = Utilities.CreateNewSceneBundleBuild(path);
tasks.Add(new MetacityBundle
{
BundleBuild = builder,
BundleType = MetacityBundleType.Scene,
NeedUpload = true
});
}
}
}
}