Getting the mesh of the node with this script

Godot Version



Am moving from Unity and am trying to do this:
mesh = this.GetComponent().sharedMesh;
However, I know that Godot doesn’t really work with components and the meshes have surfaces, but getting to the point, I’ve been using chatGPT for about day and a half and I still don’t know how to do this. It just keeps showing errors at runtime. Right now, I have mesh = this.Mesh;
CS1061: ‘BorderResize’ (the script) does not contain a definition for ‘Mesh’ and no accessible extension method ‘Mesh’ accepting a first argument of type ‘BorderResize’ could be found (are you missing a using directive or an assembly reference?)

Assuming you have a MeshInstance node (2d or 3d), then you can get the mesh in code (gdscript):

var n = $YourNodeName
var m = n.mesh # a property of that node

In C# it should be similar. See docs in-app.