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 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); }