public SelectAssetImporterDialog(IEnumerable<IAssetImporter> importers, IAssetImporter defaultImporter, IEnumerable<string> inputFiles)
		{
			this.InitializeComponent();
			
			this.importerTreeNodeName.DrawText += this.importerTreeNodeName_DrawText;
			this.fileTreeNodeName.DrawText += this.fileTreeNodeName_DrawText;
			this.fileViewColumnName.DrawColHeaderBg += this.fileViewColumnName_DrawColHeaderBg;
			this.inputFileView.ColumnHeaderHeight = 1;

			this.importerModel = new TreeModel();
			this.fileModel = new TreeModel();
			
			foreach (string inputFile in inputFiles)
			{
				this.fileModel.Nodes.Add(new Node
				{
					Text = inputFile,
					Image = GeneralResCache.page_white
				});
			}
			foreach (IAssetImporter importer in importers)
			{
				this.importerModel.Nodes.Add(new ImporterNode(importer));
			}
			this.defaultImporter = defaultImporter;
		}
Example #2
0
        public override Entity Import(IAssetImporter ctx, UnityEngine.Video.VideoClip clip)
        {
            var entityVideo = ctx.CreateEntity(typeof(Unity.Tiny.Video.VideoClip), typeof(Unity.Tiny.Video.VideoClipLoadFromFile));

            ctx.AddBufferFromString <Unity.Tiny.Video.VideoClipLoadFromFileName>(entityVideo, "Data/" + clip.GetGuid().ToString("N"));
            return(entityVideo);
        }
Example #3
0
        private static string[] ExportAssets(ContentRef <Resource> inputResource, string exportDir, bool simulate)
        {
            // Early-out, if the input Resource isn't available
            if (!inputResource.IsAvailable)
            {
                return(new string[0]);
            }

            // If there is no export directory set, derive it from the Resource path in the Data folder
            if (exportDir == null)
            {
                exportDir = AssetInternalHelper.GetSourceMediaBaseDir(inputResource);
            }

            bool userAbort = false;
            bool success   = false;

            // Set up an export operation and process it
            AssetExportOperation exportOperation = new AssetExportOperation(inputResource.Res, exportDir);

            exportOperation.ImporterConflictHandler = data =>
            {
                IAssetImporter userSelection = ResolveImporterConflict(data);
                if (userSelection == null)
                {
                    userAbort = true;
                }
                return(userSelection);
            };
            success = simulate ?
                      exportOperation.SimulatePerform() :
                      exportOperation.Perform();

            // Did we actually do something?
            if (!simulate && !userAbort)
            {
                // If the exporter modified export parameters of the Resource, notify the editor that we have modified it.
                if (exportOperation.IsAssetInfoChanged)
                {
                    DualityEditorApp.NotifyObjPropChanged(null,
                                                          new ObjectSelection(inputResource.Res),
                                                          ReflectionInfo.Property_Resource_AssetInfo);
                }

                // If the operation was a failure, display an error message in the editor UI.
                if (!success)
                {
                    MessageBox.Show(
                        string.Format(Properties.GeneralRes.Msg_CantExport_Text, inputResource.Path),
                        Properties.GeneralRes.Msg_CantExport_Caption,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }

                // Global event handling
                OnExportFinished(exportOperation, success);
            }

            return(exportOperation.OutputPaths.ToArray());
        }
Example #4
0
        public SelectAssetImporterDialog(IEnumerable <IAssetImporter> importers, IAssetImporter defaultImporter, IEnumerable <string> inputFiles)
        {
            this.InitializeComponent();

            this.importerTreeNodeName.DrawText      += this.importerTreeNodeName_DrawText;
            this.fileTreeNodeName.DrawText          += this.fileTreeNodeName_DrawText;
            this.fileViewColumnName.DrawColHeaderBg += this.fileViewColumnName_DrawColHeaderBg;
            this.inputFileView.ColumnHeaderHeight    = 1;

            this.importerModel = new TreeModel();
            this.fileModel     = new TreeModel();

            foreach (string inputFile in inputFiles)
            {
                this.fileModel.Nodes.Add(new Node
                {
                    Text  = inputFile,
                    Image = GeneralResCache.page_white
                });
            }
            foreach (IAssetImporter importer in importers)
            {
                this.importerModel.Nodes.Add(new ImporterNode(importer));
            }
            this.defaultImporter = defaultImporter;
        }
        public override Entity Import(IAssetImporter ctx, UnityEngine.AudioClip audioClip)
        {
            var entity = ctx.CreateEntity(typeof(AudioClip), typeof(AudioClipLoadFromFile), typeof(AudioClipLoadFromFileAudioFile));

            ctx.SetBufferFromString <AudioClipLoadFromFileAudioFile>(entity, "Data/" + audioClip.GetGuid().ToString("N"));
            return(entity);
        }
Example #6
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            ImporterNode node = this.importerView.SelectedNode != null ? this.importerView.SelectedNode.Tag as ImporterNode : null;

            this.selectedImporter = node != null ? node.Importer : null;
            this.DialogResult     = DialogResult.OK;
            this.Close();
        }
