Exemplo n.º 1
0
 public bool IsHandle(Object asset, ExportOptions options)
 {
     return(true);
 }
Exemplo n.º 2
0
        private IExportCollection CreateCollection(VirtualSerializedFile file, Object asset, ExportOptions options)
        {
            Stack <IAssetExporter> exporters = m_exporters[asset.ClassID];

            foreach (IAssetExporter exporter in exporters)
            {
                if (exporter.IsHandle(asset, options))
                {
                    return(exporter.CreateCollection(file, asset));
                }
            }
            throw new Exception($"There is no exporter that can handle '{asset}'");
        }
Exemplo n.º 3
0
        public void Export(string path, FileCollection fileCollection, IEnumerable <Object> assets, ExportOptions options)
        {
            EventExportPreparationStarted?.Invoke();
            VirtualSerializedFile    virtualFile = new VirtualSerializedFile(options);
            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(assets);
            depSet.UnionWith(depList);
            for (int i = 0; i < depList.Count; i++)
            {
                Object asset = depList[i];
                if (!queued.Contains(asset))
                {
                    IExportCollection collection = CreateCollection(virtualFile, asset, options);
                    foreach (Object element in collection.Assets)
                    {
                        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 asset.FetchDependencies(true))
                    {
                        if (dependency == null)
                        {
                            continue;
                        }

                        if (!depSet.Contains(dependency))
                        {
                            depList.Add(dependency);
                            depSet.Add(dependency);
                        }
                    }
                }
            }
            depList.Clear();
            depSet.Clear();
            queued.Clear();
            EventExportPreparationFinished?.Invoke();

            EventExportStarted?.Invoke();
            ProjectAssetContainer container = new ProjectAssetContainer(this, virtualFile, fileCollection.FetchAssets(), collections, options);
            for (int i = 0; i < collections.Count; i++)
            {
                IExportCollection collection = collections[i];
                container.CurrentCollection = collection;
                bool isExported = collection.Export(container, path);
                if (isExported)
                {
                    Logger.Log(LogType.Info, LogCategory.Export, $"'{collection.Name}' exported");
                }
                EventExportProgressUpdated?.Invoke(i, collections.Count);
            }
            EventExportFinished?.Invoke();
        }
Exemplo n.º 4
0
 public void Export(string path, FileCollection fileCollection, Object asset, ExportOptions options)
 {
     Export(path, fileCollection, new Object[] { asset }, options);
 }
Exemplo n.º 5
0
        public override bool IsHandle(Object asset, ExportOptions options)
        {
            Font font = (Font)asset;

            return(font.IsValidData);
        }
Exemplo n.º 6
0
 public bool IsHandle(Object asset, ExportOptions options)
 {
     return(EngineExportCollection.IsEngineAsset(asset, options.Version));
 }