MeshTexture
Texture2D for drawing a mesh on Canvas, without its own image RID.
MeshTexture passes a mesh and BaseTexture to canvas_item_add_mesh. It draws 2D geometry rather than baking a mesh into an image or rendering a camera view of a 3D model. Drawing requires both resources: a Mesh with suitable 2D vertices/UVs and BaseTexture. If either is missing, draw does nothing.
ImageSize is the logical geometry size used to scale DrawRect. It is not derived from BaseTexture and changes neither UVs nor mesh data. Although the C# API takes Vector2, native Size2i storage truncates fractional components. Supply positive nonzero integer dimensions: rectangle drawing divides destination size by ImageSize.
GetRid returns an empty RID: do not treat this object as a conventional GPU texture for a material or shader sampler. DrawRect ignores tile; DrawRectRegion ignores the source rectangle and clipUv and draws the entire mesh. HasAlpha always returns false and IsPixelOpaque always true: these are query stubs rather than transparency tests for BaseTexture or triangles. Use separate geometry/a mask for hit testing.
GetMesh and GetBaseTexture return shared resources rather than copies. Do not dispose returned aliases while an owner still uses them. Property and child-resource changes do not automatically emit Changed; notify your dependent system after a completed operation if needed. Dispose an owned MeshTexture after use.
The combined 23 Windows headless state checks establish references, values, integer size and absence of automatic Changed. Actual drawing, UVs, alpha blending and image quality were not tested; draw limitations were reviewed in source.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
MeshTextureConstructor
public MeshTexture();Creates an owned Texture2D resource without Mesh/BaseTexture and with ImageSize=(0, 0). Configure geometry, base texture and positive logical size before drawing.
Properties3
BaseTextureProperty
public Texture2D BaseTexture { get; set; }Shared texture sampled by mesh UVs. Neither a source of automatic ImageSize nor a copy. null disables drawing; the setter neither emits Changed nor connects child-resource change forwarding.
ImageSizeProperty
public Vector2 ImageSize { get; set; }Logical rectangle-drawing scale reference rather than BaseTexture dimensions. Stored internally as Size2i: fractional Vector2 components are truncated. Use positive nonzero integer dimensions; the setter neither validates them nor emits Changed.
MeshProperty
public Mesh Mesh { get; set; }Shared mesh with suitable 2D vertices and UVs for Canvas drawing. The setter stores the reference without validating geometry or emitting Changed. null disables drawing.
Methods6
GetBaseTextureTexture2D
public Texture2D GetBaseTexture();Returns BaseTexture. Shared texture sampled by mesh UVs. Neither a source of automatic ImageSize nor a copy. null disables drawing; the setter neither emits Changed nor connects child-resource change forwarding.
Texture2DShared resource or null, not an independent copy.
GetImageSizeVector2
public Vector2 GetImageSize();Returns ImageSize. Logical rectangle-drawing scale reference rather than BaseTexture dimensions. Stored internally as Size2i: fractional Vector2 components are truncated. Use positive nonzero integer dimensions; the setter neither validates them nor emits Changed.
Vector2Logical integer dimensions represented as Vector2.
GetMeshMesh
public Mesh GetMesh();Returns Mesh. Shared mesh with suitable 2D vertices and UVs for Canvas drawing. The setter stores the reference without validating geometry or emitting Changed. null disables drawing.
MeshShared resource or null, not an independent copy.
SetBaseTexturevoid
public void SetBaseTexture(Texture2D texture);Sets BaseTexture. Shared texture sampled by mesh UVs. Neither a source of automatic ImageSize nor a copy. null disables drawing; the setter neither emits Changed nor connects child-resource change forwarding.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
textureShared Texture2D sampled by mesh UVs, or null to disable draw.
SetImageSizevoid
public void SetImageSize(Vector2 size);Sets ImageSize. Logical rectangle-drawing scale reference rather than BaseTexture dimensions. Stored internally as Size2i: fractional Vector2 components are truncated. Use positive nonzero integer dimensions; the setter neither validates them nor emits Changed.
| Name | Type | Default |
|---|---|---|
size | Vector2 | — |
sizePositive nonzero logical size; fractional components are truncated.
SetMeshvoid
public void SetMesh(Mesh mesh);Sets Mesh. Shared mesh with suitable 2D vertices and UVs for Canvas drawing. The setter stores the reference without validating geometry or emitting Changed. null disables drawing.
| Name | Type | Default |
|---|---|---|
mesh | Mesh | — |
meshMesh with 2D vertices/UVs or null to disable draw; the setter does not validate geometry.