Example #7
0
        static void Main(string[] args)
        {
            var textureImporter = new IAssetImporter[] {
                new TwoTextureImporter("2d/a.png"),
                new TwoTextureImporter("2d/b.png"),
                new ThreeTextureImporter("3d/b.png"),
                new ThreeTextureImporter("3d/b.png"),
                new ComplexModelImporter("3d/model/e.fbx"),
            };

            new AssetImportProcessor().Execute(textureImporter);
        }
 internal AssetToImportByImporter(AssetToImport parent, IAssetImporter importer, AssetItem previousItem = null)
 {
     if (parent == null) throw new ArgumentNullException("parent");
     if (importer == null) throw new ArgumentNullException("importer");
     this.Parent = parent;
     this.importer = importer;
     this.Items = new List<AssetToImportMergeGroup>();
     Enabled = true;
     Log = new LoggerResult(string.Format("{0} Importer", importer.Name));
     ImporterParameters = importer.GetDefaultParameters(previousItem != null);
     ImporterParameters.Logger = Log;
     PreviousItem = previousItem;
 }
Example #9
0
        public static bool IsSupportingFile(this IAssetImporter importer, UFile file)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (file.GetFileExtension() == null)
            {
                return(false);
            }

            return(FileUtility.GetFileExtensionsAsSet(importer.SupportedFileExtensions).Contains(file.GetFileExtension()));
        }
Example #10
0
 /// <summary>
 /// Register an AssetImporter object to be used when attempting to load an asset
 /// of the given type, or an asset file with one of the given extensions.
 /// </summary>
 /// <param name="assetImporter"></param>
 /// <param name="assetFileExtensions"></param>
 public static void RegisterAssetImporter<T>(
     IAssetImporter assetImporter, params string[] assetFileExtensions)
 {
     var assetType = typeof(T);
     if (RegisteredAssetImportersByType.ContainsKey(assetType))
     {
         throw new AssetImporterRegistrationException(
             String.Format("An asset importer has already been " +
                           "associated with the type '{0}'.", assetType));
     }
     RegisteredAssetImportersByType.Add(assetType, assetImporter);
     RegisterAssetImporter(assetImporter, assetFileExtensions);
 }
Example #11
0
        public Meta(IAssetImporter importer, EngineGUID guid)
        {
            if (importer == null)
            {
                throw new ArgumentNullException(nameof(importer));
            }
            if (guid.IsZero)
            {
                throw new ArgumentNullException(nameof(guid));
            }

            m_importer = importer;
            m_guid     = guid;
        }
        protected void ExportAsset(ProjectAssetContainer container, IAssetImporter importer, Object asset, string path, string name)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string filePath = $"{Path.Combine(path, name)}.{asset.ExportExtension}";

            AssetExporter.Export(container, asset, filePath);
            Meta meta = new Meta(importer, asset.GUID);

            ExportMeta(container, meta, filePath);
        }
