コード例 #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);
        }
コード例 #2
0
        private ExportInputAssignment SelectImporter(AssetExportEnvironment env)
        {
            if (!env.IsPrepareStep)
            {
                throw new ArgumentException(
                          "The specified export environment must be configured as a preparation environment.",
                          "env");
            }

            // Find an importer to handle some or all of the unhandled input files
            List <ExportInputAssignment> candidates = new List <ExportInputAssignment>();

            foreach (IAssetImporter importer in AssetManager.Importers)
            {
                env.ResetAcquiredData();

                try
                {
                    importer.PrepareExport(env);
                }
                catch (Exception ex)
                {
                    Log.Editor.WriteError("An error occurred in the preparation step of '{1}': {0}",
                                          Log.Exception(ex),
                                          Log.Type(importer.GetType()));
                    continue;
                }

                if (env.IsHandled)
                {
                    candidates.Add(new ExportInputAssignment
                    {
                        Importer       = importer,
                        ExpectedOutput = env.OutputPaths.ToArray()
                    });
                }
            }

            // If multiple importers intend to handle the same files, resolve conflicts
            if (candidates.Count > 1)
            {
                ExportInputAssignment[] conflictingAssignments = candidates.ToArray();
                int selectedIndex = this.ResolveMappingConflict(env.Input, conflictingAssignments);
                if (selectedIndex == -1)
                {
                    return(default(ExportInputAssignment));
                }
                else
                {
                    return(conflictingAssignments[selectedIndex]);
                }
            }

            return(candidates.FirstOrDefault());
        }
コード例 #3
0
        private bool ExportToLocalFolder()
        {
            this.outputPaths = new List <string>();
            bool success = false;

            {
                AssetExportEnvironment importEnv = new AssetExportEnvironment(this.exportDir, this.input);
                success = this.RunImporter(importEnv, this.inputMapping, this.outputPaths);
            }
            return(success);
        }
コード例 #4
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);
        }
コード例 #5
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;
		}
コード例 #6
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;
		}
コード例 #7
0
		private ExportInputAssignment SelectImporter(AssetExportEnvironment env)
		{
			if (!env.IsPrepareStep) throw new ArgumentException(
				"The specified export environment must be configured as a preparation environment.", 
				"env");

			// Find an importer to handle some or all of the unhandled input files
			List<ExportInputAssignment> candidates = new List<ExportInputAssignment>();
			foreach (IAssetImporter importer in AssetManager.Importers)
			{
				env.ResetAcquiredData();

				try
				{
					importer.PrepareExport(env);
				}
				catch (Exception ex)
				{
					Log.Editor.WriteError("An error occurred in the preparation step of '{1}': {0}", 
						Log.Exception(ex),
						Log.Type(importer.GetType()));
					continue;
				}

				if (env.IsHandled)
				{
					candidates.Add(new ExportInputAssignment
					{
						Importer = importer,
						ExpectedOutput = env.OutputPaths.ToArray()
					});
				}
			}

			// If multiple importers intend to handle the same files, resolve conflicts
			if (candidates.Count > 1)
			{
				ExportInputAssignment[] conflictingAssignments = candidates.ToArray();
				int selectedIndex = this.ResolveMappingConflict(env.Input, conflictingAssignments);
				if (selectedIndex == -1)
					return default(ExportInputAssignment);
				else
					return conflictingAssignments[selectedIndex];
			}

			return candidates.FirstOrDefault();
		}
コード例 #8
0
		private bool ExportToLocalFolder()
		{
			this.outputPaths = new List<string>();
			bool success = false;
			{
				AssetExportEnvironment importEnv = new AssetExportEnvironment(this.exportDir, this.input);
				success = this.RunImporter(importEnv, this.inputMapping, this.outputPaths);
			}
			return success;
		}