Unity-Technologies/UnityCsReference · error · NotImplementedException

Unknown dialog icon type

Error message

Unknown dialog icon type

What it means

Thrown by EditorDialog's icon→LogType mapping helper in the default branch of its switch on DialogIconType. The switch covers Info, Warning, and Error — the three defined members of DialogIconType — so the default is currently unreachable through valid enum values. NotImplementedException guards against a future icon type being added without updating the log mapping.

Source

Thrown at Editor/Mono/EditorDialog.cs:172

            {
                // If we're cutting off a high surrogate, we need to include the low surrogate as well.
                truncationLength--;
            }

            LogType logType;
            switch (iconType)
            {
                case DialogIconType.Info:
                    logType = LogType.Log;
                    break;
                case DialogIconType.Warning:
                    logType = LogType.Warning;
                    break;
                case DialogIconType.Error:
                    logType = LogType.Error;
                    break;
                default:
                    throw new NotImplementedException("Unknown dialog icon type");
            }

            // Print markdown of the entire dialog to the log.
            // e.g. # Title
            //
            //      Message that spans multiple lines
            //
            //      | Button1 | Button2 |
            Debug.LogFormat(logType, LogOption.NoStacktrace, null, "# {0}\n\n{1}\n\n| {2} |\n", titleText, messageText.Trim(), string.Join(" | ", buttons));

            return messageText.Substring(0, truncationLength) + truncationMessage;
        }

        private static void ThrowIfInvalidKey(string optOutKey)
        {
            // We want to ensure that the key string is a valid XML tag.
            // More technically, we could restrict it to whichever is more restrictive of
            // XML tags (Linux), Windows Registry key names, or NSPreference dictionaries

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Validate with Enum.IsDefined(typeof(DialogIconType), iconType) before calling the dialog API.
  2. Use only the named DialogIconType constants.
  3. If extending the enum, add the new case to this switch.
Defensive patterns

Strategy: validation

Validate before calling

if (!Enum.IsDefined(typeof(DialogIconType), iconType))
    throw new ArgumentOutOfRangeException(nameof(iconType));

Type guard

static bool IsKnownIcon(DialogIconType i) =>
    i == DialogIconType.Info || i == DialogIconType.Warning || i == DialogIconType.Error;

Prevention

When it happens

Trigger: Passing a DialogIconType value that is not Info/Warning/Error — only via an invalid int cast like (DialogIconType)99, since the enum defines exactly those three members.

Common situations: Reflection/serialization reconstructing the enum from an arbitrary int; a future Unity version adding a new icon type; misuse via unsafe casting.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/8511b445bfa49d70. Report an issue: GitHub.