Class CoreEditorUtils
Utility class for Editor
Inherited Members
Namespace: UnityEditor.Rendering
Assembly: Unity.RenderPipelines.Core.Editor.dll
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(bool, Object)
Checks out a file from the Version Control System if VCS is enabled.
Declaration
public static void CheckOutFile(bool VCSEnabled, Object mat)
Parameters
Type | Name | Description |
---|---|---|
bool | VCSEnabled | A boolean value determining whether Version Control System is enabled or not. |
Object | mat | The UnityObject to be checked out from the Version Control System. |
ColorFieldLinear(SerializedProperty, GUIContent)
Draw a Color Field but convert the color to gamma space before displaying it in the shader. Using SetColor on a material does the conversion, but setting the color as vector3 in a constant buffer doesn't So we have to do it manually, doing it in the UI avoids having to do a migration step for existing fields
Declaration
public static void ColorFieldLinear(SerializedProperty property, GUIContent label)
Parameters
Type | Name | Description |
---|---|---|
SerializedProperty | property | The color property |
GUIContent | label | The label |
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, params 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(Rect, Enum) 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 | The type of Enum that the drop down menu will contain. |
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. |
DrawFoldoutEndSplitter(bool)
Draw a splitter separator which is used after drawing a fouldout header.
Declaration
public static void DrawFoldoutEndSplitter(bool isBoxed = false)
Parameters
Type | Name | Description |
---|---|---|
bool | isBoxed | [Optional] add margin if the splitter is boxed |
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, bool, bool, Func<bool>, Action, bool, string, Action<Vector2>, Action<GenericMenu>)
Draw a foldout header
Declaration
public static bool DrawHeaderFoldout(string title, bool state, bool isBoxed = false, Func<bool> hasMoreOptions = null, Action toggleMoreOption = null, bool isTitleHeader = false, string documentationURL = "", Action<Vector2> contextAction = null, Action<GenericMenu> customMenuContextAction = null)
Parameters
Type | Name | Description |
---|---|---|
string | title | The title of the header |
bool | state | The state of the header |
bool | isBoxed | [optional] is the header contained in a box style ? |
Func<bool> | 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. |
bool | isTitleHeader | [optional] is this a title header, this setting controls the color used for the foldout |
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. |
Action<GenericMenu> | customMenuContextAction | [optional] Delegate which adds items to a generic menu when the user presses the burger menu on the header. |
Returns
Type | Description |
---|---|
bool | return the state of the foldout header |
DrawHeaderFoldout(GUIContent, bool, bool, Func<bool>, Action, bool, string, Action<Vector2>, Action<GenericMenu>)
Draw a foldout header
Declaration
public static bool DrawHeaderFoldout(GUIContent title, bool state, bool isBoxed = false, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null, bool isTitleHeader = false, string documentationURL = "", Action<Vector2> contextAction = null, Action<GenericMenu> customMenuContextAction = null)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | The title of the header |
bool | state | The state of the header |
bool | isBoxed | [optional] is the eader contained in a box style ? |
Func<bool> | 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. |
bool | isTitleHeader | [optional] is this a title header, this setting controls the color used for the foldout |
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. |
Action<GenericMenu> | customMenuContextAction | [optional] Delegate which adds items to a generic menu when the user presses the burger menu on the header. |
Returns
Type | Description |
---|---|
bool | return the state of the foldout header |
DrawHeaderFoldout(Rect, GUIContent, bool, bool, Func<bool>, Action, bool, string, Action<Vector2>, Action<GenericMenu>)
Draw a foldout header
Declaration
public static bool DrawHeaderFoldout(Rect backgroundRect, GUIContent title, bool state, bool isBoxed = false, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null, bool isTitleHeader = false, string documentationURL = "", Action<Vector2> contextAction = null, Action<GenericMenu> customMenuContextAction = null)
Parameters
Type | Name | Description |
---|---|---|
Rect | backgroundRect | The rect |
GUIContent | title | The title of the header |
bool | state | The state of the header |
bool | isBoxed | [optional] is the eader contained in a box style ? |
Func<bool> | 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. |
bool | isTitleHeader | [optional] is this a title header, this setting controls the color used for the foldout |
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. |
Action<GenericMenu> | customMenuContextAction | [optional] Delegate which adds items to a generic menu when the user presses the burger menu on the header. |
Returns
Type | Description |
---|---|
bool | return the state of the foldout header |
DrawHeaderToggle(string, SerializedProperty, SerializedProperty, Action<Vector2>, Func<bool>, Action, string, Action<GenericMenu>, bool, bool, bool)
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, string documentationURL = null, Action<GenericMenu> customMenuContextAction = null, bool isBoxed = false, bool isTitleHeader = false, bool shouldUpdate = true)
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<bool> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
string | documentationURL | Documentation URL |
Action<GenericMenu> | customMenuContextAction | Delegate which adds items to a generic menu. |
bool | isBoxed | States if the header toggle should be boxed. |
bool | isTitleHeader | [optional] is this a title header, this setting controls the color used for the foldout |
bool | shouldUpdate | States if the group and active field should update before usage and apply changes to them. |
Returns
Type | Description |
---|---|
bool | return the state of the foldout header |
DrawHeaderToggle(GUIContent, SerializedProperty, SerializedProperty, Action<Vector2>, Func<bool>, Action, string, Action<GenericMenu>, bool, bool, bool)
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, string documentationURL = null, Action<GenericMenu> customMenuContextAction = null, bool isBoxed = false, bool isTitleHeader = false, bool shouldUpdate = true)
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<bool> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
string | documentationURL | Documentation URL |
Action<GenericMenu> | customMenuContextAction | Delegate which adds items to a generic menu. |
bool | isBoxed | States if the header toggle should be boxed. |
bool | isTitleHeader | [optional] is this a title header, this setting controls the color used for the foldout |
bool | shouldUpdate | States if the group and active field should update before usage and apply changes to them. |
Returns
Type | Description |
---|---|
bool | return the state of the foldout header |
DrawHeaderToggleFoldout(GUIContent, bool, SerializedProperty, Action<Vector2>, Func<bool>, Action, string)
Draw a header toggle like in Volumes
Declaration
public static bool DrawHeaderToggleFoldout(GUIContent title, bool foldoutExpanded, SerializedProperty toggleProperty, Action<Vector2> contextAction, Func<bool> hasMoreOptions, Action toggleMoreOptions, string documentationURL)
Parameters
Type | Name | Description |
---|---|---|
GUIContent | title | The title of the header |
bool | foldoutExpanded | If the foldout is expanded |
SerializedProperty | toggleProperty | The property to bind the toggle |
Action<Vector2> | contextAction | The context action |
Func<bool> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
string | documentationURL | Documentation URL |
Returns
Type | Description |
---|---|
bool | 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 | A valid struct |
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<bool>, 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<bool> | hasMoreOptions | Delegate saying if we have MoreOptions |
Action | toggleMoreOptions | Callback called when the MoreOptions is toggled |
DrawSplitter(bool)
Draw a splitter separator
Declaration
public static void DrawSplitter(bool isBoxed = false)
Parameters
Type | Name | Description |
---|---|---|
bool | isBoxed | [Optional] add margin if the splitter is boxed |
DrawSplitter(Rect, bool)
Draw a splitter separator
Declaration
public static void DrawSplitter(Rect rect, bool isBoxed = false)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect | The rect where to draw the splitter |
bool | isBoxed | [Optional] add margin if the splitter is boxed |
DrawSubHeaderFoldout(string, bool, bool)
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 |
bool | state | The state of the header |
bool | isBoxed | [optional] is the eader contained in a box style ? |
Returns
Type | Description |
---|---|
bool | return the state of the sub foldout header |
DrawSubHeaderFoldout(string, bool, bool, Func<bool>, 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 |
bool | state | The state of the header |
bool | isBoxed | [optional] is the eader contained in a box style ? |
Func<bool> | 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 |
---|---|
bool | return the state of the sub foldout header |
DrawSubHeaderFoldout(GUIContent, bool, bool)
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 |
bool | state | The state of the header |
bool | isBoxed | [optional] is the eader contained in a box style ? |
Returns
Type | Description |
---|---|
bool | return the state of the sub foldout header |
DrawSubHeaderFoldout(GUIContent, bool, bool, Func<bool>, 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 |
bool | state | The state of the header |
bool | isBoxed | [optional] is the eader contained in a box style ? |
Func<bool> | 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 |
---|---|
bool | return the state of the foldout header |
DrawVector6(GUIContent, SerializedProperty, SerializedProperty, Vector3, Vector3, Color[], SerializedProperty, bool)
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 |
bool | 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 |