Implementation references

Scripting API and implementation references.

Scripting API
EditorUtility.
DisplayDialog
Native OS dialog with 2 buttons
HelpBox
Reference for a help box in UI Toolkit.

Overview

 Illustration showing four Editor message types that include dialog modals, window banners, help boxes and console Logs
There are four key expression types for messages in the Editor

Unity Editor includes these message expression types:

Errors and other types of alerts are used to communicate conditions, indicate an event, or show responses to user actions. They can be expressed with dialogs (pop-up modals), window banners,
help boxes, or console and status logs.

  • Messages are alerts that identify problems, suggest fixes, and provide information to the user
  • Most messages comes in three varieties: Error messages, warning messages, and informative messages (log messages)
  • Message contents are usually composed of three parts: the problem, the cause, and the solution
  • Message language should always be polite, precise, and constructive
  • For errors and warnings, provide a likely workaround solution that the user can use to fix the issue

Message types

Error messages

A critical error message displayed in a help box.
  1. Indicates a function will not complete an action
  2. Use errors for situations where Unity can not recover or proceed normally
  3. Error messages in the console are themed red

Warning messages

A warning message displayed in a help box.
  1. Indicates a function that will complete an action but may return results that are not what the user intended
  2. Use warnings for situations where Unity can recover/proceed, but users may be unaware of the side effects
  3. Warning messages in the console are themed yellow

Informational (log) messages

An informative message displayed in a help box.
  1. Used for communicating non-critical information
  2. Can provide helpful advice that is not essential to the operation
  3. Shares similarities to Tooltips
  4. Sometimes referred to as a log message

Message theming

Color use

Illustrations of color usage showing red text and octagon icon for an error status message, yellow text and triangle icon for a warning status message, and white text and speech bubble icon for log status message
Examples of color use for error, warning, and log messages
Feedback icon colors
Icon of a red triangle to indicate a message of warning.
Intended for icons only
The icon color palette below is intended to be used for icon colors only. Do not use these colors in brand / product design implementations.
White
Primarily for icons that need to change color on a selected state.
#F0F0F0
#F0F0F0
Yellow
Primarily for suggesting warning states and messages.
#C99700
#FFC107
Scarlet
Primarily for suggesting error states and messages.
#B10C0C
#FF534A
Status message text colors
Default Text
The default text color
#090909
#D2D2D2
Error Text
The text color for error messages
#5A0000
#D32222
Warning Text
The text color for warning messages
#333308
#F4BC02
Help box colors
Helpbox Background
--unity-colors-helpbox-background
The background color for a helpbox control
rgba(235, 235, 235, 0.2039216)
rgba(96, 96, 96, 0.2039216)
Helpbox Border
--unity-colors-helpbox-border
The border color for a helpbox control
#A9A9A9
#232323
Helpbox Text
--unity-colors-helpbox-text
The text color for a helpbox control
#161616
#BDBDBD

Icon use

Illustration showing icons for errors, warnings and info messages in three themes: dark, mono, and light.
Error, warning and info (log) message icons in dark, mono, and light themes.
Red octagonal icon with white exclamation mark inside indicating an error

Error icon: Represented by a red octagonal warning icon with an exclamation mark

Yellow triangular icon with exclamation mark inside indicating a warning

Warning icon: Represented by a yellow triangle warning icon with an exclamation mark

White speech bubble icon with exclamation mark inside indicating information or a log

Info (log) icon: Represented by a white speech bubble icon with an exclamation mark

Content best practices

Content overview

Well written alert messages should be:

Human-readable

Messages should use the plainest possible language that can clearly convey the message. Avoid obscure codes, abbreviations, and technical jargon. Ideally, a beginner-level user of the feature should be able to understand the alert message.

Concise

Only include the information the user needs to understand and resolve the immediate problem.

Polite

Alert messages should not be written in a negative voice that blames users for incorrect usage but in a positive or neutral voice. Avoid phrases like "illegal command".

Problem / cause / solution

All error and warning messages relating to a specific problem should include these three key elements, in this order:

The problem

Ensure the problem is clearly identified in plain language.

The cause