Example #13
0
        public override Entity Import(IAssetImporter ctx, UnityEngine.U2D.SpriteAtlas atlas)
        {
            var entity = ctx.CreateEntity(typeof(SpriteAtlas));

            var sprites = atlas.GetPackedSprites().Select(s => ctx.GetEntity(s)).Where(e => e != Entity.Null).ToArray();
            var buffer  = ctx.GetBuffer <SpriteAtlas>(entity).Reinterpret <Entity>();

            foreach (var sprite in sprites)
            {
                buffer.Add(sprite);
            }

            return(entity);
        }
Example #14
0
        private static string[] ExportAssets(ContentRef <Resource> inputResource, string exportDir, bool simulate)
        {
            // Early-out, if the input Resource isn't available
            if (!inputResource.IsAvailable)
            {
                return(new string[0]);
            }

            // If there is no export directory set, derive it from the Resource path in the Data folder
            if (exportDir == null)
            {
                string resFullNameInData = PathHelper.MakeFilePathRelative(inputResource.FullName, DualityApp.DataDirectory);
                string resDirInData      = Path.GetDirectoryName(resFullNameInData);
                exportDir = Path.Combine(
                    EditorHelper.SourceMediaDirectory,
                    resDirInData);
            }

            bool userAbort = false;
            bool success   = false;

            // Set up an export operation and process it
            AssetExportOperation exportOperation = new AssetExportOperation(inputResource.Res, exportDir);

            exportOperation.ImporterConflictHandler = data =>
            {
                IAssetImporter userSelection = ResolveImporterConflict(data);
                if (userSelection == null)
                {
                    userAbort = true;
                }
                return(userSelection);
            };
            success = simulate ?
                      exportOperation.SimulatePerform() :
                      exportOperation.Perform();

            // If the operation was a failure, display an error message in the editor UI.
            if (!simulate && !success && !userAbort)
            {
                MessageBox.Show(
                    string.Format(Properties.GeneralRes.Msg_CantExport_Text, inputResource.Path),
                    Properties.GeneralRes.Msg_CantExport_Caption,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }

            return(exportOperation.OutputPaths.ToArray());
        }
Example #15
0
 /// <summary>
 /// Register an AssetImporter object to b used when attempting to load an asset
 /// file with one of the given extensions.
 /// 
 /// This is useful if you have multiple different asset importers for the same
 /// asset type but different asset file extensions. If two asset importers have
 /// the same associated asset type, but different asset file extensions, the
 /// AssetLoader will be able to determine the asset importer to use when given a
 /// file, but will not be able to distinguish the asset importer to use when
 /// given the asset type.
 /// 
 /// To further illustrate:
 /// <code>
 ///     AssetLoader.RegisterAssetImporter<Texture2D>(new AssetImporter1(), "doc", "xml");
 ///     AssetLoader.RegisterAssetImporter(new AssetImporter2(), "docx");
 /// </code>
 /// 
 /// In the above example, it is assumed that AssetImporter1 and AssetImporter2 both import
 /// Texture2D objects. Calling AssetLoader.Load<Texture2D>(fileName) would use AssetImporter1
 /// to import the asset, as well as AssetLoader.LoadUsingExtension("something.doc"), but
 /// AssetLoader.LoadUsingExtension("something.docx") would use AssetImporter2, and
 /// AssetLoader.Load<Texture2D>("something.docx") would *still* attempt to use AssetImporter1,
 /// since that's the only asset importer associated with Texture2D.
 /// </summary>
 /// <param name="assetImporter"></param>
 /// <param name="assetFileExtensions"></param>
 public static void RegisterAssetImporter(
     IAssetImporter assetImporter, params string[] assetFileExtensions)
 {
     foreach (var ext in assetFileExtensions)
     {
         var truncated = ext[0] == '.' ? ext.Substring(1) : ext;
         if (RegisteredAssetImportersByExtension.ContainsKey(truncated))
         {
             throw new AssetImporterRegistrationException(
                 String.Format("An asset importer has already been " + 
                               "associated with the extension '.{0}'", truncated));
         }
         RegisteredAssetImportersByExtension.Add(truncated, assetImporter);
     }
 }
        public override Entity Import(IAssetImporter ctx, UnityEngine.Texture2D texture)
        {
            var entity = ctx.CreateEntity(typeof(Image2D), typeof(Image2DLoadFromFile), typeof(Image2DLoadFromFileImageFile));

            ctx.SetComponentData(entity, new Image2D()
            {
                disableSmoothing = texture.filterMode == UnityEngine.FilterMode.Point,
                imagePixelSize   = new Mathematics.float2(texture.width, texture.height),
                hasAlpha         = Texture2DAsset.HasAlpha(texture)
            });

            ctx.SetBufferFromString <Image2DLoadFromFileImageFile>(entity, "Data/" + texture.GetGuid().ToString("N"));

            return(entity);
        }
Example #17
0
        protected void ExportAsset(ProjectAssetContainer container, IAssetImporter importer, Object asset, string path, string name)
        {
            if (!DirectoryUtils.Exists(path))
            {
                DirectoryUtils.CreateVirtualDirectory(path);
            }

            string fullName   = $"{name}.{GetExportExtension(asset)}";
            string uniqueName = FileUtils.GetUniqueName(path, fullName, FileUtils.MaxFileNameLength - MetaExtension.Length);
            string filePath   = Path.Combine(path, uniqueName);

            AssetExporter.Export(container, asset, filePath);
            Meta meta = new Meta(importer, asset.GUID);

            ExportMeta(container, meta, filePath);
        }
        public static Scene ImportFromFile(string fileName)
        {
            // Look for importer which handles this file extension.
            string fileExtension     = Path.GetExtension(fileName).ToUpper();
            var    lazyAssetImporter = Instance.AssetImporters.SingleOrDefault(l => l.Metadata.Extension.ToUpper() == fileExtension);

            if (lazyAssetImporter == null)
            {
                throw new ArgumentException("Could not find importer for extension '" + fileExtension + "'");
            }

            IAssetImporter assetImporter = lazyAssetImporter.Value;
            FileStream     fileStream    = File.OpenRead(fileName);

            return(assetImporter.ImportFile(fileStream, fileName));
        }
Example #19
0
 internal static void Init()
 {
     foreach (TypeInfo genType in DualityEditorApp.GetAvailDualityEditorTypes(typeof(IAssetImporter)))
     {
         if (genType.IsAbstract)
         {
             continue;
         }
         IAssetImporter gen = genType.CreateInstanceOf() as IAssetImporter;
         if (gen != null)
         {
             importers.Add(gen);
         }
     }
     importers.StableSort((a, b) => b.Priority > a.Priority ? 1 : -1);
 }
Example #20
0
        private static AssetImportOutput[] ImportAssets(IEnumerable <string> inputFiles, string targetBaseDir, string inputBaseDir, bool simulate)
        {
            // Early-out, if no input files are specified
            if (!inputFiles.Any())
            {
                return(new AssetImportOutput[0]);
            }

            bool userAbort = false;
            bool success   = false;

            // Set up an import operation and process it
            AssetFirstImportOperation importOperation = new AssetFirstImportOperation(inputFiles, targetBaseDir, inputBaseDir);

            importOperation.ConfirmOverwriteCallback = ConfirmOverwriteData;
            importOperation.ImporterConflictHandler  = data =>
            {
                IAssetImporter userSelection = ResolveImporterConflict(data);
                if (userSelection == null)
                {
                    userAbort = true;
                }
                return(userSelection);
            };
            success = simulate ?
                      importOperation.SimulatePerform() :
                      importOperation.Perform();

            // Did we actually do something?
            if (!simulate && !userAbort)
            {
                // If the operation was a failure, display an error message in the editor UI.
                if (!success)
                {
                    MessageBox.Show(
                        string.Format(Properties.GeneralRes.Msg_CantImport_Text, inputFiles.First()),
                        Properties.GeneralRes.Msg_CantImport_Caption,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }

                // Global event handling
                OnImportFinished(importOperation, success);
            }

            return(importOperation.Output.ToArray());
        }
Example #21
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;
 }
 internal AssetToImportByImporter(AssetToImport parent, IAssetImporter importer, AssetItem previousItem = null)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     if (importer == null)
     {
         throw new ArgumentNullException("importer");
     }
     this.Parent               = parent;
     this.importer             = importer;
     this.Items                = new List <AssetToImportMergeGroup>();
     Enabled                   = true;
     Log                       = new LoggerResult(string.Format("{0} Importer", importer.Name));
     ImporterParameters        = importer.GetDefaultParameters(previousItem != null);
     ImporterParameters.Logger = Log;
     PreviousItem              = previousItem;
 }
