{"record":{"id":"35929222695a4ce7","repo":"stride3d/stride","slug":"unable-to-attach-camera-camera-entity-name-to-the-graphics","errorCode":null,"errorMessage":"Unable to attach camera [{camera.Entity.Name}] to the graphics compositor. Another camera, [{slot.Camera.Entity.Name}], is enabled and already attached to this slot.","messagePattern":"Unable to attach camera \\[(.+?)\\] to the graphics compositor\\. Another camera, \\[(.+?)\\], is enabled and already attached to this slot\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Engine/Processors/CameraProcessor.cs","lineNumber":140,"sourceCode":"        }\n\n        private void OnCameraSlotsChanged(object sender, ref FastTrackingCollectionChangedEventArgs e)\n        {\n            cameraSlotsDirty = true;\n        }\n\n        private void AttachCameraToSlot(GraphicsCompositor graphicsCompositor, CameraComponent camera)\n        {\n            if (!camera.Enabled) throw new InvalidOperationException($\"The camera [{camera.Entity.Name}] is disabled and can't be attached\");\n            if (camera.Slot.AttachedCompositor != null) throw new InvalidOperationException($\"The camera [{camera.Entity.Name}] is already attached\");\n\n            for (var i = 0; i < graphicsCompositor.Cameras.Count; ++i)\n            {\n                var slot = graphicsCompositor.Cameras[i];\n                if (slot.Id == camera.Slot.Id)\n                {\n                    if (slot.Camera != null)\n                        throw new InvalidOperationException($\"Unable to attach camera [{camera.Entity.Name}] to the graphics compositor. Another camera, [{slot.Camera.Entity.Name}], is enabled and already attached to this slot.\");\n\n                    slot.Camera = camera;\n                    camera.Slot.AttachedCompositor = graphicsCompositor;\n                    break;\n                }\n            }\n        }\n\n        private static void DetachCameraFromSlot(CameraComponent camera)\n        {\n            if (camera.Slot.AttachedCompositor == null)\n                throw new InvalidOperationException($\"The camera [{camera.Entity.Name}] isn't attached\");\n\n            for (var i = 0; i < camera.Slot.AttachedCompositor.Cameras.Count; ++i)\n            {\n                var slot = camera.Slot.AttachedCompositor.Cameras[i];\n                if (slot.Id == camera.Slot.Id)\n                {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Engine/Processors/CameraProcessor.cs#L122-L158","documentation":"Raised by CameraProcessor.AttachCameraToSlot when the camera's slot in the graphics compositor is already occupied by another enabled camera. During Draw, the processor tries to bind the current camera to its slot; if a different enabled camera (slot.Camera) is already attached to that slot, the binding is ambiguous, so an InvalidOperationException naming both entities is thrown instead of silently overriding the existing attachment.","triggerScenarios":"Attaching a camera whose Slot.Id matches a slot already occupied by another camera component (slot.Camera != null) during the Draw pass.","commonSituations":"Two entities assigned the same camera slot value; duplicated camera entities from a prefab; forgetting to change camera.Slot when cloning entities; level streaming loading a scene that reuses a slot.","solutions":["Assign each enabled camera a unique Slot from the GraphicsCompositor's camera slots","Disable or detach the other camera occupying the slot before attaching this one","Detach the previous camera via the processor so slot.Camera is null","Audit scene content/prefabs for duplicated camera slot assignments"],"exampleFix":"// before\ncamA.Slot = slot0; camB.Slot = slot0; // conflict\n// after\ncamA.Slot = slot0;\ncamB.Slot = slot1; // unique slots","handlingStrategy":"validation","validationCode":"var slot = compositor.Cameras.FirstOrDefault(s => s.Id == camera.Slot.Id);\nif (slot?.Camera != null && slot.Camera != camera) camera.Slot.Id = freeSlotId;","typeGuard":"bool SlotIsFree(GraphicsCompositor g, CameraComponent c) => g.Cameras.FirstOrDefault(s => s.Id == c.Slot.Id)?.Camera == null;","tryCatchPattern":"try { AttachCameraToSlot(compositor, camera); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Another camera\")) { /* assign different slot or disable other camera */ }","preventionTips":["Assign unique camera slots to each enabled camera","Audit prefabs and streamed scenes for duplicate slot ids","Detach the previous camera before attaching a new one to a slot","Use distinct GraphicsCompositor slot lists per scene"],"tags":["graphics","camera","slot-conflict"],"backgroundTag":"conflicting-config-options","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}