Where possible include the cause of the problem so that the message not only helps correct this particular instance of a problem, but becomes a teachable moment that helps prevent future mistakes.

The solution

Recommend constructive advice on how to fix the problem.

Message content

Do recommendation illustrated by a green checkbox icon

Do include any phrasing that specifically relates to that error so users can look up that exact problem on a search engine using precise wording.

Don't recommendation illustrated by a red X icon

Don't use vague wording such as "syntax error".

Don't recommendation illustrated by a red X icon

Don't begin the error or warning message with “Error” or “Warning” as the color styling and associated icon makes this wording redundant.

Examples

Incorrect
Correct
Breakdown
"Cannot load textures."
"Unity cannot run the application, because it cannot load the textures. Refresh the textures and re-launch the application."
Problem: Unity cannot run the application.

Cause: Because it cannot load the textures.

Solution: Refresh the textures and re-launch the application.
"Warning: using safe fallback for shader "yourShaderName" as it is not compatible with the VGPR ABI requirements of one or more used instance shaders, this could cause poor performance so consider using "#pragma platform_call_register_window <n>" in the ray generation shader."
"Unity is using a safe fallback shader for "yourShaderName", because the shader in your build is not compatible with the VGPR ABI requirements of one or more of the used instance shaders. To reduce performance impact, use "#pragma platform_call_register_window <n>" in the ray generation shader instead."
Problem: Unity is using a safe fallback shader for "yourShaderName".

Cause: Because the shader in your build is not compatible with the VGPR ABI requirements of one or more of the used instance shaders.

Solution: To reduce performance impact, use "#pragma platform_call_register_window <n>" in the ray generation shader instead.
"You have entered an invalid file name."
"This file name is invalid. File names can only contain alphanumeric characters."
Problem: This file name is invalid.

Cause: File names can only contain alphanumeric characters.

Solution: Please enter an alphanumeric file name.

Expression types

Dialogs (pop up modals)

Illustration of a dialog pop up
Dialogs are messages that affect the entirety of the Editor
Plastic SCM requesting user input with a two button macOS 11 dialog

Dialogs are messages that present a short-term task the user must perform to continue the operation. Users won't be able to interact with the Editor until the dialog is closed.

  1. The Editor displays the operating system dialog by default
  2. Dialogs are invasive and should be used sparingly
  3. Dialogs should be reserved to be used when a response is required, such as critical messages, interruptive actions or destructive outcomes, eg. saving the project before quitting
  4. Dialogs can have one, two, or three buttons. Dialogs with only the ok button should only be used for displaying specific user decision, or acknowledgement
  5. Avoid complex options that require information unavailable in the dialog
  6. Alternatively referred to as pop-up modals
  7. Option labels should be a verb or verb phrase, to indicate the action being taken when the button is clicked
  8. Dialogs should have an opt-out from displaying option if they might be shown repeatedly
Dialog with two and three buttons
Screen captures of dialogs displaying  three buttons and two buttons.
Dialogs with three and two buttons as displayed in macOS 12.

Editor displays the native OS dialog window

Scripting API
EditorUtility.
DisplayDialog
Dialog with 2 buttons
EditorUtility.
DisplayDialogComplex
Dialog with 3 buttons
  1. Dialogs with two buttons ok / cancel are displayed with EditorUtility.DisplayDialog method
  2. Dialogs with three buttons ok / alt / cancel are displayed with EditorUtility.DisplayDialogComplex method

Do not show again

For dialog boxes that might be shown repeatedly, consider using an overload of this method that takes a DialogOptOutDecisionType

Button options

  1. Dialogs can have ok, cancel and alt buttons.
  2. The ok button is the default option, and can also be activated by pressing Enter.
  3. The cancel button is considered the "cancel" action and should usually not perform any action besides closing the dialog.
  4. The cancel option is not set by default. If not set, only the ok button is displayed.

Button order in dialogs

OS dialogs in macOS 12 / macOS 11 and Win 8 have different button orders.

Editor displays the native operating system dialog

