> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksstyle.md).

# Class ksStyle

Namespace: [KS.Unity.Editor](/reactor/api-reference/ks.unity.editor.md)\
Assembly: KSUnity-Editor.dll

Common styles used in our Unity GUIs.

```csharp
public class ksStyle
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksStyle](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksstyle.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Fields

### BUILD\_GROUP <a href="#ks_unity_editor_ksstyle_build_group" id="ks_unity_editor_ksstyle_build_group"></a>

```csharp
public const int BUILD_GROUP = 200
```

#### Field Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### BUTTON\_WIDTH <a href="#ks_unity_editor_ksstyle_button_width" id="ks_unity_editor_ksstyle_button_width"></a>

```csharp
public const float BUTTON_WIDTH = 200
```

#### Field Value

[float](https://learn.microsoft.com/dotnet/api/system.single)

### HIGHLIGHT\_BLUE <a href="#ks_unity_editor_ksstyle_highlight_blue" id="ks_unity_editor_ksstyle_highlight_blue"></a>

```csharp
public const string HIGHLIGHT_BLUE = "#3172D6"
```

#### Field Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### ICON\_BUTTON\_SIZE <a href="#ks_unity_editor_ksstyle_icon_button_size" id="ks_unity_editor_ksstyle_icon_button_size"></a>

```csharp
public const float ICON_BUTTON_SIZE = 20
```

#### Field Value

[float](https://learn.microsoft.com/dotnet/api/system.single)

### LINE\_HEIGHT <a href="#ks_unity_editor_ksstyle_line_height" id="ks_unity_editor_ksstyle_line_height"></a>

```csharp
public const int LINE_HEIGHT = 20
```

#### Field Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### MAX\_LABEL\_WIDTH <a href="#ks_unity_editor_ksstyle_max_label_width" id="ks_unity_editor_ksstyle_max_label_width"></a>

```csharp
public const float MAX_LABEL_WIDTH = 200
```

#### Field Value

[float](https://learn.microsoft.com/dotnet/api/system.single)

### MISC\_GROUP <a href="#ks_unity_editor_ksstyle_misc_group" id="ks_unity_editor_ksstyle_misc_group"></a>

```csharp
public const int MISC_GROUP = 400
```

#### Field Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### TESTING\_GROUP <a href="#ks_unity_editor_ksstyle_testing_group" id="ks_unity_editor_ksstyle_testing_group"></a>

```csharp
public const int TESTING_GROUP = 300
```

#### Field Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### WINDOW\_GROUP <a href="#ks_unity_editor_ksstyle_window_group" id="ks_unity_editor_ksstyle_window_group"></a>

```csharp
public const int WINDOW_GROUP = 100
```

#### Field Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

## Properties

### EditorBackgroundColor <a href="#ks_unity_editor_ksstyle_editorbackgroundcolor" id="ks_unity_editor_ksstyle_editorbackgroundcolor"></a>

The background color of an editor window.

```csharp
public static Color32 EditorBackgroundColor { get; }
```

#### Property Value

Color32

### HighlightColour <a href="#ks_unity_editor_ksstyle_highlightcolour" id="ks_unity_editor_ksstyle_highlightcolour"></a>

Row highlight colour.

```csharp
public static Color32 HighlightColour { get; }
```

#### Property Value

Color32

### LineColor <a href="#ks_unity_editor_ksstyle_linecolor" id="ks_unity_editor_ksstyle_linecolor"></a>

The color of lines drawn with [Line](#KS_Unity_Editor_ksStyle_Line). Matches the default text color. This color value makes the line appear to match the text color better than using the actual text color from GUI.skin.label.normal.textColor.

```csharp
public static Color32 LineColor { get; }
```

#### Property Value

Color32

### LinkColor <a href="#ks_unity_editor_ksstyle_linkcolor" id="ks_unity_editor_ksstyle_linkcolor"></a>

Color to use for links.

```csharp
public static Color LinkColor { get; }
```

#### Property Value

Color

### MissingPrefabColour <a href="#ks_unity_editor_ksstyle_missingprefabcolour" id="ks_unity_editor_ksstyle_missingprefabcolour"></a>

Colour of missing prefab game object names in the hierarchy window.

```csharp
public static Color32 MissingPrefabColour { get; }
```

#### Property Value

Color32

### PrefabColour <a href="#ks_unity_editor_ksstyle_prefabcolour" id="ks_unity_editor_ksstyle_prefabcolour"></a>

Colour of prefab game object names in the hierarchy window.

```csharp
public static Color32 PrefabColour { get; }
```

#### Property Value

Color32

### SelectionHighlightColour <a href="#ks_unity_editor_ksstyle_selectionhighlightcolour" id="ks_unity_editor_ksstyle_selectionhighlightcolour"></a>

Selected row highlight colour.

```csharp
public static Color32 SelectionHighlightColour { get; }
```

#### Property Value

Color32

### WarningColour <a href="#ks_unity_editor_ksstyle_warningcolour" id="ks_unity_editor_ksstyle_warningcolour"></a>

Colour to use for warning text.

```csharp
public static Color32 WarningColour { get; }
```

#### Property Value

Color32

## Methods

### AlphaNumericTextField(Rect, string) <a href="#ks_unity_editor_ksstyle_alphanumerictextfield_unityengine_rect_system_string" id="ks_unity_editor_ksstyle_alphanumerictextfield_unityengine_rect_system_string"></a>

Creates a text field that only accepts alhpanumeric input (A-Z, a-z, 0-9).

```csharp
public static string AlphaNumericTextField(Rect rect, string text)
```

#### Parameters

`rect` Rect

Rect to draw the input in.

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

Input text

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

Output text

### BrowseButton() <a href="#ks_unity_editor_ksstyle_browsebutton" id="ks_unity_editor_ksstyle_browsebutton"></a>

Creates a browse button with our styling applied.

```csharp
public static bool BrowseButton()
```

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the button was clicked.

### Button(string, Texture2D, string) <a href="#ks_unity_editor_ksstyle_button_system_string_unityengine_texture2d_system_string" id="ks_unity_editor_ksstyle_button_system_string_unityengine_texture2d_system_string"></a>

Creates a button with our styling applied.

```csharp
public static bool Button(string name, Texture2D icon = null, string tooltip = null)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of the button.

