CodeSmile AssetDatabase 1.9
Unity's AssetDatabase in enjoyable, consistent, concise, convenient, comprehensible, safe, documented form.
Loading...
Searching...
No Matches

◆ Path() [2/3]

Path ( [NotNull] String folderPath,
[NotNull] String fileName,
[NotNull] String extension = DefaultExtension )

Creates an asset path by combining folder path, file name and extension.

The default extension is ".asset". Note that AssetImporters rely on file extensions.

Example parameters: "\Assets\Some/Sub\Dir", "New File", "MyExt"

Resulting path: "Assets/Some/Sub/Dir/New File.myext"

Parameters
folderPathAbsolute or relative path to a folder. Leading/trailing path separators are trimmed.
fileNameName of the file without extension. Must not contain path separators.
extensionExtension of the file (default: 'asset'). Leading dots will be trimmed. Extension will be lowercase.
See also

Definition at line 251 of file Asset.Path.cs.

252 {
253 ThrowIf.NullOrWhitespace(folderPath, nameof(folderPath));
254 ThrowIf.NullOrWhitespace(fileName, nameof(fileName));
255 ThrowIf.NullOrWhitespace(extension, nameof(extension));
256 ThrowIf.ContainsPathSeparators(fileName, nameof(fileName));
257
258 var relativeDir = ToRelative(folderPath.ToForwardSlashes());
259 m_RelativePath = $"{relativeDir}/{fileName}.{extension.TrimStart('.').ToLower()}";
260 }