/// <summary> /// Returns whether or not this importer accepts the given input. /// By default, compares the input files extension to <see cref="SourceFileExts"/>. /// </summary> protected virtual bool AcceptsInput(AssetImportInput input) { string inputFileExt = Path.GetExtension(input.Path); bool matchingFileExt = this.SourceFileExts.Any(acceptedExt => string.Equals(inputFileExt, acceptedExt, StringComparison.InvariantCultureIgnoreCase)); return(matchingFileExt); }
private void DetermineLocalInputFilePaths() { for (int assignmentIndex = 0; assignmentIndex < this.inputMapping.Count; assignmentIndex++) { ImportInputAssignment assignment = inputMapping.Data[assignmentIndex]; // Create a relative mapping for each of the handled files AssetImportInput[] handledInputInSourceMedia = new AssetImportInput[assignment.HandledInput.Length]; for (int i = 0; i < assignment.HandledInput.Length; i++) { string oldFullName = assignment.HandledInput[i].AssetName; string newFullName; // If there was an automatic rename of output Resources, reflect that with local source / media paths if (this.assetRenameMap.TryGetValue(oldFullName, out newFullName)) { string ext = Path.GetExtension(assignment.HandledInput[i].Path); string newRelativePath = newFullName + ext; handledInputInSourceMedia[i] = new AssetImportInput( Path.Combine(sourceDir, newRelativePath), newRelativePath, newFullName); } // Otherwise, perform a regular mapping from original input location to local source / media else { handledInputInSourceMedia[i] = new AssetImportInput( Path.Combine(sourceDir, assignment.HandledInput[i].RelativePath), assignment.HandledInput[i].RelativePath, assignment.HandledInput[i].AssetName); } } // Assign the determined paths back to the input mapping this.inputMapping.Data[assignmentIndex].HandledInputInSourceMedia = handledInputInSourceMedia; } }
private bool AcceptsInput(AssetImportInput input) { string inputFileExt = Path.GetExtension(input.Path); bool matchingFileExt = SourceFileExts.Any(acceptedExt => string.Equals(inputFileExt, acceptedExt, StringComparison.InvariantCultureIgnoreCase)); return matchingFileExt; }
/// <summary> /// Returns the name of the resource that this importer /// would generate for the given input. Defaults to the name /// of the input file, without extension. /// </summary> protected virtual string GetResourceNameFromInput(AssetImportInput input) { return(input.AssetName); }
/// <summary> /// Performs the import operation for a resource. /// </summary> /// <param name="resourceRef">A <see cref="ContentRef{T}"/> pointing to the resource being imported.</param> /// <param name="input">The input information for the import operation.</param> /// <param name="env">The input environment in which the import is taking place.</param> protected abstract void ImportResource(ContentRef <T> resourceRef, AssetImportInput input, IAssetImportEnvironment env);
private void DetermineLocalInputFilePaths() { for (int assignmentIndex = 0; assignmentIndex < this.inputMapping.Count; assignmentIndex++) { ImportInputAssignment assignment = inputMapping.Data[assignmentIndex]; // Create a relative mapping for each of the handled files AssetImportInput[] handledInputInSourceMedia = new AssetImportInput[assignment.HandledInput.Length]; for (int i = 0; i < assignment.HandledInput.Length; i++) { string oldFullName = assignment.HandledInput[i].AssetName; string newFullName; // If there was an automatic rename of output Resources, reflect that with local source / media paths if (this.assetRenameMap.TryGetValue(oldFullName, out newFullName)) { string ext = Path.GetExtension(assignment.HandledInput[i].Path); string newRelativePath = newFullName + ext; handledInputInSourceMedia[i] = new AssetImportInput( Path.Combine(sourceDir, newRelativePath), newRelativePath, newFullName); } // Otherwise, perform a regular mapping from original input location to local source / media else { handledInputInSourceMedia[i] = new AssetImportInput( Path.Combine(sourceDir, assignment.HandledInput[i].RelativePath), assignment.HandledInput[i].RelativePath, assignment.HandledInput[i].AssetName); } } // Assign the determined paths back to the input mapping this.inputMapping.Data[assignmentIndex].HandledInputInSourceMedia = handledInputInSourceMedia; } }