protected string GetUniqueFileName(Object @object, string dirPath) { string fileName; NamedObject named = @object as NamedObject; if (named == null) { Prefab prefab = @object as Prefab; if (prefab != null) { fileName = prefab.Name; } else { fileName = @object.GetType().Name; } } else { fileName = named.Name; } fileName = DirectoryUtils.GetMaxIndexName(dirPath, fileName); fileName = $"{fileName}.{@object.ExportExtension}"; return(fileName); }
public void Export(string path, IEnumerable <Object> objects) { if (IsExporting) { throw new InvalidOperationException("Unable to start a new export process until the old one is completed"); } // 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); } m_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 dep in current.FetchDependencies(true)) { if (!depSet.Contains(dep)) { depList.Add(dep); depSet.Add(dep); } } } } depList.Clear(); depSet.Clear(); queued.Clear(); foreach (IExportCollection collection in m_collections) { m_currentCollection = collection; bool isExported = collection.AssetExporter.Export(collection, path); if (isExported) { Logger.Log(LogType.Info, LogCategory.Export, $"'{collection.Name}' exported"); } } m_currentCollection = null; m_collections.Clear(); }
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 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 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 string GetExportID(Object @object) { if (@object == Asset) { return(base.GetExportID(@object)); } return(m_exportIDs[@object]); }
public ExportPointer CreateExportPointer(Object @object, bool isLocal) { if (isLocal) { throw new ArgumentException(nameof(isLocal)); } return(new ExportPointer(GetExportID(@object), UnityGUID.MissingReference, AssetExporter.ToExportType(@object.ClassID))); }
public virtual string GetExportID(Object @object) { if (@object == Asset) { return(GetMainExportID(Asset)); } throw new ArgumentException(nameof(@object)); }
public ExportPointer CreateExportPointer(Object @object, bool isLocal) { string exportID = GetExportID(@object); return(isLocal ? new ExportPointer(exportID) : new ExportPointer(exportID, @object.GUID, AssetExporter.ToExportType(@object.ClassID))); }
public string GetExportID(Object @object) { if (@object == m_asset) { return($"{(int)m_asset.ClassID}00000"); } throw new ArgumentException(nameof(@object)); }
public AssetExportCollection(IAssetExporter assetExporter, Object asset) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (asset == null) { throw new ArgumentNullException(nameof(asset)); } AssetExporter = assetExporter; Asset = asset; MetaImporter = new NativeFormatImporter(asset); }
private bool IsPresentInCollection(Object @object) { foreach (IExportCollection collection in m_collections) { foreach (Object element in collection.Objects) { if (element == @object) { return(true); } } } return(false); }
public IExportCollection CreateCollection(Object @object) { MonoScript monoScript = @object as MonoScript; if (monoScript != null) { return(new SkipExportCollection(this, monoScript, monoScript.ClassName)); } AnimatorController animController = @object as AnimatorController; if (animController != null) { return(new SkipExportCollection(this, animController)); } AssetBundle bundle = (AssetBundle)@object; string name = bundle.IsReadAssetBundleName ? bundle.AssetBundleName : bundle.Name; return(new EmptyExportCollection(this, name)); }
private void AddObject(Object @object) { if (@object == null) { throw new ArgumentNullException(nameof(@object)); } #warning ID compatible with Unity 2017.3f1. Add support depend of current version string exportID; do { m_builder.Length = 0; m_builder.Append((int)@object.ClassID); for (int i = 0; i < 15; i++) { int number = RandomUtils.Next(0, 10); m_builder.Append(number); } exportID = m_builder.ToString(); }while (m_exportIDs.Values.Any(t => t == exportID)); m_exportIDs.Add(@object, exportID); }
public static string GetMainExportID(Object @object) { return($"{(int)@object.ClassID}00000"); }
public override IExportCollection CreateCollection(Object @object) { AssetExportCollection collection = new AssetExportCollection(this, @object); return(collection); }
public ExportPointer CreateExportPointer(Object @object, bool isLocal) { throw new NotSupportedException(); }
public string GetExportID(Object @object) { return(Exporter.GetExportID(@object)); }
public string GetExportID(Object @object) { throw new NotSupportedException(); }
public override IExportCollection CreateCollection(Object @object) { return(new AssetExportCollection(this, @object)); }
public void Export(string path, Object @object) { Export(path, ToIEnumerable(@object)); }
public abstract IExportCollection CreateCollection(Object @object);
public ExportPointer CreateExportPointer(Object @object) { return(Exporter.CreateExportPointer(@object)); }
private IEnumerable <Object> ToIEnumerable(Object @object) { yield return(@object); }