Example #23
0
        /// <summary>
        /// Registers a <see cref="IAssetImporter" /> for the specified asset type.
        /// </summary>
        /// <param name="importer">The importer.</param>
        /// <exception cref="System.ArgumentNullException">importer</exception>
        public static void RegisterImporter(IAssetImporter importer)
        {
            if (importer == null)
            {
                throw new ArgumentNullException("importer");
            }

            // Register this importer
            lock (RegistryLock)
            {
                var existingImporter = FindImporterById(importer.Id);
                if (existingImporter != null)
                {
                    RegisteredImportersInternal.Remove(existingImporter);
                }

                RegisteredImportersInternal.Add(importer);
                RegisteredImportersInternal.Sort((left, right) => left.Order.CompareTo(right.Order));
            }
        }
Example #24
0
        private int ResolveMappingConflict(Resource input, ExportInputAssignment[] conflictingAssignments)
        {
            // Ask the input Resource which importer it would prefer
            if (input != null && input.AssetInfo != null && input.AssetInfo.ImporterId != null)
            {
                for (int i = 0; i < conflictingAssignments.Length; i++)
                {
                    // If we have a match with the preferred importer, this is definitely the correct assignment to handle this.
                    if (conflictingAssignments[i].Importer.Id == input.AssetInfo.ImporterId)
                    {
                        return(i);
                    }
                }
            }

            // By default, fall back on simply prefering the highest-priority importer
            int keepIndex   = -1;
            int highestPrio = int.MinValue;

            for (int i = 0; i < conflictingAssignments.Length; i++)
            {
                if (conflictingAssignments[i].Importer.Priority > highestPrio)
                {
                    highestPrio = conflictingAssignments[i].Importer.Priority;
                    keepIndex   = i;
                }
            }

            // If there is a conflict handler (such as "spawn a user dialog"), see if that can deal with it.
            if (this.conflictHandler != null)
            {
                ConflictData   data             = new ConflictData(input, conflictingAssignments, keepIndex);
                IAssetImporter selectedImporter = this.conflictHandler(data);
                int            selectedIndex    = conflictingAssignments.IndexOfFirst(item => item.Importer == selectedImporter);
                return(selectedIndex);
            }

            return(keepIndex);
        }
