Unity-Technologies/UnityCsReference · warning · NotImplementedException

The DialogOptOut type named {0} has not been implemented.

Error message

The DialogOptOut type named {0} has not been implemented.

What it means

Thrown by the DialogOptOutService.GetDialogOptOutMessage switch when the DialogOptOutDecisionType value is neither ForThisUser nor ForThisSession. This is a defensive default arm: as Unity extends the enum, every unhandled new case surfaces here so the localizable message is never silently wrong. It is a NotImplementedException, signaling incomplete implementation rather than bad input.

Source

Thrown at Editor/Mono/EditorUtility.cs:66

    }

    public partial class EditorUtility
    {
        static class Content
        {
            public static readonly string Cancel = L10n.Tr("Cancel");
            static readonly string k_DialogOptOutForThisMachine = L10n.Tr("Do not show me this message again on this machine.");
            static readonly string k_DialogOptOutForThisSession = L10n.Tr("Do not show me this message again for this session.");
            public static string GetDialogOptOutMessage(DialogOptOutDecisionType dialogOptOutType)
            {
                switch (dialogOptOutType)
                {
                    case DialogOptOutDecisionType.ForThisUser:
                        return k_DialogOptOutForThisMachine;
                    case DialogOptOutDecisionType.ForThisSession:
                        return k_DialogOptOutForThisSession;
                    default:
                        throw new NotImplementedException(string.Format("The DialogOptOut type named {0} has not been implemented.", dialogOptOutType));
                }
            }
        }

        [NoAutoStaticsCleanup] // StringBuilder reuse pool, no user-type references; safe to persist across reload
        private static readonly Stack<StringBuilder> _SbPool = new Stack<StringBuilder>();

        public delegate void SelectMenuItemFunction(object userData, string[] options, int selected);

        [AutoStaticsCleanupOnCodeReload]
        internal static event Action onResetMouseDown;

        public static bool LoadWindowLayout(string path)
        {
            return WindowLayout.TryLoadWindowLayout(path, false);
        }

        public static void CompressTexture(Texture2D texture, TextureFormat format, TextureCompressionQuality quality)

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. If extending DialogOptOutDecisionType, add the new case to all three switches (lines 66, 187, 202) and provide the message and storage behavior.
  2. As a caller, restrict input to the two known enum values; do not cast arbitrary ints.
  3. Treat a NotImplementedException here as a Unity bug to report, not a runtime condition to handle.

Example fix

// before (Unity internal): enum gains ForThisProject, switch unhandled -> throws
// after: add the case
switch (dialogOptOutType) {
  case DialogOptOutDecisionType.ForThisProject:
    return k_DialogOptOutForThisProject;
  ...
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (dialogOptOutType != DialogOptOutDecisionType.ForThisUser && dialogOptOutType != DialogOptOutDecisionType.ForThisSession) { Debug.LogError("Unsupported DialogOptOutDecisionType"); return string.Empty; }

Type guard

static bool IsSupportedDialogOptOut(DialogOptOutDecisionType t) => t == DialogOptOutDecisionType.ForThisUser || t == DialogOptOutDecisionType.ForThisSession;

Try / catch

try { return DialogOptOutService.GetDialogOptOutMessage(t); } catch (NotImplementedException) { return string.Empty; }

Prevention

When it happens

Trigger: A future DialogOptOutDecisionType value is added to the enum but this switch is not updated. Cannot be triggered by user code because the enum is closed and both current values are handled.

Common situations: Internal Unity development when extending the opt-out enum; reflection that fabricates an out-of-range enum value (technically possible but unsupported).

Related errors


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