Unity-Technologies/UnityCsReference · error · Exception

Unsupported PlayModeView type

Error message

Unsupported PlayModeView type

What it means

Thrown by PlayModeWindow.GetViewType() when the current main play mode view's runtime type is neither typeof(GameView) nor s_SimulatorWindowType. This is a fallback for an unrecognized window type — normally only GameView and SimulatorWindow exist as valid play mode views. The error indicates the editor has an unexpected or custom PlayModeView subclass as the active main window.

Source

Thrown at Editor/Mono/PlayModeView/PlayModeWindow.cs:77

            GetOrCreateWindow().enterPlayModeBehavior = focused
                ? PlayModeView.EnterPlayModeBehavior.PlayFocused
                : PlayModeView.EnterPlayModeBehavior.PlayMaximized;
        }

        public static bool GetPlayModeFocused()
        {
            return GetOrCreateWindow().enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayFocused;
        }

        public static PlayModeViewTypes GetViewType()
        {
            var type = GetOrCreateWindow().GetType();
            if (type == typeof(GameView))
                return PlayModeViewTypes.GameView;
            if (type == s_SimulatorWindowType)
                return PlayModeViewTypes.SimulatorView;

            throw new Exception("Unsupported PlayModeView type");
        }

        public static void SetViewType(PlayModeViewTypes type)
        {
            var view = GetOrCreateWindow();
            switch (type)
            {
                case PlayModeViewTypes.GameView:
                    view.SwapMainWindow(typeof(GameView));
                    return;
                case PlayModeViewTypes.SimulatorView:
                {
                    // DeviceSim is a Module that might be disabled in the future.
                    if (s_SimulatorWindowType == null)
                    {
                        throw new Exception("Cannot find the SimulatorWindow type.");
                    }
                    view.SwapMainWindow(s_SimulatorWindowType);

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. If using a standard setup, ensure the Device Simulator module is properly installed and loaded so s_SimulatorWindowType initializes correctly.
  2. Avoid swapping to custom PlayModeView subclasses via SwapMainWindow if you need GetViewType() to work — it only recognizes the two built-in types.
  3. Check if the simulator type resolved: if s_SimulatorWindowType is null after a domain reload, trigger PlayModeWindow initialization or restart the editor.
Defensive patterns

Strategy: try-catch

Try / catch

try { var t = PlayModeWindow.GetViewType(); }
catch (Exception) { /* current view is not GameView or SimulatorView; handle gracefully */ }

Prevention

When it happens

Trigger: Calling GetViewType() when the main play mode view is a type other than GameView or SimulatorWindow. This can happen with custom play mode view implementations, or if s_SimulatorWindowType failed to initialize (was null at comparison time) while the actual window is a SimulatorWindow instance.

Common situations: Custom editor extensions that swap the main window to a non-standard PlayModeView subclass; simulator module version mismatch where s_SimulatorWindowType is not resolved yet; code reload scenarios where the static type cache is stale.

Related errors


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