public void Export(string path, IEnumerable <Object> objects) { List <IExportCollection> collections = new List <IExportCollection>(); // speed up fetching a little bit List <Object> depList = new List <Object>(); HashSet <Object> depSet = new HashSet <Object>(); HashSet <Object> queued = new HashSet <Object>(); depList.AddRange(objects); depSet.UnionWith(depList); for (int i = 0; i < depList.Count; i++) { Object current = depList[i]; if (!queued.Contains(current)) { ClassIDType exportID = current.IsAsset ? current.ClassID : ClassIDType.Component; IAssetExporter exporter = m_exporters[exportID]; IExportCollection collection = exporter.CreateCollection(current); foreach (Object element in collection.Objects) { queued.Add(element); } collections.Add(collection); } #warning TODO: if IsGenerateGUIDByContent set it should build collections and write actual references with persistent GUIS, but skip dependencies if (Config.IsExportDependencies) { foreach (Object dependency in current.FetchDependencies(true)) { if (dependency == null) { continue; } if (!depSet.Contains(dependency)) { depList.Add(dependency); depSet.Add(dependency); } } } } depList.Clear(); depSet.Clear(); queued.Clear(); AssetsExportContainer container = new AssetsExportContainer(this, collections); foreach (IExportCollection collection in collections) { container.CurrentCollection = collection; bool isExported = collection.AssetExporter.Export(container, collection, path); if (isExported) { Logger.Log(LogType.Info, LogCategory.Export, $"'{collection.Name}' exported"); } } }
public NativeFormatImporter(Object mainObject) { if (mainObject == null) { throw new ArgumentNullException(nameof(mainObject)); } m_mainObject = mainObject; }
public override string GetExportID(Object asset) { if (asset == Asset) { return(GetMainExportID(Asset)); } throw new ArgumentException(nameof(asset)); }
public void Export(ProjectAssetContainer container, Object asset, string path) { using (FileStream fileStream = new FileStream(path, FileMode.CreateNew, FileAccess.Write)) { container.File = asset.File; asset.ExportBinary(container, fileStream); } }
public override ExportPointer CreateExportPointer(Object asset, bool isLocal) { string exportID = GetExportID(asset); return(isLocal ? new ExportPointer(exportID) : new ExportPointer(exportID, Asset.GUID, AssetExporter.ToExportType(Asset.ClassID))); }
public IExportCollection CreateCollection(Object asset) { switch (asset.ClassID) { case ClassIDType.MonoManager: case ClassIDType.AssetBundle: case ClassIDType.PreloadData: return(new EmptyExportCollection()); default: return(new SkipExportCollection(this, asset)); } }
public IExportCollection CreateCollection(Object asset) { if (!asset.IsValid) { Logger.Instance.Log(LogType.Warning, LogCategory.Export, $"Can't export '{asset}' because it isn't valid"); return(new EmptyExportCollection()); } switch (asset.ClassID) { case ClassIDType.Texture2D: case ClassIDType.Cubemap: return(new TextureExportCollection(this, asset)); default: return(new AssetExportCollection(this, asset)); } }
public AssetExportCollection(IAssetExporter assetExporter, Object asset, IAssetImporter metaImporter) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (asset == null) { throw new ArgumentNullException(nameof(asset)); } if (metaImporter == null) { throw new ArgumentNullException(nameof(metaImporter)); } AssetExporter = assetExporter; Asset = asset; MetaImporter = metaImporter; }
private IExportCollection CreateCollection(Object asset) { Stack <IAssetExporter> exporters = m_exporters[asset.ClassID]; foreach (IAssetExporter exporter in exporters) { if (exporter.IsHandle(asset)) { if (asset.IsValid) { return(exporter.CreateCollection(asset)); } else { Logger.Instance.Log(LogType.Warning, LogCategory.Export, $"Can't export '{asset}' because it isn't valid"); return(new SkipExportCollection(exporter, asset)); } } } throw new Exception($"There is no exporter that can handle '{asset}'"); }
public AssetExportCollection(IAssetExporter assetExporter, Object asset) : this(assetExporter, asset, new NativeFormatImporter(asset)) { }
private IEnumerable <Object> ToIEnumerable(Object @object) { yield return(@object); }
public void Export(string path, Object @object) { Export(path, ToIEnumerable(@object)); }
private IEnumerable <Object> ToIEnumerable(Object asset) { yield return(asset); }
public void Export(IExportContainer container, Object asset, string path) { }
public void Export(string path, FileCollection fileCollection, Object asset) { Export(path, fileCollection, new Object[] { asset }); }
public void Export(IExportContainer container, Object asset, string path, Action <IExportContainer, Object, string> callback) { }
public override bool IsContains(Object asset) { return(Asset == asset); }
public AssetType ToExportType(Object asset) { ToUnknownExportType(asset.ClassID, out AssetType assetType); return(assetType); }
public bool IsHandle(Object asset) { return(true); }
public void Export(string path, Object asset) { Export(path, ToIEnumerable(asset)); }