Example #25
0
        /// <summary>
        /// Registers a <see cref="IAssetImporter" /> for the specified asset type.
        /// </summary>
        /// <param name="importer">The importer.</param>
        /// <exception cref="System.ArgumentNullException">importer</exception>
        public static void RegisterImporter(IAssetImporter importer)
        {
            if (importer == null)
            {
                throw new ArgumentNullException("importer");
            }

            // Register this importer
            lock (RegisteredImportersInternal)
            {
                if (RegisteredImportersInternal.ContainsKey(importer.Id))
                {
                    return;
                }
                RegisteredImportersInternal[importer.Id] = importer;
            }

            // Register file extensions to type
            var extensions = FileUtility.GetFileExtensions(importer.SupportedFileExtensions);

            lock (RegisterImportExtensions)
            {
                foreach (var extension in extensions)
                {
                    List <IAssetImporter> importers;
                    if (!RegisterImportExtensions.TryGetValue(extension, out importers))
                    {
                        importers = new List <IAssetImporter>();
                        RegisterImportExtensions.Add(extension, importers);
                    }
                    if (!importers.Contains(importer))
                    {
                        importers.Add(importer);
                        // Always keep the list of importer sotred by their DisplayRank
                        importers.Sort((left, right) => - left.DisplayRank.CompareTo(right.DisplayRank));
                    }
                }
            }
        }
