Esempio n. 1
0
        private bool DetermineExportInputMapping()
        {
            AssetExportEnvironment prepareEnv = new AssetExportEnvironment(
                this.exportDir,
                this.input);

            prepareEnv.IsPrepareStep = true;
            this.inputMapping        = this.SelectImporter(prepareEnv);
            return(this.inputMapping.Importer != null);
        }
Esempio n. 2
0
        private bool RunImporter(AssetExportEnvironment env, ExportInputAssignment assignment, IList <string> outputPathCollection)
        {
            try
            {
                assignment.Importer.Export(env);

                // Get a list on properly registered output Resources and report warnings on the rest
                foreach (string outputPath in env.OutputPaths)
                {
                    FileEventManager.FlagPathEditorModified(outputPath);
                    if (!assignment.ExpectedOutput.Contains(outputPath))
                    {
                        Log.Editor.WriteWarning(
                            "AssetImporter '{0}' created an unpredicted output file: '{1}'. " + Environment.NewLine +
                            "This may cause problems in the Asset Management system, especially during Asset re-import. " + Environment.NewLine +
                            "Please fix the implementation of the PrepareExport method so it properly calls AddOutputPath for each predicted output file.",
                            Log.Type(assignment.Importer.GetType()),
                            outputPath);
                    }
                    else
                    {
                        outputPathCollection.Add(outputPath);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Editor.WriteError("An error occurred while trying to export Resource '{2}' using '{1}': {0}",
                                      Log.Exception(ex),
                                      Log.Type(assignment.Importer.GetType()),
                                      env.Input);
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
 private void ResetWorkingData()
 {
     this.isAssetInfoChanged = false;
     this.inputMapping       = default(ExportInputAssignment);
     this.outputPaths        = null;
 }
Esempio n. 4
0
		private bool DetermineExportInputMapping()
		{
			AssetExportEnvironment prepareEnv = new AssetExportEnvironment(
				this.exportDir, 
				this.input);
			prepareEnv.IsPrepareStep = true;
			this.inputMapping = this.SelectImporter(prepareEnv);
			return this.inputMapping.Importer != null;
		}
Esempio n. 5
0
			public ConflictData(Resource input, ExportInputAssignment[] conflicts, int defaultIndex)
			{
				this.input = input;
				this.conflicts = conflicts;
				this.defaultIndex = defaultIndex;
			}
Esempio n. 6
0
		private void ResetWorkingData()
		{
			this.inputMapping = default(ExportInputAssignment);
			this.outputPaths = null;
		}
Esempio n. 7
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;
		}
Esempio n. 8
0
		private bool RunImporter(AssetExportEnvironment env, ExportInputAssignment assignment, IList<string> outputPathCollection)
		{
			try
			{
				assignment.Importer.Export(env);
						
				// Get a list on properly registered output Resources and report warnings on the rest
				foreach (string outputPath in env.OutputPaths)
				{
					FileEventManager.FlagPathEditorModified(outputPath);
					if (!assignment.ExpectedOutput.Contains(outputPath))
					{
						Log.Editor.WriteWarning(
							"AssetImporter '{0}' created an unpredicted output file: '{1}'. " + Environment.NewLine +
							"This may cause problems in the Asset Management system, especially during Asset re-import. " + Environment.NewLine +
							"Please fix the implementation of the PrepareExport method so it properly calls AddOutputPath for each predicted output file.",
							Log.Type(assignment.Importer.GetType()),
							outputPath);
					}
					else
					{
						outputPathCollection.Add(outputPath);
					}
				}
			}
			catch (Exception ex)
			{
				Log.Editor.WriteError("An error occurred while trying to export Resource '{2}' using '{1}': {0}", 
					Log.Exception(ex),
					Log.Type(assignment.Importer.GetType()),
					env.Input);
				return false;
			}

			return true;
		}