`icon` Texture2D

Icon for the button.

`tooltip` [string](https://learn.microsoft.com/dotnet/api/system.string)

Tooltip for the button.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the button was clicked.

### Button(Rect, string, MouseCursor) <a href="#ks_unity_editor_ksstyle_button_unityengine_rect_system_string_unityeditor_mousecursor" id="ks_unity_editor_ksstyle_button_unityengine_rect_system_string_unityeditor_mousecursor"></a>

Creates a button with specific position and mouse cursor.

```csharp
public static bool Button(Rect rect, string name, MouseCursor mouseCursor = MouseCursor.Arrow)
```

#### Parameters

`rect` Rect

position to place the button.

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of the button.

`mouseCursor` MouseCursor

Use arrow mourse cursor by default.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the button was clicked.

### CreateTempContents(string\[]) <a href="#ks_unity_editor_ksstyle_createtempcontents_system_string" id="ks_unity_editor_ksstyle_createtempcontents_system_string"></a>

Creates temp gui contents array from given strings

```csharp
public static GUIContent[] CreateTempContents(string[] texts)
```

#### Parameters

`texts` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]

#### Returns

GUIContent\[]

### Foldout(bool, string) <a href="#ks_unity_editor_ksstyle_foldout_system_boolean_system_string" id="ks_unity_editor_ksstyle_foldout_system_boolean_system_string"></a>

Draws a foldout that works correctly with horizontal scroll bars. Unity's foldouts do not affect the width of horizontal scroll bars and long foldouts will disappear when scrolling enough to the right.

```csharp
public static bool Foldout(bool expanded, string text)
```

#### Parameters

`expanded` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Is the foldout expanded?

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

Foldout text

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the foldout is expanded.

### GetHelpBoxIcon(MessageType) <a href="#ks_unity_editor_ksstyle_gethelpboxicon_unityeditor_messagetype" id="ks_unity_editor_ksstyle_gethelpboxicon_unityeditor_messagetype"></a>

Gets the help box icon for the given message type.

```csharp
public static Texture2D GetHelpBoxIcon(MessageType type)
```

#### Parameters

`type` MessageType

info, warning or error?

#### Returns

Texture2D

### GetInspectorLabelWidth(float) <a href="#ks_unity_editor_ksstyle_getinspectorlabelwidth_system_single" id="ks_unity_editor_ksstyle_getinspectorlabelwidth_system_single"></a>

Gets the width field labels would have in the inspector if it were the given width. The current view width is used if no width is provided. The width of field labels depends on the size of inspector window, but is always a fixed size in other windows. Set EditorGUIUtility.labelWidth to the returned value to make the label width scale with the window width like it does in the inpsector.

```csharp
public static float GetInspectorLabelWidth(float width = 0)
```

#### Parameters

