Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

MeshInstance2D

繼承: Node2D < CanvasItem < Node < Object

用於在 2D 中顯示 Mesh 的節點。

說明

Node 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.

教學

屬性

Mesh

mesh

Texture2D

texture


訊號

texture_changed() 🔗

texture 被改變時觸發。


屬性說明

Mesh mesh 🔗

  • void set_mesh(value: Mesh)

  • Mesh get_mesh()

MeshInstance2D 繪製的 Mesh


Texture2D texture 🔗

使用預設 CanvasItemMaterial 時,將使用的 Texture2D。可以在 CanvasItem 著色器中作為 TEXTURE 存取。