Class CoreEditorUtils
Utility class for Editor
Namespace: UnityEditor.Rendering
Syntax
public static class CoreEditorUtils
Properties
buildTargets
Build targets
Declaration
public static GraphicsDeviceType[] buildTargets { get; }
Property Value
Type | Description |
---|---|
GraphicsDeviceType[] |
Methods
AddAdditionalData<T, AdditionalT>(GameObject, Action<AdditionalT>)
Add the appropriate AdditionalData to the given GameObject and its children containing the original component
Declaration
public static void AddAdditionalData<T, AdditionalT>(GameObject go, Action<AdditionalT> initDefault = null)
where T : Component where AdditionalT : Component
Parameters
Type | Name | Description |
---|---|---|
GameObject | go | The root object to update |
Action<AdditionalT> | initDefault | [Optional] The default value to use if there is no AdditionalData |
Type Parameters
Name | Description |
---|---|
T | The type of the original component |
AdditionalT | The type of the AdditionalData component |
CheckOutFile(Boolean, Object)
Declaration
public static void CheckOutFile(bool VCSEnabled, Object mat)
Parameters
Type | Name | Description |
---|---|---|
Boolean | VCSEnabled | |
Object | mat |
CreateColoredTexture2D(Color, String)
Declaration
public static Texture2D CreateColoredTexture2D(Color color, string textureName)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The color to fill the texture |
String | textureName | The name of the texture |
Returns
Type | Description |
---|---|
Texture2D |
CreateGameObject(String, Object)
Creates a new GameObject and set it's position to the current view
Declaration
public static GameObject CreateGameObject(string name, Object context)
Parameters
Type | Name | Description |
---|---|---|
String | name | the name of the new gameobject |
Object | context | the parent of the gameobject |
Returns
Type | Description |
---|---|
GameObject | the created GameObject |
CreateGameObject(GameObject, String, Type[])
Create a game object
Declaration
public static GameObject CreateGameObject(GameObject parent, string name, params Type[] types)
Parameters
Type | Name | Description |
---|---|---|
GameObject | parent | The parent |
String | name | The wanted name (can be updated with a number if a sibling with same name exist |
Type[] | types | Required component on this object in addition to Transform |
Returns
Type | Description |
---|---|
GameObject | The created object |
DrawEnumPopup(SerializedProperty, Type, GUIContent)
Draw an EnumPopup handling multiEdition
Declaration
public static void DrawEnumPopup(SerializedProperty property, Type type, GUIContent label = null)
Parameters
Type | Name | Description |
---|---|---|
SerializedProperty | property | The data displayed |
Type | type | Type of the property |
GUIContent | label | The label |
DrawEnumPopup<TEnum>(Rect, GUIContent, SerializedProperty)
Draws an EnumPopup for the given property
Declaration
public static void DrawEnumPopup<TEnum>(Rect rect, GUIContent label, SerializedProperty serializedProperty)
where TEnum : Enum
Parameters
Type | Name | Description |
---|---|---|
Rect | rect | The rect where the drop down will be drawn |
GUIContent | label | The label for the drop down |
SerializedProperty | serializedProperty | The SerializedProperty to modify |
Type Parameters
Name | Description |
---|---|
TEnum |
DrawFixMeBox(String, Action)
Draw a help box with the Fix button.
Declaration
public static void DrawFixMeBox(string message, Action action)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message text. |
Action | action | When the user clicks the button, Unity performs this action. |
DrawFixMeBox(String, MessageType, Action)
Draw a help box with the Fix button.
Declaration
public static void DrawFixMeBox(string message, MessageType messageType, Action action)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message text. |
MessageType | messageType | The type of the message. |
Action | action | When the user clicks the button, Unity performs this action. |
DrawFixMeBox(String, MessageType, String, Action)
Draw a help box with the Fix button.
Declaration
public static void DrawFixMeBox(string message, MessageType messageType, string buttonLabel, Action action)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message text. |
MessageType | messageType | The type of the message. |
String | buttonLabel | The button text. |
Action | action | When the user clicks the button, Unity performs this action. |
DrawFixMeBox(GUIContent, Action)
Draw a help box with the Fix button.
Declaration
public static void DrawFixMeBox(GUIContent message, Action action)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | message | The message with icon if needed. |
Action | action | When the user clicks the button, Unity performs this action. |
DrawFixMeBox(GUIContent, String, Action)
Draw a help box with the Fix button.
Declaration
public static void DrawFixMeBox(GUIContent message, string buttonLabel, Action action)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | message | The message with icon if needed. |
String | buttonLabel | The button text. |
Action | action | When the user clicks the button, Unity performs this action. |
DrawHeader(String)
Draw a header
Declaration
public static void DrawHeader(string title)
Parameters
Type | Name | Description |
---|---|---|
String | title | Title of the header |
DrawHeader(GUIContent)
Draw a header
Declaration
public static void DrawHeader(GUIContent title)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | Title of the header |
DrawHeaderFoldout(String, Boolean, Boolean, Func<Boolean>, Action)
Draw a foldout header
Declaration
public static bool DrawHeaderFoldout(string title, bool state, bool isBoxed = false, Func<bool> hasMoreOptions = null, Action toggleMoreOption = null)
Parameters
Type | Name | Description |
---|---|---|
String | title | The title of the header |
Boolean | state | The state of the header |
Boolean | isBoxed | [optional] is the eader contained in a box style ? |
Func<Boolean> | hasMoreOptions | [optional] Delegate used to draw the right state of the advanced button. If null, no button drawn. |
Action | toggleMoreOption | [optional] Callback call when advanced button clicked. Should be used to toggle its state. |
Returns
Type | Description |
---|---|
Boolean | return the state of the foldout header |
DrawHeaderFoldout(GUIContent, Boolean, Boolean, Func<Boolean>, Action, String, Action<Vector2>)
Draw a foldout header
Declaration
public static bool DrawHeaderFoldout(GUIContent title, bool state, bool isBoxed = false, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null, string documentationURL = "", Action<Vector2> contextAction = null)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | The title of the header |
Boolean | state | The state of the header |
Boolean | isBoxed | [optional] is the eader contained in a box style ? |
Func<Boolean> | hasMoreOptions | [optional] Delegate used to draw the right state of the advanced button. If null, no button drawn. |
Action | toggleMoreOptions | [optional] Callback call when advanced button clicked. Should be used to toggle its state. |
String | documentationURL | [optional] The URL that the Unity Editor opens when the user presses the help button on the header. |
Action<Vector2> | contextAction | [optional] The callback that the Unity Editor executes when the user presses the burger menu on the header. |
Returns
Type | Description |
---|---|
Boolean | return the state of the foldout header |
DrawHeaderToggle(String, SerializedProperty, SerializedProperty, Action<Vector2>, Func<Boolean>, Action)
Draw a header toggle like in Volumes
Declaration
public static bool DrawHeaderToggle(string title, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction = null, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null)
Parameters
Type | Name | Description |
---|---|---|
String | title | The title of the header |
SerializedProperty | group | The group of the header |
SerializedProperty | activeField | The active field |
Action<Vector2> | contextAction | The context action |
Func<Boolean> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
Returns
Type | Description |
---|---|
Boolean | return the state of the foldout header |
DrawHeaderToggle(String, SerializedProperty, SerializedProperty, Action<Vector2>, Func<Boolean>, Action, String)
Draw a header toggle like in Volumes
Declaration
public static bool DrawHeaderToggle(string title, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction, Func<bool> hasMoreOptions, Action toggleMoreOptions, string documentationURL)
Parameters
Type | Name | Description |
---|---|---|
String | title | The title of the header |
SerializedProperty | group | The group of the header |
SerializedProperty | activeField | The active field |
Action<Vector2> | contextAction | The context action |
Func<Boolean> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
String | documentationURL | Documentation URL |
Returns
Type | Description |
---|---|
Boolean | return the state of the foldout header |
DrawHeaderToggle(GUIContent, SerializedProperty, SerializedProperty, Action<Vector2>, Func<Boolean>, Action)
Draw a header toggle like in Volumes
Declaration
public static bool DrawHeaderToggle(GUIContent title, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction = null, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | The title of the header |
SerializedProperty | group | The group of the header |
SerializedProperty | activeField | The active field |
Action<Vector2> | contextAction | The context action |
Func<Boolean> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
Returns
Type | Description |
---|---|
Boolean | return the state of the foldout header |
DrawHeaderToggle(GUIContent, SerializedProperty, SerializedProperty, Action<Vector2>, Func<Boolean>, Action, String)
Draw a header toggle like in Volumes
Declaration
public static bool DrawHeaderToggle(GUIContent title, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction, Func<bool> hasMoreOptions, Action toggleMoreOptions, string documentationURL)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | The title of the header |
SerializedProperty | group | The group of the header |
SerializedProperty | activeField | The active field |
Action<Vector2> | contextAction | The context action |
Func<Boolean> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
String | documentationURL | Documentation URL |
Returns
Type | Description |
---|---|
Boolean | return the state of the foldout header |
DrawMultipleFields(String, SerializedProperty[], GUIContent[])
Draw a multiple field property
Declaration
public static void DrawMultipleFields(string label, SerializedProperty[] ppts, GUIContent[] labels)
Parameters
Type | Name | Description |
---|---|---|
String | label | Label of the whole |
SerializedProperty[] | ppts | Properties |
GUIContent[] | labels | Sub-labels |
DrawMultipleFields(GUIContent, SerializedProperty[], GUIContent[])
Draw a multiple field property
Declaration
public static void DrawMultipleFields(GUIContent label, SerializedProperty[] ppts, GUIContent[] labels)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | label | Label of the whole |
SerializedProperty[] | ppts | Properties |
GUIContent[] | labels | Sub-labels |
DrawMultipleFields<T>(GUIContent, GUIContent[], T[])
Draw a multiple field property
Declaration
public static void DrawMultipleFields<T>(GUIContent label, GUIContent[] labels, T[] values)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
GUIContent | label | Label of the whole |
GUIContent[] | labels | The labels mapping the values |
T[] | values | The values to be displayed |
Type Parameters
Name | Description |
---|---|
T | The serialized properties |
DrawPopup(GUIContent, SerializedProperty, String[])
Draw a popup
Declaration
public static void DrawPopup(GUIContent label, SerializedProperty property, string[] options)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | label | the label |
SerializedProperty | property | The data displayed |
String[] | options | Options of the dropdown |
DrawSectionHeader(GUIContent, String, Action<Vector2>, Func<Boolean>, Action)
Draw a header section like in Global Settings
Declaration
public static void DrawSectionHeader(GUIContent title, string documentationURL = null, Action<Vector2> contextAction = null, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | The title of the header |
String | documentationURL | Documentation URL |
Action<Vector2> | contextAction | The context action |
Func<Boolean> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
DrawSplitter(Boolean)
Draw a splitter separator
Declaration
public static void DrawSplitter(bool isBoxed = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | isBoxed | [Optional] add margin if the splitter is boxed |
DrawSubHeaderFoldout(String, Boolean, Boolean)
Draw a foldout sub header
Declaration
public static bool DrawSubHeaderFoldout(string title, bool state, bool isBoxed = false)
Parameters
Type | Name | Description |
---|---|---|
String | title | The title of the header |
Boolean | state | The state of the header |
Boolean | isBoxed | [optional] is the eader contained in a box style ? |
Returns
Type | Description |
---|---|
Boolean | return the state of the sub foldout header |
DrawSubHeaderFoldout(String, Boolean, Boolean, Func<Boolean>, Action)
Draw a foldout header
Declaration
[Obsolete("'More Options' versions of DrawSubHeaderFoldout are obsolete. Please use DrawSubHeaderFoldout without 'More Options'")]
public static bool DrawSubHeaderFoldout(string title, bool state, bool isBoxed = false, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null)
Parameters
Type | Name | Description |
---|---|---|
String | title | The title of the header |
Boolean | state | The state of the header |
Boolean | isBoxed | [optional] is the eader contained in a box style ? |
Func<Boolean> | hasMoreOptions | [optional] Delegate used to draw the right state of the advanced button. If null, no button drawn. |
Action | toggleMoreOptions | [optional] Callback call when advanced button clicked. Should be used to toggle its state. |
Returns
Type | Description |
---|---|
Boolean | return the state of the sub foldout header |
DrawSubHeaderFoldout(GUIContent, Boolean, Boolean)
Draw a foldout sub header
Declaration
public static bool DrawSubHeaderFoldout(GUIContent title, bool state, bool isBoxed = false)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | The title of the header |
Boolean | state | The state of the header |
Boolean | isBoxed | [optional] is the eader contained in a box style ? |
Returns
Type | Description |
---|---|
Boolean | return the state of the sub foldout header |
DrawSubHeaderFoldout(GUIContent, Boolean, Boolean, Func<Boolean>, Action)
Draw a foldout header
Declaration
[Obsolete("'More Options' versions of DrawSubHeaderFoldout are obsolete. Please use DrawSubHeaderFoldout without 'More Options'")]
public static bool DrawSubHeaderFoldout(GUIContent title, bool state, bool isBoxed = false, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | The title of the header |
Boolean | state | The state of the header |
Boolean | isBoxed | [optional] is the eader contained in a box style ? |
Func<Boolean> | hasMoreOptions | [optional] Delegate used to draw the right state of the advanced button. If null, no button drawn. |
Action | toggleMoreOptions | [optional] Callback call when advanced button clicked. Should be used to toggle its state. |
Returns
Type | Description |
---|---|
Boolean | return the state of the foldout header |
DrawVector6(GUIContent, SerializedProperty, SerializedProperty, Vector3, Vector3, Color[], SerializedProperty, Boolean)
Draw a Vector6 field
Declaration
public static void DrawVector6(GUIContent label, SerializedProperty positive, SerializedProperty negative, Vector3 min, Vector3 max, Color[] colors = null, SerializedProperty multiplicator = null, bool allowIntersection = true)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | label | The label |
SerializedProperty | positive | The data for +X, +Y and +Z |
SerializedProperty | negative | The data for -X, -Y and -Z |
Vector3 | min | Min clamping value along axis |
Vector3 | max | Max clamping value along axis |
Color[] | colors | [Optional] Color marks to use |
SerializedProperty | multiplicator | [Optional] multiplicator on the datas |
Boolean | allowIntersection | [Optional] Allow the face positive values to be smaller than negative ones and vice versa |
FindProperty<T, TValue>(Expression<Func<T, TValue>>)
To use with extreme caution. It not really get the property but try to find a field with similar name Hence inheritance override of property is not supported. Also variable rename will silently break the search.
Declaration
public static string FindProperty<T, TValue>(Expression<Func<T, TValue>> expr)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, TValue>> | expr | Expression returning the value seeked |
Returns
Type | Description |
---|---|
String | serialization path of the seeked property |
Type Parameters
Name | Description |
---|---|
T | Entry type of expr |
TValue | Type of the value |
GetAdditionalData<T>(Object[], Action<T>)
Get the AdditionalData of the given component
Declaration
public static T[] GetAdditionalData<T>(Object[] targets, Action<T> initDefault = null)
where T : Component
Parameters
Type | Name | Description |
---|---|---|
Object[] | targets | The object to seek for AdditionalData |
Action<T> | initDefault | [Optional] The default value to use if there is no AdditionalData |
Returns
Type | Description |
---|---|
T[] | return an AdditionalData component |
Type Parameters
Name | Description |
---|---|
T | The type of the AdditionalData component |
GetCurrentProjectVersion()
Parse and return current project version
Declaration
public static string GetCurrentProjectVersion()
Returns
Type | Description |
---|---|
String | The version |
Highlight(String, String, HighlightSearchMode)
Highlights an element in the editor for a short period of time.
Declaration
public static void Highlight(string windowTitle, string text, HighlightSearchMode mode = HighlightSearchMode.Auto)
Parameters
Type | Name | Description |
---|---|---|
String | windowTitle | The title of the window the element is inside. |
String | text | The text to identify the element with. |
HighlightSearchMode | mode | Optional mode to specify how to search for the element. |
LoadIcon(String, String, String)
Load an icon regarding skin and editor resolution. Icon should be stored as legacy icon resources:
- "d_" prefix for Professional theme
- "@2x" suffix for high resolution
Declaration
public static Texture2D LoadIcon(string path, string name, string extention = ".png")
Parameters
Type | Name | Description |
---|---|---|
String | path | Path to seek the icon from Assets/ folder |
String | name | Icon name without suffix, prefix or extention |
String | extention | [Optional] Extention of file (png per default) |
Returns
Type | Description |
---|---|
Texture2D | The loaded texture |
RemoveMaterialKeywords(Material)
Remove the keywords on the given materials
Declaration
public static void RemoveMaterialKeywords(Material material)
Parameters
Type | Name | Description |
---|---|---|
Material | material | The material to edit |