MeshInstance2D
Entity used for displaying a Mesh in 2D.
Entity used for displaying a Mesh in 2D.
Entity used for displaying a Mesh in 2D. This can be faster to render compared to displaying a Sprite2D node with large transparent areas, especially if the node takes up a lot of space on screen at high viewport resolutions. This is because using a mesh designed to fit the sprite's opaque areas will reduce GPU fill rate utilization (at the cost of increased vertex processing utilization).
When a Mesh has to be instantiated more than thousands of times close to each other, consider using a MultiMesh in a MultiMeshInstance2D instead.
A MeshInstance2D can be created from an existing Sprite2D via a tool in the editor toolbar. Select the Sprite2D node, then choose Sprite2D > Convert to MeshInstance2D at the top of the 2D editor viewport.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
MeshInstance2DConstructor
public MeshInstance2D();Properties2
MeshProperty
public Mesh Mesh { get; set; }The Mesh that will be drawn by the MeshInstance2D.
TextureProperty
public Texture2D Texture { get; set; }The Texture2D that will be used if using the default CanvasItemMaterial. Can be accessed as TEXTURE in CanvasItem shader.
Methods4
GetMeshMesh
public Mesh GetMesh();MeshGetTextureTexture2D
public Texture2D GetTexture();Texture2DSetMeshvoid
public void SetMesh(Mesh mesh);| Name | Type | Default |
|---|---|---|
mesh | Mesh | — |
SetTexturevoid
public void SetTexture(Texture2D texture);| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
Signals and events1
TextureChangedEvent
public event Action TextureChanged;Emitted when the MeshInstance2D.Texture is changed.