{"record":{"id":"ea3be87186ef61e6","repo":"stride3d/stride","slug":"texture","errorCode":null,"errorMessage":"texture","messagePattern":"texture","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Sprite3DBatch.cs","lineNumber":71,"sourceCode":"        }\n\n        /// <summary>\n        /// Draw a 3D sprite (or add it to the draw list depending on the sortMode).\n        /// </summary>\n        /// <param name=\"texture\">The texture to use during the draw</param>\n        /// <param name=\"worldMatrix\">The world matrix of the element</param>\n        /// <param name=\"sourceRectangle\">The rectangle indicating the source region of the texture to use</param>\n        /// <param name=\"elementSize\">The size of the sprite in the object space</param>\n        /// <param name=\"color\">The color to apply to the texture image.</param>\n        /// <param name=\"imageOrientation\">The rotation to apply on the image uv</param>\n        /// <param name=\"swizzle\">Swizzle mode indicating the swizzle use when sampling the texture in the shader</param>\n        /// <param name=\"depth\">The depth of the element. If null, it is calculated using world and view-projection matrix.</param>\n        public void Draw(Texture texture, ref Matrix worldMatrix, ref RectangleF sourceRectangle, ref Vector2 elementSize, ref Color4 color,\n                         ImageOrientation imageOrientation = ImageOrientation.AsIs, SwizzleMode swizzle = SwizzleMode.None, float? depth = null)\n        {\n            // Check that texture is not null\n            if (texture == null)\n                throw new ArgumentNullException(\"texture\");\n\n            // Skip items with null size\n            if (elementSize.LengthSquared() < MathUtil.ZeroTolerance)\n                return;\n\n            // Calculate the information needed to draw.\n            var drawInfo = new Sprite3DDrawInfo\n            {\n                Source =\n                {\n                    X = sourceRectangle.X / texture.ViewWidth,\n                    Y = sourceRectangle.Y / texture.ViewHeight,\n                    Width = sourceRectangle.Width / texture.ViewWidth,\n                    Height = sourceRectangle.Height / texture.ViewHeight,\n                },\n                ColorScale = color,\n                ColorAdd = new Color4(0, 0, 0, 0),\n                Swizzle = swizzle,","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Sprite3DBatch.cs#L53-L89","documentation":"Argument-null validation in Sprite3DBatch.Draw: the texture parameter is null. Drawing a 3D sprite requires a texture to sample; the batch cannot enqueue a sprite without one, so it throws ArgumentNullException named 'texture'. Declared in the docs of the Draw overload that draws 3D sprites with element size, sorting mode, etc.","triggerScenarios":"Calling Draw(texture, ...) with texture == null — e.g. a Sprite3D component whose texture/material image failed to load or was not assigned.","commonSituations":"Missing or failed asset loads (texture asset absent from the build), unassigned fields in scene setup, or code paths where the texture is conditionally created but a null slips through.","solutions":["Ensure the texture is loaded before drawing (await asset load; check load errors)","Guard the call: skip drawing when texture is null","Fix the asset reference so the texture is included in the build output"],"exampleFix":"// before\nbatch.Draw(mySprite3D.Texture, ref world, ref src, ref size, ref color);\n// after\nif (mySprite3D.Texture != null)\n    batch.Draw(mySprite3D.Texture, ref world, ref src, ref size, ref color);","handlingStrategy":"type-guard","validationCode":"if (texture == null) return;","typeGuard":"bool IsDrawable(Texture t) => t != null && !t.IsDisposed;","tryCatchPattern":"try { batch.Draw(texture, ...); } catch (ArgumentNullException) { /* texture missing */ }","preventionTips":["Await/verify texture asset loading before draw calls","Fail fast at load time when a required texture is missing"],"tags":["graphics","sprites","null-argument"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}