Unity-Technologies/UnityCsReference · error · Exception

Cannot find the SimulatorWindow type.

Error message

Cannot find the SimulatorWindow type.

What it means

Thrown by PlayModeWindow.SetViewType when the caller requests PlayModeViewTypes.SimulatorView but s_SimulatorWindowType is null. The SimulatorWindow type is discovered at runtime via reflection (searching for a type whose name contains 'SimulatorWindow' in the available window types), and it comes from the Device Simulator module which may not be installed or enabled. This guard prevents a NullReferenceException when trying to swap to a non-existent type.

Source

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

                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);
                    return;
                }
                default:
                    throw new Exception("Unsupported PlayModeView type");
            }
        }

        static PlayModeView GetOrCreateWindow()
        {
            var view = PlayModeView.GetMainPlayModeView();
            if (view == null)
            {
                return EditorWindow.CreateWindow<GameView>();
            }

            return view;

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Install the Device Simulator package via Package Manager (com.unity.device-simulator).
  2. Before calling SetViewType for SimulatorView, verify the simulator is available — try-catch or check whether the type exists.
  3. Fall back to GameView if the simulator is unavailable: handle the exception and call SetViewType(PlayModeViewTypes.GameView) instead.

Example fix

// before
PlayModeWindow.SetViewType(PlayModeViewTypes.SimulatorView);

// after
try
{
    PlayModeWindow.SetViewType(PlayModeViewTypes.SimulatorView);
}
catch (Exception)
{
    PlayModeWindow.SetViewType(PlayModeViewTypes.GameView);
}
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    PlayModeWindow.SetViewType(PlayModeViewTypes.SimulatorView);
}
catch (Exception)
{
    PlayModeWindow.SetViewType(PlayModeViewTypes.GameView);
}

Prevention

When it happens

Trigger: Calling PlayModeWindow.SetViewType(PlayModeViewTypes.SimulatorView) when the Device Simulator module is not installed, not enabled, or has not yet been loaded. The static field s_SimulatorWindowType is populated by InitializeSimulatorWindowType which runs on code load — if that hasn't run or found nothing, the type is null.

Common situations: Project without the Device Simulator package installed; simulator module disabled in the project; calling SetViewType before editor initialization completes; after a code reload where InitializeSimulatorWindowType hasn't re-run yet.

Related errors


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