{"record":{"id":"f651427a54fff785","repo":"Unity-Technologies/UnityCsReference","slug":"unsupported-playmodeview-type","errorCode":null,"errorMessage":"Unsupported PlayModeView type","messagePattern":"Unsupported PlayModeView type","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/PlayModeView/PlayModeWindow.cs","lineNumber":77,"sourceCode":"            GetOrCreateWindow().enterPlayModeBehavior = focused\n                ? PlayModeView.EnterPlayModeBehavior.PlayFocused\n                : PlayModeView.EnterPlayModeBehavior.PlayMaximized;\n        }\n\n        public static bool GetPlayModeFocused()\n        {\n            return GetOrCreateWindow().enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayFocused;\n        }\n\n        public static PlayModeViewTypes GetViewType()\n        {\n            var type = GetOrCreateWindow().GetType();\n            if (type == typeof(GameView))\n                return PlayModeViewTypes.GameView;\n            if (type == s_SimulatorWindowType)\n                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);","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/PlayModeView/PlayModeWindow.cs#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["If using a standard setup, ensure the Device Simulator module is properly installed and loaded so s_SimulatorWindowType initializes correctly.","Avoid swapping to custom PlayModeView subclasses via SwapMainWindow if you need GetViewType() to work — it only recognizes the two built-in types.","Check if the simulator type resolved: if s_SimulatorWindowType is null after a domain reload, trigger PlayModeWindow initialization or restart the editor."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var t = PlayModeWindow.GetViewType(); }\ncatch (Exception) { /* current view is not GameView or SimulatorView; handle gracefully */ }","preventionTips":["Avoid swapping the main window to non-standard PlayModeView subclasses if you need GetViewType() support.","Ensure the Device Simulator module is installed so s_SimulatorWindowType initializes correctly.","Be aware GetViewType only recognizes GameView and SimulatorWindow."],"tags":["unity-editor","playmode","simulator","type-validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}