Description
The FindProjectByDirectory
method is a static method of the Editor.EditorUtility
class. It is used to locate a Sandbox.Project
instance based on a specified directory path. This method is particularly useful when you need to retrieve project information from a given directory within the Sandbox environment.
Usage
To use the FindProjectByDirectory
method, you need to provide a string representing the full path of the directory you want to search. The method will return a Sandbox.Project
object if a project is found at the specified location, or it may return null
if no project is found.
Example
// Example usage of FindProjectByDirectory
string directoryPath = "C:\\Projects\\MySandboxProject";
Sandbox.Project project = Editor.EditorUtility.FindProjectByDirectory(directoryPath);
if (project != null)
{
// Project found, proceed with operations on the project
Console.WriteLine($"Project Name: {project.Name}");
}
else
{
// No project found at the specified directory
Console.WriteLine("No project found at the specified directory.");
}