{"record":{"id":"a8c437eb32173397","repo":"Unity-Technologies/UnityCsReference","slug":"cannot-find-the-simulatorwindow-type","errorCode":null,"errorMessage":"Cannot find the SimulatorWindow type.","messagePattern":"Cannot find the SimulatorWindow type\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/PlayModeView/PlayModeWindow.cs","lineNumber":93,"sourceCode":"                return PlayModeViewTypes.SimulatorView;\n\n            throw new Exception(\"Unsupported PlayModeView type\");\n        }\n\n        public static void SetViewType(PlayModeViewTypes type)\n        {\n            var view = GetOrCreateWindow();\n            switch (type)\n            {\n                case PlayModeViewTypes.GameView:\n                    view.SwapMainWindow(typeof(GameView));\n                    return;\n                case PlayModeViewTypes.SimulatorView:\n                {\n                    // DeviceSim is a Module that might be disabled in the future.\n                    if (s_SimulatorWindowType == null)\n                    {\n                        throw new Exception(\"Cannot find the SimulatorWindow type.\");\n                    }\n                    view.SwapMainWindow(s_SimulatorWindowType);\n                    return;\n                }\n                default:\n                    throw new Exception(\"Unsupported PlayModeView type\");\n            }\n        }\n\n        static PlayModeView GetOrCreateWindow()\n        {\n            var view = PlayModeView.GetMainPlayModeView();\n            if (view == null)\n            {\n                return EditorWindow.CreateWindow<GameView>();\n            }\n\n            return view;","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/PlayModeView/PlayModeWindow.cs#L75-L111","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Install the Device Simulator package via Package Manager (com.unity.device-simulator).","Before calling SetViewType for SimulatorView, verify the simulator is available — try-catch or check whether the type exists.","Fall back to GameView if the simulator is unavailable: handle the exception and call SetViewType(PlayModeViewTypes.GameView) instead."],"exampleFix":"// before\nPlayModeWindow.SetViewType(PlayModeViewTypes.SimulatorView);\n\n// after\ntry\n{\n    PlayModeWindow.SetViewType(PlayModeViewTypes.SimulatorView);\n}\ncatch (Exception)\n{\n    PlayModeWindow.SetViewType(PlayModeViewTypes.GameView);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    PlayModeWindow.SetViewType(PlayModeViewTypes.SimulatorView);\n}\ncatch (Exception)\n{\n    PlayModeWindow.SetViewType(PlayModeViewTypes.GameView);\n}","preventionTips":["Install the Device Simulator package (com.unity.device-simulator) before requesting SimulatorView.","Wrap SetViewType(SimulatorView) in try-catch and fall back to GameView.","After a domain reload, verify the simulator module is loaded before calling SetViewType."],"tags":["unity-editor","playmode","simulator","module-not-found","missing-dependency"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}