Exemplo n.º 1
0
        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");
                }
            }
        }
Exemplo n.º 2
0
 public NativeFormatImporter(Object mainObject)
 {
     if (mainObject == null)
     {
         throw new ArgumentNullException(nameof(mainObject));
     }
     m_mainObject = mainObject;
 }
Exemplo n.º 3
0
 public override string GetExportID(Object asset)
 {
     if (asset == Asset)
     {
         return(GetMainExportID(Asset));
     }
     throw new ArgumentException(nameof(asset));
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
        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));
            }
        }
Exemplo n.º 7
0
        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));
            }
        }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
        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}'");
        }
Exemplo n.º 10
0
 public AssetExportCollection(IAssetExporter assetExporter, Object asset) :
     this(assetExporter, asset, new NativeFormatImporter(asset))
 {
 }
Exemplo n.º 11
0
 private IEnumerable <Object> ToIEnumerable(Object @object)
 {
     yield return(@object);
 }
Exemplo n.º 12
0
 public void Export(string path, Object @object)
 {
     Export(path, ToIEnumerable(@object));
 }
Exemplo n.º 13
0
 private IEnumerable <Object> ToIEnumerable(Object asset)
 {
     yield return(asset);
 }
Exemplo n.º 14
0
 public void Export(IExportContainer container, Object asset, string path)
 {
 }
Exemplo n.º 15
0
 public void Export(string path, FileCollection fileCollection, Object asset)
 {
     Export(path, fileCollection, new Object[] { asset });
 }
Exemplo n.º 16
0
 public void Export(IExportContainer container, Object asset, string path, Action <IExportContainer, Object, string> callback)
 {
 }
Exemplo n.º 17
0
 public override bool IsContains(Object asset)
 {
     return(Asset == asset);
 }
Exemplo n.º 18
0
 public AssetType ToExportType(Object asset)
 {
     ToUnknownExportType(asset.ClassID, out AssetType assetType);
     return(assetType);
 }
Exemplo n.º 19
0
 public bool IsHandle(Object asset)
 {
     return(true);
 }
Exemplo n.º 20
0
 public void Export(string path, Object asset)
 {
     Export(path, ToIEnumerable(asset));
 }