Wanzyee Studio

Include some convenient methods for editor or asset operation. More...

Static Public Member Functions

static Object[] GetAllAssets (bool progressBar=false)
 Get all main assets in the project folder. More...
 
static string[] GetAllAssetLabels (params Object[] assets)
 Get all asset labels used in project, or only find the ones used by assigned assets. More...
 
static T[] LoadAssets< T > (string filter=null, params string[] searchInFolders)
 Load all specified type assets with the search filter in the folders. More...
 
static bool OpenAsset< T > (int instanceID, Action< T > handler)
 Common template method to open an asset. More...
 
static string GetObjectOrder (Object source, bool assetFirst=true)
 Get an order string of given object for sorting. More...
 
static string GetTypeOrder (Type source, bool builtinFirst=true)
 Get an order string of given type for sorting. More...
 
static void ReplaceDrawerType (Type type, Type drawer, bool children=true, Type original=null)
 Replace the default property drawer type for the specified type. More...
 
static Type GetDrawerType (Type type)
 Get the creatable property drawer type for the specified type. More...
 
static PropertyDrawer CreateDrawer (Type type, FieldInfo field, PropertyAttribute attribute=null)
 Create a property drawer instance. More...
 
static void OpenAbout (Object obj)
 Open the about message of the specified object. More...
 
static bool CheckIoCreatable (string path, bool overwrite=false, bool exception=false)
 Determine if the path can be used to create a file or directory. More...
 
static IEnumerable< Type > GetExposingTypes (bool editor=false)
 Get types appropriate to expose in the Inspector to select members, optional to include editor types. More...
 

Detailed Description

Include some convenient methods for editor or asset operation.

3

Member Function Documentation

static Object [] GetAllAssets ( bool  progressBar = false)
static

Get all main assets in the project folder.

Parameters
progressBarIf set to true show progress bar while scanning.
Returns
The all assets.
static string [] GetAllAssetLabels ( params Object[]  assets)
static

Get all asset labels used in project, or only find the ones used by assigned assets.

Parameters
assetsAssets.
Returns
The asset labels.
static T [] LoadAssets< T > ( string  filter = null,
params string[]  searchInFolders 
)
static

Load all specified type assets with the search filter in the folders.

Template Parameters
TThe asset type.
Parameters
filterThe filter string can contain search data.
searchInFoldersThe folders where the search will start.
Returns
The assets.
Type Constraints
T :Object 
static bool OpenAsset< T > ( int  instanceID,
Action< T >  handler 
)
static

Common template method to open an asset.

Basically for usage of UnityEditor.Callbacks.OnOpenAssetAttribute.

Template Parameters
TAsset type.
Parameters
instanceIDInstance ID.
handlerCallback to open the asset.
Returns
true, if handled the opening of the asset.
Type Constraints
T :Object 
static string GetObjectOrder ( Object  source,
bool  assetFirst = true 
)
static

Get an order string of given object for sorting.

It's asset path, append with sibling if relative to UnityEngine.GameObject. Optional to sort asset or hierarchy object first.

Parameters
sourceSource object.
assetFirstIf set to true asset first.
Returns
The order.
static string GetTypeOrder ( Type  source,
bool  builtinFirst = true 
)
static

Get an order string of given type for sorting.

It's type full name, optional to sort Unity and System type first.

Parameters
sourceSource type.
builtinFirstIf set to true built-in type first.
Returns
The order.
static void ReplaceDrawerType ( Type  type,
Type  drawer,
bool  children = true,
Type  original = null 
)
static

Replace the default property drawer type for the specified type.

Parameters
typeThe drawn type.
drawerNew drawer type.
childrenIf set to use for children types.
originalOnly replace when match the original drawer type if set.
static Type GetDrawerType ( Type  type)
static

Get the creatable property drawer type for the specified type.

Parameters
typeThe drawn type.
Returns
The drawer type.
static PropertyDrawer CreateDrawer ( Type  type,
FieldInfo  field,
PropertyAttribute  attribute = null 
)
static

Create a property drawer instance.

Parameters
typeThe drawer type.
fieldThe field info.
attributeThe attribute.
Returns
The property drawer.
static void OpenAbout ( Object  obj)
static

Open the about message of the specified object.

This fetches the messages from the object type attributes:

  1. Brief message from System.ComponentModel.DescriptionAttribute.
  2. Online manual URL from UnityEngine.HelpURLAttribute.

Show a dialog if there's the brief, and with a button to open the URL if exists. Otherwise, directly open the URL, or warning if not any message.

Parameters
objThe object to retrieve documentation for.
static bool CheckIoCreatable ( string  path,
bool  overwrite = false,
bool  exception = false 
)
static

Determine if the path can be used to create a file or directory.

Check IoUtility.CheckCreatable() at the first. Then return true if the file doesn't exist yet or force to overwrite. Otherwise popup a dialog for the user to make the decision.

Parameters
pathPath.
overwriteOverwrite.
exceptionIf invalid, throw an exception or return false.
Returns
true if is creatable; otherwise, false.
static IEnumerable<Type> GetExposingTypes ( bool  editor = false)
static

Get types appropriate to expose in the Inspector to select members, optional to include editor types.

Include types from Unity and assemblies in the project folder. And what excluded is non-public, interface, enum, array or generic types.

Parameters
editorIf set to true include editor types.
Returns
The types.