`width` [float](https://learn.microsoft.com/dotnet/api/system.single)

width of window. If zero or less, the current view width is used.

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

Width of labels in the inspector window if it were the given width.

### HelpBox(MessageType, params string\[]) <a href="#ks_unity_editor_ksstyle_helpbox_unityeditor_messagetype_system_string" id="ks_unity_editor_ksstyle_helpbox_unityeditor_messagetype_system_string"></a>

Creates a help box with link text.

```csharp
[Obsolete("Use HelpBoxLink. Link click detection in this function does not work in Unity 6+")]
public static int HelpBox(MessageType type, params string[] linkStrings)
```

#### Parameters

`type` MessageType

info, warning or error?

`linkStrings` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]

{text, url, text, url...} If url is null, the preceding text will not be a link. If it is empty string, clicking the link will not open a url.

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

The index of the clicked link. -1 if no index was clicked.

### HelpBoxLink(MessageType, string, string) <a href="#ks_unity_editor_ksstyle_helpboxlink_unityeditor_messagetype_system_string_system_string" id="ks_unity_editor_ksstyle_helpboxlink_unityeditor_messagetype_system_string_system_string"></a>

Creates a help box with clickable link text. In Unity 6+ the entire link is clickable because the Unity function we use to detect if the mouse is over a link doesn't work.

```csharp
public static bool HelpBoxLink(MessageType type, string text, string url = null)
```

#### Parameters

`type` MessageType

info, warning or error?

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

Text to display in the helpbox. Text surrounded with `<a>` and `</a>` will be shown as a link.

