Sprite to MeshInstance2D in code?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Remedee

In godot you can covert a Sprite to a MeshInstance2D using a menu in the editor. What I want to know is if there is a way to do this in gdscript. I have Sprites that aren’t created till runtime that I would like to convert to MeshInstance2Ds after their creation. Is there a way to do this conversion using gdscript or is it only available through the editor?

:bust_in_silhouette: Reply From: Eder

I was looking for the same just now but there are no relevant info about it. I check it directly on the Github project and unfortunately the code for calculating the mesh vertices is build-into the Editor’s code which means that it’s only available through the Editor. If someone wants to check the implementation the source was located at: editor/plugins/sprite_2d_editor_plugin.cpp on Godot project