So I have a text file at D:\data.txt with these words “Hello World”. I want to display them on a cube model. Please help me!!
2 Answers
21.) Create a 3D Text Prefab.
2.) Using the Streamreader class, read the text file from disk.
3.) Set the TextMesh component of your 3D Text prefab to the text from the Streamreader.
4.) Set the Cube as the parent of the 3D Text Prefab
5.) Transform the prefab in relation to the cube so it looks like the text is on it.
I think you would need to build/create yourself a texture with the words. You can access textures directly in memory and even make them dynamically too.
The part of writing the text could be done with standard .NET/MONO API for text I think.
Alternatively, you have to use the GUI classes to write some text for a frame, grab the text from the camera screenbuffer and make a screenshoot (search for “unity screenshot wiki” on Google) then take that data and build a texture.
Thank for answer, but I just want when I click button "Play", the text will display on cube, I don't want to make GUI.
– leokvnoh, that would make it a bit easier to understand. From your question I thought reading a textfile from D: was important.
– BerggreenDK
but what is the correct transformation to look like the text is on it? i am really struggling with this
– dimitros89