Search Results for

    Show / Hide Table of Contents

    Class UnityPath

    Dealing the path in Unity can be very painful. This class provides a set of extensions to make it easier to work with file paths in Unity. (It's still painful, but at least it's easier.)

    Inheritance
    object
    UnityPath
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Glitch9
    Assembly: Glitch9.dll
    Syntax
    public static class UnityPath

    Properties

    | Edit this page View Source

    consoleLogPath

    Declaration
    public static string consoleLogPath { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    dataPath

    Declaration
    public static string dataPath { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    persistentDataPath

    Declaration
    public static string persistentDataPath { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    resourcesPath

    Declaration
    public static string resourcesPath { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    streamingAssetsPath

    Declaration
    public static string streamingAssetsPath { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    temporaryCachePath

    Declaration
    public static string temporaryCachePath { get; }
    Property Value
    Type Description
    string

    Methods

    | Edit this page View Source

    Combine(string, string)

    Declaration
    public static string Combine(string basePath, string relativePath)
    Parameters
    Type Name Description
    string basePath
    string relativePath
    Returns
    Type Description
    string
    | Edit this page View Source

    CombineDataPath(string)

    Declaration
    public static string CombineDataPath(string relativePath)
    Parameters
    Type Name Description
    string relativePath
    Returns
    Type Description
    string
    | Edit this page View Source

    Convert(string, UnityPathType)

    Converts a path from one UnityPathType to another.

    Declaration
    public static string Convert(string path, UnityPathType to)
    Parameters
    Type Name Description
    string path
    UnityPathType to
    Returns
    Type Description
    string
    | Edit this page View Source

    DetectPathType(string)

    Resolves the path type based on the given file path.

    Declaration
    public static UnityPathType DetectPathType(string unknownTypePath)
    Parameters
    Type Name Description
    string unknownTypePath

    The file path as a string

    Returns
    Type Description
    UnityPathType

    The resolved path type

    | Edit this page View Source

    ExtractResourcesPath(string)

    Extracts the path relative to the Resources folder from a full path.

    Declaration
    public static string ExtractResourcesPath(string fullPath)
    Parameters
    Type Name Description
    string fullPath
    Returns
    Type Description
    string
    | Edit this page View Source

    FormatRelativePath(string, string)

    Declaration
    public static string FormatRelativePath(string fileName, string basePath)
    Parameters
    Type Name Description
    string fileName
    string basePath
    Returns
    Type Description
    string
    | Edit this page View Source

    GetFileName(Object, string)

    Declaration
    public static string GetFileName(Object obj, string path = null)
    Parameters
    Type Name Description
    Object obj
    string path
    Returns
    Type Description
    string
    | Edit this page View Source

    GetFileUri(string)

    Converts a relative path to a file URI (file://).

    Declaration
    public static string GetFileUri(string filePath)
    Parameters
    Type Name Description
    string filePath
    Returns
    Type Description
    string
    | Edit this page View Source

    GetFullDirectoryPath(string)

    Declaration
    public static string GetFullDirectoryPath(string filePath)
    Parameters
    Type Name Description
    string filePath
    Returns
    Type Description
    string
    | Edit this page View Source

    GetFullPath(string)

    Gets the full local path (starting with C:/ or D:/) for a UnityFilePath object.

    Declaration
    public static string GetFullPath(string path)
    Parameters
    Type Name Description
    string path

    The UnityFilePath object

    Returns
    Type Description
    string

    The resolved local path as a string

    | Edit this page View Source

    GetRelativePath(string)

    Converts a relative path to an absolute path.

    Declaration
    public static string GetRelativePath(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    string
    | Edit this page View Source

    GetStreamingAssetsPath(string)

    Declaration
    public static string GetStreamingAssetsPath(string subPath)
    Parameters
    Type Name Description
    string subPath
    Returns
    Type Description
    string
    | Edit this page View Source

    GetUnityObjectDefaultExtension(Object)

    Declaration
    public static string GetUnityObjectDefaultExtension(Object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    string
    | Edit this page View Source

    IsProjectPath(UnityPathType)

    Returns true if the path is inside the build on the device. This includes Assets, Resources, and StreamingAssets.

    Declaration
    public static bool IsProjectPath(this UnityPathType pathType)
    Parameters
    Type Name Description
    UnityPathType pathType
    Returns
    Type Description
    bool
    | Edit this page View Source

    IsProjectPath(string)

    Returns true if the path is a project-relative path (starts with "Assets/" or is under Application.dataPath).

    Declaration
    public static bool IsProjectPath(this string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    bool
    | Edit this page View Source

    IsValidAssetPath(string)

    Checks if a given asset path is valid and safe (no traversal, within Assets folder).

    Declaration
    public static bool IsValidAssetPath(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    bool
    | Edit this page View Source

    ResolvePath(UnityPathType)

    Declaration
    public static string ResolvePath(UnityPathType pathType)
    Parameters
    Type Name Description
    UnityPathType pathType
    Returns
    Type Description
    string
    | Edit this page View Source

    SanitizeAssetPath(string)

    Normalizes a Unity asset path by ensuring forward slashes are used and that it is rooted under "Assets/". Also protects against path traversal attacks using "../" sequences.

    Declaration
    public static string SanitizeAssetPath(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    string
    • Edit this page
    • View Source
    In this article
    Back to top AI DevKit Documentation