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

Represents a relative path to an asset file or folder, typically under 'Assets' or 'Packages'. More...

+ Inheritance diagram for Asset.Path:
+ Collaboration diagram for Asset.Path:

Public Member Functions

 Path ([NotNull] Object asset)
 Creates an asset path from an asset instance.
 
 Path ([NotNull] String folderPath, [NotNull] String fileName, [NotNull] String extension=DefaultExtension)
 Creates an asset path by combining folder path, file name and extension.
 
 Path ([NotNull] String fullOrRelativePath)
 Creates an asset path from either an absolute or relative path.
 
GUID CreateFolders ()
 Creates the folders in the path recursively.
 
Boolean Equals (Path other)
 Tests another path for equality.
 
Boolean Equals (String other)
 Tests another path for equality.
 
override Boolean Equals (System.Object obj)
 Tests path for equality with an object.
 
override Int32 GetHashCode ()
 Returns the internal path string's hash code.
 
void OpenExternal ()
 Opens the folder externally, for example File Explorer (Windows) or Finder (Mac).
 
void Rename (String newFileOrFolderName)
 Renames the last element of the CodeSmileEditor.Asset.Path instance.
 
override String ToString ()
 Returns the relative path as string.
 

Static Public Member Functions

static GUID CreateFolders ([NotNull] Path path)
 Creates any missing folders in the path.
 
static Boolean FileExists ([NotNull] Path path)
 Tests if the given file exists in the file system.
 
static Boolean FolderExists ([NotNull] Path path)
 Tests if the given folder exists in the file system.
 
static Path FromMeta ([NotNull] Path path)
 Returns the asset's file path from a .meta file path.
 
static Path Get ([NotNull] Object asset)
 Gets the relative path of an asset.
 
static String[] Get ([NotNull] Object[] assets)
 Converts an array of asset instances to their asset paths.
 
static Path Get (GUID guid)
 Gets the relative path of an asset.
 
static GUID GetGuid ([NotNull] Path path, AssetPathToGUIDOptions options=AssetPathToGUIDOptions.IncludeRecentlyDeletedAssets)
 Returns the GUID for an asset path.
 
static Path GetScene ([NotNull] Object instanceOrAsset)
 Returns the scene's path if the object is instantiated in a scene, otherwise returns the object's path.
 
static String[] GetSubFolders ([NotNull] Path path)
 Returns the names of all subfolders in the path.
 
static Boolean IsValid ([NotNull] String path)
 Returns true if the provided path is valid.
 
static implicit operator Path (String path)
 Implicit conversion to Path from a string.
 
static implicit operator String (Path path)
 Implicit conversion to string.
 
static Boolean operator!= (Path path1, Path path2)
 Tests two path instances for inequality.
 
static Boolean operator!= (Path path1, System.Object other)
 Tests for inequality with an object.
 
static Boolean operator!= (System.Object other, Path path)
 Tests for inequality with an object.
 
static Boolean operator== (Path path1, Path path2)
 Tests two path instances for equality.
 
static Boolean operator== (Path path1, System.Object other)
 Tests for equality with an object.
 
static Boolean operator== (System.Object other, Path path)
 Tests for equality with an object.
 
static Path ToMeta ([NotNull] Path path)
 Returns the .meta file path for an asset path.
 
static String[] ToStrings ([NotNull] IEnumerable< Path > paths)
 Converts an IEnumerable collection of Path instances to a string array.
 
static Path UniquifyFileName ([NotNull] Path path)
 Returns the path altered with a numbering if an asset already exists (and is imported) at the path.
 

Properties

Path AssetPath [get]
 Returns the path to the asset file if the path represents a .meta file.
 
Boolean Exists [get]
 Returns true if the path exists in the AssetDatabase.
 
Boolean ExistsInFileSystem [get]
 Returns true if the path exists in the file system.
 
String Extension [get]
 Returns the extension of the path.
 
String FileName [get]
 Returns the file name with extension.
 
String FileNameWithoutExtension [get]
 Returns the file name without extension.
 
Path FolderPath [get]
 Returns the relative path to the directory the file or folder is in.
 
static String FullAssetsPath [get]
 Returns the absolute path to the project's Assets subfolder.
 
static String FullLibraryPath [get]
 Returns the absolute path to the project's Library subfolder.
 
static String FullLogsPath [get]
 Returns the absolute path to the project's Logs subfolder.
 
static String FullPackagesPath [get]
 Returns the absolute path to the project's Packages subfolder.
 
String FullPath [get]
 Returns the full (absolute) path with forward slashes as separators.
 
static String FullProjectPath [get]
 Returns the absolute path to the project's root folder.
 
static String FullProjectSettingsPath [get]
 Returns the absolute path to the project's ProjectSettings subfolder.
 
static String FullProjectTempPath [get]
 Returns the absolute path to the project's Temp subfolder.
 
static String FullUserSettingsPath [get]
 Returns the absolute path to the project's UserSettings subfolder.
 
GUID Guid [get]
 Returns the GUID for the path.
 
Path MetaPath [get]
 Returns the path to the .meta file if the path is an asset file or folder.
 
String[] SubFolders [get]
 Returns the names of all folders in a path to a folder.
 
Path UniqueFilePath [get]
 Returns the path altered with a numbering if an asset already exists (and is imported) at the path.
 

Detailed Description

Represents a relative path to an asset file or folder, typically under 'Assets' or 'Packages'.

  • Guards against inconsistencies like invalid paths (not under project root), illegal characters, etc.
  • Converts path separators to forward slashes for compatibility with OS X, Linux
  • Converts absolute paths to relative paths
  • Implicitly convertible to/from string eg "use it like a string path"
  • Provides quick access to File I/O tasks like: get file's folder, extension, full path, exists, meta file, etc.

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