Hi,
I’m trying to implement 3D text that can be associated with a mesh, which the appearance looks like a 3D button. I’ve tried a few approaches but can’t get this work nicely. (2D GUI text is not what I’m after)
First of all, I tried to use GUI.Button3D (see this playground). It works somewhat nicely but I can’t find a good way to resize the button.
I tried to use button.scaling, it rescaled button width/height/depths successfully but the text content was stretched at the same time, which is not ideal. (The scaling is not working in this playground for some reason but it once worked.)
Then I used GUI.MeshButton3D (see this playground). I’m able to use a custom sized box mesh as button, however I can’t associate text as button content. In provided playground there’s only an empty box mesh (3D mesh button), no text is visible
I also tried to use MeshWriter, but I can’t position text properly on surface of the box mesh. See this playground.
Even I set text position to mesh position, it still sits somewhere inside the mesh. I also tried to set text x/y/z to other mesh relevant values, text still sits inside mesh
At last I find the Dynamic Texture which seem to give me the best outcome so far. In this playground I created a box mesh then add text as dynamic texture. The only issue here though is it doesn’t support line break (\n
character) or auto wrap of the text. Seems I need to manually split up a long string into multiple strings, then individually drawText each string like how this playground does.
I wonder if anyone knows the best approach to implement 3D text that can be attached to a mesh and also auto wrap? Or can be attached to a mesh and supports \n
line break character?
Many thanks!
Updates:
In the end this playground is the best solution for my own project that has lots of scaling happing. The major approach is based on the marked solution answer.
In my other answer a bit further down this post has couple playground does similar thing but there’s no scaling, only width/height change.
Hope these playgrounds can help anyone encountered similar issue!
Thanks community for all the advice!