Icon of a red triangle to indicate a message of warning.
Button order in dialogs is dependant on the operating system.
Note that Editor API will automatically display the operating systems default button order.
  1. On macOS 12, button order is ok / alt / cancel
  2. On macOS 11, button order is alt / cancel / ok
  3. On Windows, button order is ok / alt / cancel

Window banners

Illustration of a window banner
Window banners are messages that affect the entirety of the active window.
UI Builder message indicates that Editor-only controls are now activated.

Window banners are used to provide brief feedback about an operation that affects the entire active window. They are used for informative purposes and are not persistent on the screen.

Window banners are rendered via the function EditorWindow.ShowNotification in the affected interface.

  1. Window banners automatically fade-out after some time. (Default duration is 4 seconds)
  2. Window banner size is responsive to the window size
  3. Window banners are displayed in the lower half of the window
  4. Avoid using window banners to describe edge cases

Message duration

  1. Default message duration is 4 seconds
  2. Use fadeoutWait parameter to adjust the duration the notification is displayed. Measured in seconds
  3. Duration should be based on the length of message content

Section messages (help boxes)

Illustration of a help box
Help boxes affect only a section of the affected window
Shader channels displaying a warning helpbox

Section messages (help boxes) are used to alert the user of something that happened in a specific section of an Editor window, such as a property setting.

They appear as help boxes in the affected interface.

  1. They appear below the affected area (for example a property in the Inspector window)
  2. Help boxes shift the content below it
  3. Avoid using Help Boxes to describe edge cases
  4. Avoid using Help Boxes for documentation
API in

UI Toolkit

HelpBox
Reference for a help box.
API in

IMGUI

EditorGUI.HelpBox
Reference for a help box.

Console and status logs

Illustration of a console window displaying console messages
Console window logs all console messages, and status message shows the latest log
Console window displaying console logs, and an error status message

Console messages are important messages that help users with debugging the application / issue and to log important messages in the console.

  1. Are easily understood
  2. Are informative on what happened or caused the message to appear
  3. Contain identifying information in the message
  1. Debug.Log is used to log messages to the Unity Console
  2. Debug.LogWarning is used to warning messages to the Unity Console
  3. Debug.LogError is used to error messages to the Unity Console

Console logs

  1. Console window uses toolbar toggles to hide / show different message types for easier tracking / resolving
  2. Time stamps are added automatically / on time the message is first logged
  3. You can format messages with string concatenation Debug.Log("Text: " + myText.text);
  4. You can also use Rich Text markup
  5. Call stack information should be given in the message for easier debugging

Status messages

  1. Latest console message is displayed in the bottom of the editor in a single line as a status message, and when clicked it opens the Console window

Assigning an object

Use context parameter to set the object which the message applies to.

If you pass a GameObject or Component as the optional context argument, the object will highlight in the Hierarchy window when you click the log message in the Console.

Which type to use

 Illustration showing four Editor message types that include dialog modals, window banners, help boxes and console Logs
 1. Dialog Modals 2. Window Banners 3. Help Boxes 4. Console Logs

Scale and location

  • If the message prevents the user from continuing until a choice or an action is made, use dialogs
  • If the message is a confirmation or an acknowledgment that requires minimal user interaction, use a window banner
  • If the message is about a property or a control in the window, use a help box
  • If the message is operational to the Editor, it should be logged as a console log

Severity: Is it critical? Does it disrupt the user flow?

  • If the message presents a short-term task the user must perform to continue the operation, use dialogs
  • If the message is not critical, use an info (log) message type
  • If the message is critical, use error or warning messages types based on the severity of the issue

Layout

  • When working in high-density layouts, do not disrupt the vertical layout of the interface
  • Help boxes are displayed after its related controls / layout
  • Help boxes shift the content below it
  • Use window banners to give informative messages about the active window

Persistence

  • If the message relates to a task that the user needs to perform, use a dialog
  • If the message needs to appear to inform the user of a non-disruptive event or give brief feedback, use window banners that disappear overtime
  • If the message needs to stay visible until it is resolved, and relates to a specific section or control, use a help box
  • Persistent messages need to be logged in the console if they affect larger operations

Resources

Kits, tools, libraries, and documentation to guide users through creating for the Editor.