Skip to main content
Version: 2.1.x

Class EditorTools

Editor Tools Class

Assembly: YooAsset.Editor.dll
View Source
Declaration
public static class EditorTools

Methods

GetAssignableTypes(Type)

Get the types of all classes with inheritance relationships

View Source
Declaration
public static List<Type> GetAssignableTypes(Type parentType)
Returns

System.Collections.Generic.List<System.Type>

Parameters
TypeName
System.TypeparentType

InvokeNonPublicStaticMethod(Type, string, params object[])

Invoke private static methods

View Source
Declaration
public static object InvokeNonPublicStaticMethod(Type type, string method, params object[] parameters)
Returns

System.Object

Parameters
TypeNameDescription
System.TypetypeType of the class
System.StringmethodName of the method to be called in the class
System.Object[]parametersParameters passed to the method

InvokePublicStaticMethod(Type, string, params object[])

Invoke public static methods

View Source
Declaration
public static object InvokePublicStaticMethod(Type type, string method, params object[] parameters)
Returns

System.Object

Parameters
TypeNameDescription
System.TypetypeType of the class
System.StringmethodName of the method to be called in the class
System.Object[]parametersParameters passed to the method

FindAssets(EAssetSearchType, string[])

Collect assets

View Source
Declaration
public static string[] FindAssets(EAssetSearchType searchType, string[] searchInFolders)
Returns

System.String[]: List of collected asset paths

Parameters
TypeNameDescription
YooAsset.Editor.EAssetSearchTypesearchTypeType of assets to collect
System.String[]searchInFoldersList of folders to search in

FindAssets(EAssetSearchType, string)

Collect assets

View Source
Declaration
public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder)
Returns

System.String[]: List of collected asset paths

Parameters
TypeNameDescription
YooAsset.Editor.EAssetSearchTypesearchTypeType of assets to collect
System.StringsearchInFolderFolder to search in

OpenFolderPanel(string, string, string)

Open the search panel

View Source
Declaration
public static string OpenFolderPanel(string title, string defaultPath, string defaultName = "")
Returns

System.String: Absolute path of the selected folder, returns NULL if invalid

Parameters
TypeNameDescription
System.StringtitleTitle name
System.StringdefaultPathDefault search path
System.StringdefaultName

OpenFilePath(string, string, string)

Open the search panel

View Source
Declaration
public static string OpenFilePath(string title, string defaultPath, string extension = "")
Returns

System.String: Absolute path of the selected file, returns NULL if invalid

Parameters
TypeNameDescription
System.StringtitleTitle name
System.StringdefaultPathDefault search path
System.Stringextension

DisplayProgressBar(string, int, int)

Display a progress bar

View Source
Declaration
public static void DisplayProgressBar(string tips, int progressValue, int totalValue)
Parameters
TypeName
System.Stringtips
System.Int32progressValue
System.Int32totalValue

ClearProgressBar()

Hide the progress bar

View Source
Declaration
public static void ClearProgressBar()

FocusUnitySceneWindow()

View Source
Declaration
public static void FocusUnitySceneWindow()

CloseUnityGameWindow()

View Source
Declaration
public static void CloseUnityGameWindow()

FocusUnityGameWindow()

View Source
Declaration
public static void FocusUnityGameWindow()

FocueUnityProjectWindow()

View Source
Declaration
public static void FocueUnityProjectWindow()

FocusUnityHierarchyWindow()

View Source
Declaration
public static void FocusUnityHierarchyWindow()

FocusUnityInspectorWindow()

View Source
Declaration
public static void FocusUnityInspectorWindow()

FocusUnityConsoleWindow()

View Source
Declaration
public static void FocusUnityConsoleWindow()

ClearUnityConsole()

Clear the console

View Source
Declaration
public static void ClearUnityConsole()

HasDirtyScenes()

View Source
Declaration
public static bool HasDirtyScenes()
Returns

System.Boolean

StringToStringList(string, char)

View Source
Declaration
public static List<string> StringToStringList(string str, char separator)
Returns

System.Collections.Generic.List<System.String>

Parameters
TypeName
System.Stringstr
System.Charseparator

NameToEnum<T>(string)

View Source
Declaration
public static T NameToEnum<T>(string name)
Returns