Example #26
0
        public override Entity Import(IAssetImporter ctx, UnityEngine.Sprite sprite)
        {
            var entity = ctx.CreateEntity(typeof(Sprite2D));

            var texture = SpriteAsset.GetSpriteTexture(sprite);
            var rect    = SpriteAsset.GetSpriteTextureRect(sprite);
            var offset  = SpriteAsset.GetSpriteTextureRectOffset(sprite);
            var pivot   = sprite.pivot;
            var border  = sprite.border;

            ctx.SetComponentData(entity, new Sprite2D()
            {
                image       = ctx.GetEntity(texture),
                imageRegion = new Rect(
                    rect.x / texture.width,
                    rect.y / texture.height,
                    rect.width / texture.width,
                    rect.height / texture.height),
                pivot = new float2(
                    (pivot.x - offset.x) / rect.width,
                    (pivot.y - offset.y) / rect.height),
                pixelsToWorldUnits = 1f / sprite.pixelsPerUnit
            });

            if (border != UnityEngine.Vector4.zero)
            {
                ctx.AddComponentData(entity, new Sprite2DBorder()
                {
                    bottomLeft = new float2(
                        border.x / rect.width,
                        border.y / rect.height),
                    topRight = new float2(
                        (rect.width - border.z) / rect.width,
                        (rect.height - border.w) / rect.height)
                });
            }
            return(entity);
        }
Example #27
0
        public override Entity Import(IAssetImporter ctx, TMP_FontAsset font)
        {
            var entity = ctx.CreateEntity(typeof(BitmapFont), typeof(CharacterInfoBuffer));

            ctx.SetComponentData(entity, new BitmapFont()
            {
                textureAtlas = ctx.GetEntity(font.atlasTexture),
                size         = font.creationSettings.pointSize,
                ascent       = font.faceInfo.ascentLine,
                descent      = font.faceInfo.descentLine
            });

            var buffer = ctx.GetBuffer <CharacterInfoBuffer>(entity).Reinterpret <CharacterInfo>();

            foreach (var lookup in font.characterLookupTable)
            {
                var glyph  = lookup.Value;
                var rect   = glyph.glyph.glyphRect;
                var region = new Rect(
                    (float)rect.x / font.atlasTexture.width,
                    (float)rect.y / font.atlasTexture.height,
                    (float)rect.width / font.atlasTexture.width,
                    (float)rect.height / font.atlasTexture.height);

                buffer.Add(new CharacterInfo
                {
                    value           = lookup.Key,
                    advance         = glyph.glyph.metrics.horizontalAdvance,
                    bearingX        = glyph.glyph.metrics.horizontalBearingX,
                    bearingY        = glyph.glyph.metrics.horizontalBearingY,
                    width           = glyph.glyph.metrics.width,
                    height          = glyph.glyph.metrics.height,
                    characterRegion = region
                });
            }

            return(entity);
        }
