{"record":{"id":"81811748d290ca29","repo":"stride3d/stride","slug":"texture-uibatch","errorCode":null,"errorMessage":"texture","messagePattern":"texture","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/UIBatch.cs","lineNumber":331,"sourceCode":"        }\n\n        /// <summary>\n        /// Batch a new border image draw to the draw list.\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 ui element</param>\n        /// <param name=\"borderSize\">The size of the borders in the texture in pixels (left/top/right/bottom)</param>\n        /// <param name=\"color\">The color to apply to the texture image.</param>\n        /// <param name=\"depthBias\">The depth bias of the ui element</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=\"snapImage\">Indicate if the image needs to be snapped or not</param>\n        public void DrawImage(Texture texture, ref Matrix worldMatrix, ref RectangleF sourceRectangle, ref Vector3 elementSize, ref Vector4 borderSize,\n            ref Color color, int depthBias, ImageOrientation imageOrientation = ImageOrientation.AsIs, SwizzleMode swizzle = SwizzleMode.None, bool snapImage = false)\n        {\n            if (texture == null) throw new ArgumentNullException(nameof(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 UIImageDrawInfo\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                DepthBias = depthBias,\n                ColorScale = color,\n                ColorAdd = Color.Zero,","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/UIBatch.cs#L313-L349","documentation":"Thrown by UIBatch.DrawImage when the texture parameter is null. The public DrawImage overload validates its required texture before computing draw information. Raised as ArgumentNullException with param name \"texture\".","triggerScenarios":"Calling UIBatch.DrawImage(null, ...) — typically when a SpriteField/UI element's texture has not been assigned or a texture load failed and returned null.","commonSituations":"UI image whose Texture property is unset; asynchronous texture load not finished; asset not found leaving the reference null.","solutions":["Ensure the texture is loaded and assigned before batching (await load, or use a placeholder texture).","Null-check the texture at the call site and skip or substitute a white pixel texture.","Verify the asset reference in the UI component is not null at draw time."],"exampleFix":"// before\nuiBatch.DrawImage(element.Texture, ref world, ref source, ref size, ref border, ref color, 0);\n// after\nif (element.Texture != null)\n    uiBatch.DrawImage(element.Texture, ref world, ref source, ref size, ref border, ref color, 0);","handlingStrategy":"validation","validationCode":"if (texture == null) return; // or use placeholder\ntexture.Validate();","typeGuard":"bool HasTexture(UIElement e) => (e as UIImageElement)?.Texture != null;","tryCatchPattern":"try { uiBatch.DrawImage(texture, ...); }\ncatch (ArgumentNullException e) when (e.ParamName == \"texture\") { log.Warning(\"DrawImage skipped: null texture\"); }","preventionTips":["Null-check textures before each UI batch pass.","Use a 1x1 white placeholder for missing textures.","Verify async texture loads complete before first render."],"tags":["ui","null-argument","graphics"],"backgroundTag":"null-argument","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"}