`url` [string](https://learn.microsoft.com/dotnet/api/system.string)

Url to open if the user clicks a link.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the user clicked a link

### Line() <a href="#ks_unity_editor_ksstyle_line" id="ks_unity_editor_ksstyle_line"></a>

Creates a horizontal line.

```csharp
public static void Line()
```

### Link(string, string) <a href="#ks_unity_editor_ksstyle_link_system_string_system_string" id="ks_unity_editor_ksstyle_link_system_string_system_string"></a>

Creates a link.

```csharp
public static bool Link(string text, string url)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

text showing for the link.

`url` [string](https://learn.microsoft.com/dotnet/api/system.string)

url of the link.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the link was clicked.

### Link(Vector2, string, string) <a href="#ks_unity_editor_ksstyle_link_unityengine_vector2_system_string_system_string" id="ks_unity_editor_ksstyle_link_unityengine_vector2_system_string_system_string"></a>

Creates a link.

```csharp
public static bool Link(Vector2 position, string text, string url)
```

#### Parameters

`position` Vector2

position to place the link.

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

text showing for the link.

`url` [string](https://learn.microsoft.com/dotnet/api/system.string)

url of the link.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the link was clicked.

### NumericOverrideField(SerializedProperty, object, string, string) <a href="#ks_unity_editor_ksstyle_numericoverridefield_unityeditor_serializedproperty_system_object_system_str" id="ks_unity_editor_ksstyle_numericoverridefield_unityeditor_serializedproperty_system_object_system_str"></a>

Creates an int or float field with a checkbox. When the value is less than zero, the checkbox is unchecked and the numeric field box is hidden. Checking the checkbox will show the numeric field box and set the value to `defaultValue`.

```csharp
public static void NumericOverrideField(SerializedProperty property, object defaultValue, string tooltip = null, string displayName = null)
```

#### Parameters

`property` SerializedProperty

The numeric property to create the field for.

`defaultValue` [object](https://learn.microsoft.com/dotnet/api/system.object)

The default value to set when the checkbox is checked.

`tooltip` [string](https://learn.microsoft.com/dotnet/api/system.string)

Optional tooltip

`displayName` [string](https://learn.microsoft.com/dotnet/api/system.string)

Optional display name

### OptionsButton() <a href="#ks_unity_editor_ksstyle_optionsbutton" id="ks_unity_editor_ksstyle_optionsbutton"></a>

Draws an options button with 3 vertical dots.

```csharp
public static bool OptionsButton()
```

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the button was clicked.

### OptionsButton(Vector2) <a href="#ks_unity_editor_ksstyle_optionsbutton_unityengine_vector2" id="ks_unity_editor_ksstyle_optionsbutton_unityengine_vector2"></a>

Draws an options button with 3 vertical dots.

```csharp
public static bool OptionsButton(Vector2 position)
```

#### Parameters

`position` Vector2

Position of the top left corner of the button.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the button was clicked.

### OptionsButton(Rect) <a href="#ks_unity_editor_ksstyle_optionsbutton_unityengine_rect" id="ks_unity_editor_ksstyle_optionsbutton_unityengine_rect"></a>

Draws an options button with 3 vertical dots.

```csharp
public static bool OptionsButton(Rect rect)
```

#### Parameters

`rect` Rect

Rectangle to draw button in.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the button was clicked.

### PasswordField(Rect, string, string) <a href="#ks_unity_editor_ksstyle_passwordfield_unityengine_rect_system_string_system_string" id="ks_unity_editor_ksstyle_passwordfield_unityengine_rect_system_string_system_string"></a>

Creates a password field with specific position and place holder string.

```csharp
public static string PasswordField(Rect rect, string text, string placeholder = "")
```

#### Parameters

`rect` Rect

position to place the password field.

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

text showing in the password field.

`placeholder` [string](https://learn.microsoft.com/dotnet/api/system.string)

empty string by default.

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

password in this password field

### ProjectSelector\<T>(string, T, List\<T>, Action, Action\<T>) <a href="#ks_unity_editor_ksstyle_projectselector__1_system_string___0_system_collections_generic_list___0__sy" id="ks_unity_editor_ksstyle_projectselector__1_system_string___0_system_collections_generic_list___0__sy"></a>

Creates email/logout and project selector buttons.

```csharp
public static void ProjectSelector<T>(string email, T project, List<T> projects, Action logoutCallback, Action<T> selectProjectCallback) where T : ksProjectInfo
```

#### Parameters

`email` [string](https://learn.microsoft.com/dotnet/api/system.string)

The user's email account

`project` T

Selected project

`projects` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)\<T>

List of projects

`logoutCallback` [Action](https://learn.microsoft.com/dotnet/api/system.action)

Callback to call when the user logsout.

`selectProjectCallback` [Action](https://learn.microsoft.com/dotnet/api/system.action-1)\<T>

Callback to call when the user selects a project.

#### Type Parameters

`T`

Project type

### TextField(Rect, string, string) <a href="#ks_unity_editor_ksstyle_textfield_unityengine_rect_system_string_system_string" id="ks_unity_editor_ksstyle_textfield_unityengine_rect_system_string_system_string"></a>

Creates a text field with specific position and place holder string.

```csharp
public static string TextField(Rect rect, string text, string placeholder = "")
```

#### Parameters

`rect` Rect

position to place the text field.

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

text showing in the text field.

`placeholder` [string](https://learn.microsoft.com/dotnet/api/system.string)

empty string by default.

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

text in this text field

### TitleFoldout(bool, string) <a href="#ks_unity_editor_ksstyle_titlefoldout_system_boolean_system_string" id="ks_unity_editor_ksstyle_titlefoldout_system_boolean_system_string"></a>

Creates a bolded title foldout with our styling applied.

```csharp
public static bool TitleFoldout(bool expanded, string text)
```

#### Parameters

`expanded` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Is the foldout expanded?

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

Foldout text

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the foldout is expanded.

### Toggle(Rect, string, bool, float) <a href="#ks_unity_editor_ksstyle_toggle_unityengine_rect_system_string_system_boolean_system_single" id="ks_unity_editor_ksstyle_toggle_unityengine_rect_system_string_system_boolean_system_single"></a>

Creates a toggle with specific position and checkbox Width.

```csharp
public static bool Toggle(Rect rect, string text, bool isChecked, float checkboxWidth)
```

#### Parameters

`rect` Rect

position to place the toggle.

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

text showing on the label.

`isChecked` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Is the toggle checked?

`checkboxWidth` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

if checkbox is checked

### TrimToFit(string, GUIStyle, float) <a href="#ks_unity_editor_ksstyle_trimtofit_system_string_unityengine_guistyle_system_single" id="ks_unity_editor_ksstyle_trimtofit_system_string_unityengine_guistyle_system_single"></a>

If the `text` does not fit within `maxWidth`, trims characters off the end and appends "..." until it fits.

```csharp
public static string TrimToFit(string text, GUIStyle style, float maxWidth)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

Text to trim to fit within `maxWidth`.

`style` GUIStyle

Style the text will be rendered with.

`maxWidth` [float](https://learn.microsoft.com/dotnet/api/system.single)

Maximum width of the text.

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

Trimmed text

### WordWrapLabel(string) <a href="#ks_unity_editor_ksstyle_wordwraplabel_system_string" id="ks_unity_editor_ksstyle_wordwraplabel_system_string"></a>

Creates a word-wrapped label.

```csharp
public static void WordWrapLabel(string text)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

Text for the label.