Example #28
0
        private int ResolveMappingConflict(ImportInputAssignment[] conflictingAssignments)
        {
            // Determine the preferred importer based on existing output Resources
            string preferredImporterId = null;

            {
                // Check each importer assignment individually, as each one represents a conflicting import operation
                for (int i = 0; i < conflictingAssignments.Length; i++)
                {
                    preferredImporterId = null;

                    // Find out whether all output Resources of this importer assignment exist and share the same preferred importer
                    AssetImportOutput[] output = conflictingAssignments[i].ExpectedOutput;
                    for (int j = 0; j < output.Length; j++)
                    {
                        Resource existingRes = output[j].Resource.Res;
                        if (existingRes == null)
                        {
                            preferredImporterId = null;
                            break;
                        }

                        // If at least one Resource doesn't have a preference, that's ambiuous. Cancel it.
                        string resImporterPref = existingRes.AssetInfo != null ? existingRes.AssetInfo.ImporterId : null;
                        if (resImporterPref == null)
                        {
                            preferredImporterId = null;
                            break;
                        }

                        // Set up the shared importer preference
                        if (preferredImporterId == null)
                        {
                            preferredImporterId = resImporterPref;
                        }
                        // If different outputs from this mapping report different preferred importers, that's ambiguous. Cancel it.
                        else if (preferredImporterId != resImporterPref)
                        {
                            preferredImporterId = null;
                            break;
                        }
                    }

                    // If this importer assignment's Resources have full confidence in a preferred importer, we have a match
                    if (preferredImporterId != null)
                    {
                        break;
                    }
                }
            }

            // If we have a preferred ID, see if it's an option
            if (preferredImporterId != null)
            {
                for (int i = 0; i < conflictingAssignments.Length; i++)
                {
                    // If we have a match with the preferred importer, this is definitely the correct assignment to handle this.
                    if (conflictingAssignments[i].Importer.Id == preferredImporterId)
                    {
                        return(i);
                    }
                }
            }

            // By default, fall back on simply prefering the highest-priority importer
            int keepIndex   = -1;
            int highestPrio = int.MinValue;

            for (int i = 0; i < conflictingAssignments.Length; i++)
            {
                if (conflictingAssignments[i].Importer.Priority > highestPrio)
                {
                    highestPrio = conflictingAssignments[i].Importer.Priority;
                    keepIndex   = i;
                }
            }

            // If there is a conflict handler (such as "spawn a user dialog"), see if that can deal with it.
            if (this.conflictHandler != null)
            {
                ConflictData   data             = new ConflictData(conflictingAssignments, keepIndex);
                IAssetImporter selectedImporter = this.conflictHandler(data);
                int            selectedIndex    = conflictingAssignments.IndexOfFirst(assignment => assignment.Importer == selectedImporter);
                return(selectedIndex);
            }

            return(keepIndex);
        }
Example #29
0
 public PipelineBuilder Use(IAssetImporter importer)
 {
     _importers.Add(importer);
     return(this);
 }
Example #30
0
 protected AssetsExportCollection(IAssetExporter assetExporter, Object asset, IAssetImporter metaImporter) :
     base(assetExporter, asset, metaImporter)
 {
 }
			public ImporterNode(IAssetImporter importer) : base(importer.Name)
			{
				this.importer = importer;
				this.Image = importer.GetType().GetEditorImage();
			}
		private void buttonOk_Click(object sender, EventArgs e)
		{
			ImporterNode node = this.importerView.SelectedNode != null ? this.importerView.SelectedNode.Tag as ImporterNode : null;
			this.selectedImporter = node != null ? node.Importer : null;
			this.DialogResult = DialogResult.OK;
			this.Close();
		}
		private void buttonCancel_Click(object sender, EventArgs e)
		{
			this.selectedImporter = null;
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}
Example #34
0
 public Entity Import(IAssetImporter ctx, UnityEngine.Object obj)
 {
     return(Import(ctx, obj as T));
 }
Example #35
0
 public abstract Entity Import(IAssetImporter ctx, T obj);