public override IExportCollection CreateCollection(Object @object) { Component comp = @object as Component; if (comp != null) { @object = comp.GameObject.GetObject(); } if (@object.ClassID == ClassIDType.GameObject) { GameObject go = (GameObject)@object; @object = go.GetRoot(); } if (@object.ClassID == ClassIDType.GameObject) { GameObject go = (GameObject)@object; Prefab prefab = new Prefab(go); IEnumerable <Object> prefabContent = EnumeratePrefabContent(prefab); PrefabExportCollection collection = new PrefabExportCollection(this, prefab, prefabContent); return(collection); } else { if ([email protected]) { throw new ArgumentException($"Unsupported export object type {@object.ClassID}", "@object"); } AssetExportCollection collection = new AssetExportCollection(this, @object); return(collection); } }
public ExportPointer CreateExportPointer(Object @object) { if (!IsExporting) { throw new InvalidOperationException("Export pointer could be used only during export process"); } foreach (IExportCollection collection in m_collections) { foreach (Object element in collection.Objects) { if (element == @object) { return(collection.CreateExportPointer(element, collection == m_currentCollection)); } } } if (Config.IsExportDependencies) { throw new InvalidOperationException($"Object {@object} wasn't found in any export collection"); } else { string exportID = AssetExportCollection.GetMainExportID(@object); return(new ExportPointer(exportID, UnityGUID.MissingReference, AssetType.Meta)); } }
public string GetExportID(Object @object) { if (!IsExporting) { throw new InvalidOperationException("Export pointer can only be used during export process"); } foreach (IExportCollection collection in m_collections) { foreach (Object element in collection.Objects) { if (element == @object) { return(collection.GetExportID(@object)); } } } if (Config.IsExportDependencies) { throw new InvalidOperationException($"Object {@object} wasn't found in any export collection"); } else { return(AssetExportCollection.GetMainExportID(@object)); } }
public override bool Export(IExportCollection collection, string dirPath) { AssetExportCollection asset = (AssetExportCollection)collection; byte[] data = asset.Asset.ExportBinary(); if (data == null) { return(false); } string subFolder = asset.Asset.ClassID.ToString(); string subPath = Path.Combine(dirPath, subFolder); string fileName = GetUniqueFileName(asset.Asset, subPath); string filePath = Path.Combine(subPath, fileName); if (!Directory.Exists(subPath)) { Directory.CreateDirectory(subPath); } using (FileStream fileStream = new FileStream(filePath, FileMode.CreateNew, FileAccess.Write)) { using (BinaryWriter writer = new BinaryWriter(fileStream)) { writer.Write(data); } } ExportMeta(asset, filePath); return(true); }
public override void Export(IExportCollection collection, string dirPath) { AssetExportCollection asset = (AssetExportCollection)collection; string subFolder = asset.Asset.ClassID.ToString(); string subPath = Path.Combine(dirPath, subFolder); string fileName = GetUniqueFileName(asset.Asset, subPath); string filePath = Path.Combine(subPath, fileName); PrefabExportCollection prefab = collection as PrefabExportCollection; if (prefab == null) { YAMLExporter.Export(asset.Asset, filePath); } else { YAMLExporter.Export(prefab.Objects, filePath); } ExportMeta(collection, filePath); }
public override IExportCollection CreateCollection(Object @object) { AssetExportCollection collection = new AssetExportCollection(this, @object); return(collection); }