private IExportCollection CreateCollection(VirtualSerializedFile file, Object asset, ExportOptions options) { Stack <IAssetExporter> exporters = m_exporters[asset.ClassID]; foreach (IAssetExporter exporter in exporters) { if (exporter.IsHandle(asset, options)) { return(exporter.CreateCollection(file, asset)); } } throw new Exception($"There is no exporter that can handle '{asset}'"); }
public void Export(string path, GameCollection fileCollection, IEnumerable <SerializedFile> files, ExportOptions options) { EventExportPreparationStarted?.Invoke(); LayoutInfo info = new LayoutInfo(options.Version, options.Platform, options.Flags); AssetLayout exportLayout = new AssetLayout(info); VirtualSerializedFile virtualFile = new VirtualSerializedFile(exportLayout); List <IExportCollection> collections = new List <IExportCollection>(); // speed up fetching List <Object> depList = new List <Object>(); HashSet <Object> depSet = new HashSet <Object>(); HashSet <Object> queued = new HashSet <Object>(); foreach (SerializedFile file in files) { foreach (Object asset in file.FetchAssets()) { if (!options.Filter(asset)) { continue; } depList.Add(asset); depSet.Add(asset); } } for (int i = 0; i < depList.Count; i++) { Object asset = depList[i]; if (!queued.Contains(asset)) { IExportCollection collection = CreateCollection(virtualFile, asset, options); foreach (Object element in collection.Assets) { queued.Add(element); } collections.Add(collection); } if (options.ExportDependencies) { DependencyContext context = new DependencyContext(exportLayout, true); foreach (PPtr <Object> pointer in asset.FetchDependencies(context)) { if (pointer.IsNull) { continue; } Object dependency = pointer.FindAsset(asset.File); if (dependency == null) { string hierarchy = $"[{asset.File.Name}]" + asset.File.GetAssetLogString(asset.PathID) + "." + context.GetPointerPath(); Logger.Log(LogType.Warning, LogCategory.Export, $"{hierarchy}'s dependency {context.PointerName} = {pointer.ToLogString(asset.File)} wasn't found"); continue; } if (!depSet.Contains(dependency)) { depList.Add(dependency); depSet.Add(dependency); } } } } depList.Clear(); depSet.Clear(); queued.Clear(); EventExportPreparationFinished?.Invoke(); EventExportStarted?.Invoke(); ProjectAssetContainer container = new ProjectAssetContainer(this, options, virtualFile, fileCollection.FetchAssets(), collections); for (int i = 0; i < collections.Count; i++) { IExportCollection collection = collections[i]; container.CurrentCollection = collection; bool isExported = collection.Export(container, path); if (isExported) { Logger.Log(LogType.Info, LogCategory.Export, $"'{collection.Name}' exported"); } EventExportProgressUpdated?.Invoke(i, collections.Count); } EventExportFinished?.Invoke(); }
public void Export(string path, GameCollection fileCollection, SerializedFile file, ExportOptions options) { Export(path, fileCollection, new SerializedFile[] { file }, options); }
public bool IsHandle(Object asset, ExportOptions options) { return(true); }
public override bool IsHandle(Object asset, ExportOptions options) { Font font = (Font)asset; return(font.IsValidData); }
public bool IsHandle(Object asset, ExportOptions options) { return(EngineExportCollection.IsEngineAsset(asset, options.Version)); }