{"record":{"id":"5a277695325171f9","repo":"Unity-Technologies/UnityCsReference","slug":"cannot-be-null-or-empty","errorCode":null,"errorMessage":"Cannot be null or empty","messagePattern":"Cannot be null or empty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/SceneView/SceneView.cs","lineNumber":4635,"sourceCode":"                LookAt(pivot, lastSceneViewRotation, size, m_LastSceneViewOrtho);\n                if (Tools.current == Tool.Rect)\n                    Tools.current = Tool.Move;\n            }\n\n            // Let's not persist the vertex snapping mode on 2D/3D mode change\n            HandleUtility.ignoreRaySnapObjects = null;\n            Tools.vertexDragging = false;\n            Tools.handleOffset = Vector3.zero;\n\n            var gridSettings = GridSettings.instance;\n            gridSettings.rotation = Quaternion.identity;\n            gridSettings.position = Vector3.zero;\n        }\n\n        public static CameraMode AddCameraMode(string name, string section)\n        {\n            if (string.IsNullOrEmpty(name))\n                throw new ArgumentException(\"Cannot be null or empty\", \"name\");\n            if (string.IsNullOrEmpty(section))\n                throw new ArgumentException(\"Cannot be null or empty\", \"section\");\n            var newMode = new CameraMode(DrawCameraMode.UserDefined, name, section);\n            if (userDefinedModes.Contains(newMode))\n                throw new InvalidOperationException(string.Format(\"A mode named {0} already exists in section {1}\", name, section));\n            userDefinedModes.Add(newMode);\n            return newMode;\n        }\n\n        private static bool IsValidCameraMode(CameraMode cameraMode)\n        {\n            foreach (var mode in Enum.GetValues(typeof(DrawCameraMode)))\n            {\n                if (SceneRenderModeWindow.DrawCameraModeExists((DrawCameraMode)mode) && cameraMode == GetBuiltinCameraMode((DrawCameraMode)mode))\n                {\n                    return true;\n                }\n            }","sourceCodeStart":4617,"sourceCodeEnd":4653,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/SceneView/SceneView.cs#L4617-L4653","documentation":"Thrown by SceneView.AddCameraMode when the name parameter is null or empty. A custom camera mode requires a non-empty display name to appear in the scene view draw mode dropdown. This is the first of two guards in AddCameraMode (name, then section).","triggerScenarios":"Calling SceneView.AddCameraMode with an empty string or null for name. Programmatic mode creation where the name is derived from user input or config that can be empty.","commonSituations":"Editor extension that registers custom draw modes based on configurable names. Data-driven mode registration where a config entry is missing the name field.","solutions":["Provide a non-empty, non-null name string.","Validate the name with string.IsNullOrEmpty before calling AddCameraMode.","Use a sensible default name if the source value is empty."],"exampleFix":"// before\nSceneView.AddCameraMode(modeName, \"Custom\");\n\n// after\nstring name = string.IsNullOrEmpty(modeName) ? \"UnnamedMode\" : modeName;\nSceneView.AddCameraMode(name, \"Custom\");","handlingStrategy":"validation","validationCode":"bool IsValidModeName(string name)\n{\n    return !string.IsNullOrEmpty(name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the name parameter with string.IsNullOrEmpty before calling AddCameraMode.","Provide a sensible default name when the source value is empty."],"tags":["unity","scene-view","editor","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}