We've moved!

Starting from MRTK 2.6, we are publishing both conceptual docs and API references on docs.microsoft.com. For conceptual docs, please visit our new landing page. For API references, please visit the MRTK-Unity section of the dot net API explorer. Existing content will remain here but will not be updated further.

    Show / Hide Table of Contents

    Class MixedRealityToolkitFiles

    API for working with MixedRealityToolkit folders contained in the project.

    Inheritance
    Object
    MixedRealityToolkitFiles
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Microsoft.MixedReality.Toolkit.Utilities.Editor
    Assembly: cs.temp.dll.dll
    Syntax
    public static class MixedRealityToolkitFiles
    Remarks

    This class works by looking for sentinel files (following the pattern MRTK.*.sentinel, for example, MRTK.Core.sentinel) in order to identify where the MRTK is located within the project.

    If the MRTK is being consumed as code that sits within the Assets folder, the "root" MRTK folder must be at most three directories deep - this search code will only reason over MRTK folders that sit in a depth range [0, 3].

    Fields

    DirectorySearchDepth

    Directory levels to search for MRTK folders below the root directory.

    Declaration
    public const int DirectorySearchDepth = 3
    Field Value
    Type Description
    Int32
    Remarks

    E.g. with level 3 and folders ROOT/A/B/C/D would search A and B and C, but not D.

    Properties

    AreFoldersAvailable

    Are any of the MRTK directories available?

    Declaration
    public static bool AreFoldersAvailable { get; }
    Property Value
    Type Description
    Boolean

    MRTKDirectories

    Returns a collection of MRTK directories found in the project.

    Declaration
    public static IEnumerable<string> MRTKDirectories { get; }
    Property Value
    Type Description
    IEnumerable<String>

    Methods

    FindMatchingModule(String, out List<MixedRealityToolkitModuleType>)

    Try to find the matching modules associated with path by looking for the presence of MRTK sentinel files.

    Declaration
    public static bool FindMatchingModule(string path, out List<MixedRealityToolkitModuleType> result)
    Parameters
    Type Name Description
    String path
    List<MixedRealityToolkitModuleType> result
    Returns
    Type Description
    Boolean
    Remarks

    In certain consumption situations, the content can be placed within the same folder, meaning it's possible for multiple sentinel values to exist within the same folder.

    GetAssetDatabasePath(String)

    Maps an absolute path to be relative to the Project Root path (the Unity folder that contains Assets)

    Declaration
    public static string GetAssetDatabasePath(string absolutePath)
    Parameters
    Type Name Description
    String absolutePath

    The absolute path to the project.

    Returns
    Type Description
    String

    The project relative path.

    Remarks

    This doesn't produce paths that contain step out '..' relative paths.

    GetDirectories(MixedRealityToolkitModuleType)

    Declaration
    public static IEnumerable<string> GetDirectories(MixedRealityToolkitModuleType module)
    Parameters
    Type Name Description
    MixedRealityToolkitModuleType module
    Returns
    Type Description
    IEnumerable<String>

    GetFiles(MixedRealityToolkitModuleType, String)

    Returns files from all folder instances of the MRTK folder relative path.

    Declaration
    public static string[] GetFiles(MixedRealityToolkitModuleType module, string mrtkRelativeFolder)
    Parameters
    Type Name Description
    MixedRealityToolkitModuleType module
    String mrtkRelativeFolder

    The MRTK folder relative path to the target folder.

    Returns
    Type Description
    String[]

    The array of files.

    GetFiles(String)

    Returns files from all folder instances of the MRTK folder relative path.

    Declaration
    public static string[] GetFiles(string mrtkRelativeFolder)
    Parameters
    Type Name Description
    String mrtkRelativeFolder

    The MRTK folder relative path to the target folder.

    Returns
    Type Description
    String[]

    The array of files.

    GetModuleFromPackageFolder(String)

    Finds the module type, if found, from the specified package folder name.

    Declaration
    public static MixedRealityToolkitModuleType GetModuleFromPackageFolder(string packageFolder)
    Parameters
    Type Name Description
    String packageFolder

    The asset folder name (ex: MixedRealityToolkit.Providers)

    Returns
    Type Description
    MixedRealityToolkitModuleType

    MixedRealityToolkitModuleType associated with the package folder name. Returns MixedRealityToolkitModuleType.None if an appropriate module type could not be found.

    MapModulePath(MixedRealityToolkitModuleType)

    Declaration
    public static string MapModulePath(MixedRealityToolkitModuleType module)
    Parameters
    Type Name Description
    MixedRealityToolkitModuleType module
    Returns
    Type Description
    String

    MapRelativeFilePath(MixedRealityToolkitModuleType, String)

    Maps a single relative path file to a concrete path from one of the MRTK folders, if found. Otherwise returns null.

    Declaration
    public static string MapRelativeFilePath(MixedRealityToolkitModuleType module, string mrtkPathToFile)
    Parameters
    Type Name Description
    MixedRealityToolkitModuleType module
    String mrtkPathToFile

    The MRTK folder relative path to the file.

    Returns
    Type Description
    String

    The project relative path to the file.

    MapRelativeFilePath(String)

    Maps a single relative path file to a concrete path from one of the MRTK folders, if found. Otherwise returns null.

    Declaration
    public static string MapRelativeFilePath(string mrtkPathToFile)
    Parameters
    Type Name Description
    String mrtkPathToFile

    The MRTK folder relative path to the file.

    Returns
    Type Description
    String

    The project relative path to the file.

    MapRelativeFilePathToAbsolutePath(MixedRealityToolkitModuleType, String)

    Overload of MapRelativeFilePathToAbsolutePath which provides the ability to specify the module that the file belongs to.

    Declaration
    public static string MapRelativeFilePathToAbsolutePath(MixedRealityToolkitModuleType module, string mrtkPathToFile)
    Parameters
    Type Name Description
    MixedRealityToolkitModuleType module
    String mrtkPathToFile
    Returns
    Type Description
    String
    Remarks

    When searching for a resource that lives in the MixedRealityToolkit.SDK folder, this could be invoked in this way: MapRelativeFilePathToAbsolutePath(MixedRealityToolkitModuleType.SDK, mrtkPathToFile)

    MapRelativeFilePathToAbsolutePath(String)

    Maps a single relative path file to MRTK folders to its absolute path, if found. Otherwise returns null.

    Declaration
    public static string MapRelativeFilePathToAbsolutePath(string mrtkPathToFile)
    Parameters
    Type Name Description
    String mrtkPathToFile
    Returns
    Type Description
    String
    Remarks

    For example, this will map "Inspectors\Data\EditorWindowOptions.json" to its full path like "c:\project\Assets\Libs\MRTK\MixedRealityToolkit\Inspectors\Data\EditorWindowOptions.json". This assumes that the passed in mrtkPathToFile is found under the "MixedRealityToolkit" folder (instead of the MixedRealityToolkit.SDK, or any of the other folders).

    MapRelativeFolderPathToAbsolutePath(MixedRealityToolkitModuleType, String)

    Similar to MapRelativeFilePathToAbsolutePath, except this checks for the existence of a folder instead of file.

    Declaration
    public static string MapRelativeFolderPathToAbsolutePath(MixedRealityToolkitModuleType module, string mrtkPathToFolder)
    Parameters
    Type Name Description
    MixedRealityToolkitModuleType module
    String mrtkPathToFolder
    Returns
    Type Description
    String

    RefreshFolders()

    This function is only exposed for testing purposes, and can change/be removed at any time.

    Declaration
    public static void RefreshFolders()
    Remarks

    Synchronously refreshes the MRTK folder database.

    Back to top Generated by DocFX