using System.Collections.Generic; using UnityEditor; using System.Linq; namespace MetaCity.BundleKit.Editor { public static class SceneCollector { public static List CollectSceneEntries() { var scenesGuids = AssetDatabase.FindAssets("t:scene", Constants.UserSceneFolderList.ToArray()); var bundleNames = new List(); foreach (var sceneGuid in scenesGuids) { var assetPath = AssetDatabase.GUIDToAssetPath(sceneGuid); bundleNames.Add(Utilities.CreateSceneBundleName(assetPath)); } return bundleNames; } public static void CollectSceneBundles(List tasks, List sceneConfigs) { var scenesGuids = AssetDatabase.FindAssets("t:scene", Constants.UserSceneFolderList.ToArray()); var toBuildScenePaths = new List(); 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 }); } } } }