<T>

Parameters
TypeName
System.Stringname
Type Parameters
  • T

CreateFileDirectory(string)

Create the directory where the file is located

View Source
Declaration
public static void CreateFileDirectory(string filePath)
Parameters
TypeNameDescription
System.StringfilePathFile path

CreateDirectory(string)

Create a directory

View Source
Declaration
public static bool CreateDirectory(string directory)
Returns

System.Boolean

Parameters
TypeName
System.Stringdirectory

DeleteDirectory(string)

Delete a directory and its subdirectories

View Source
Declaration
public static bool DeleteDirectory(string directory)
Returns

System.Boolean

Parameters
TypeName
System.Stringdirectory

FileRename(string, string)

File Rename

View Source
Declaration
public static void FileRename(string filePath, string newName)
Parameters
TypeName
System.StringfilePath
System.StringnewName

MoveFile(string, string)

Move File

View Source
Declaration
public static void MoveFile(string filePath, string destPath)
Parameters
TypeName
System.StringfilePath
System.StringdestPath

CopyDirectory(string, string)

Copy Directory Note: Including files from all subdirectories

View Source
Declaration
public static void CopyDirectory(string sourcePath, string destPath)
Parameters
TypeName
System.StringsourcePath
System.StringdestPath

CopyFile(string, string, bool)

Copy File

View Source
Declaration
public static void CopyFile(string sourcePath, string destPath, bool overwrite)
Parameters
TypeName
System.StringsourcePath
System.StringdestPath
System.Booleanoverwrite

ClearFolder(string)

Clear Folder

View Source
Declaration
public static void ClearFolder(string directoryPath)
Parameters
TypeName
System.StringdirectoryPath

GetFileSize(string)

Get File Size in bytes

View Source
Declaration
public static long GetFileSize(string filePath)
Returns

System.Int64

Parameters
TypeName
System.StringfilePath

ReadFileAllText(string)

Read all text content of a file

View Source
Declaration
public static string ReadFileAllText(string filePath)
Returns

System.String

Parameters
TypeName
System.StringfilePath

ReadFileAllLine(string)

Read all lines of text content

View Source
Declaration
public static string[] ReadFileAllLine(string filePath)
Returns

System.String[]

Parameters
TypeName
System.StringfilePath

CheckBundleFileValid(byte[])

Check if the AssetBundle file is valid

View Source
Declaration
public static bool CheckBundleFileValid(byte[] fileData)
Returns

System.Boolean

Parameters
TypeName
System.Byte[]fileData

GetRegularPath(string)

Get the regular path

View Source
Declaration
public static string GetRegularPath(string path)
Returns

System.String

Parameters
TypeName
System.Stringpath

GetProjectPath()

Get the project's project path

View Source
Declaration
public static string GetProjectPath()
Returns

System.String

AbsolutePathToAssetPath(string)

Convert the absolute path of a file to a Unity asset path For example, replace D:\YourPorject\Assets\Works\file.txt with Assets/Works/file.txt

View Source
Declaration
public static string AbsolutePathToAssetPath(string absolutePath)
Returns

System.String

Parameters
TypeName
System.StringabsolutePath

AssetPathToAbsolutePath(string)

Converts Unity asset path to the absolute file path. For example: Replace Assets/Works/file.txt with D:\YourProject/Assets/Works/file.txt

View Source
Declaration
public static string AssetPathToAbsolutePath(string assetPath)
Returns

System.String

Parameters
TypeName
System.StringassetPath

FindFolder(string, string)

Recursively finds the target folder path.

View Source
Declaration
public static string FindFolder(string root, string folderName)
Returns

System.String: Returns the found folder path, or an empty string if not found.

Parameters
TypeNameDescription
System.StringrootThe root directory to search.
System.StringfolderNameThe name of the target folder.

Substring(string, string, bool, bool)

Substring a string. Get the content after the matched key.

View Source
Declaration
public static string Substring(string content, string key, bool includeKey, bool firstMatch = true)
Returns

System.String

Parameters
TypeNameDescription
System.StringcontentThe content.
System.StringkeyThe keyword.
System.BooleanincludeKeyWhether the result includes the keyword.
System.BooleanfirstMatch