Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
IAssetImporter.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Diagnostics;
6 using SiliconStudio.Core.IO;
7 
8 namespace SiliconStudio.Assets
9 {
10  /// <summary>
11  /// Imports a raw asset into the asset system.
12  /// </summary>
13  public interface IAssetImporter
14  {
15  /// <summary>
16  /// Gets an unique identifier to identify the importer. See remarks.
17  /// </summary>
18  /// <value>The identifier.</value>
19  /// <remarks>This identifier is used to recover the importer used for a particular asset. This
20  /// Guid must be unique and stored statically in the definition of an importer. It is used to
21  /// reimport an existing asset with the same importer.
22  /// </remarks>
23  Guid Id { get; }
24 
25  /// <summary>
26  /// Gets the name of this importer.
27  /// </summary>
28  /// <value>The name.</value>
29  string Name { get; }
30 
31  /// <summary>
32  /// Gets the description of this importer.
33  /// </summary>
34  /// <value>The description.</value>
35  string Description { get; }
36 
37  /// <summary>
38  /// Gets the supported file extensions (separated by ',' for multiple extensions) by this importer.
39  /// </summary>
40  /// <returns>Returns a list of supported file extensions handled by this importer.</returns>
41  string SupportedFileExtensions { get; }
42 
43  /// <summary>
44  /// Gets the default parameters for this importer.
45  /// </summary>
46  /// <param name="isForReImport"></param>
47  /// <value>The supported types.</value>
48  AssetImporterParameters GetDefaultParameters(bool isForReImport);
49 
50  /// <summary>
51  /// Gets the rank of this importer, higher is the value, higher the importer is important or commonly used. Default is <c>100</c>.
52  /// </summary>
53  /// <value>The rank.</value>
54  // TODO this could be done also at runtime dynamically based on real usage
55  int DisplayRank { get; }
56 
57  /// <summary>
58  /// Imports a raw assets from the specified path into the specified package.
59  /// </summary>
60  /// <param name="rawAssetPath">The path to a raw asset on the disk.</param>
61  /// <param name="importParameters">The parameters. It is mandatory to call <see cref="GetDefaultParameters"/> and pass the parameters instance here</param>
62  IEnumerable<AssetItem> Import(UFile rawAssetPath, AssetImporterParameters importParameters);
63  }
64 
65  public static class AssetImportExtensions
66  {
67  public static bool IsSupportingFile(this IAssetImporter importer, UFile file)
68  {
69  if (file == null) throw new ArgumentNullException("file");
70  if (file.GetFileExtension() == null) return false;
71 
72  return FileUtility.GetFileExtensionsAsSet(importer.SupportedFileExtensions).Contains(file.GetFileExtension());
73  }
74  }
75 
76 }
static bool IsSupportingFile(this IAssetImporter importer, UFile file)
Parameters used by IAssetImporter.Import
string GetFileExtension()
Gets the extension of the file. Can be null.
Definition: UFile.cs:84
Imports a raw asset into the asset system.
Defines a normalized file path. See UPath for details. This class cannot be inherited.
Definition: UFile.cs:13