- Home /
How to display *.txt file on the cube model?
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!!
Answer by Meltdown · Sep 18, 2011 at 02:25 PM
Create a 3D Text Prefab.
Using the Streamreader class, read the text file from disk.
Set the TextMesh component of your 3D Text prefab to the text from the Streamreader.
Set the Cube as the parent of the 3D Text Prefab
Transform the prefab in relation to the cube so it looks like the text is on it.
but what is the correct transformation to look like the text is on it? i am really struggling with this
Answer by BerggreenDK · Sep 18, 2011 at 09:50 AM
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.
oh, that would make it a bit easier to understand. From your question I thought reading a textfile from D: was important.
Your answer
Follow this Question
Related Questions
Changing GUITEXT Value... 0 Answers
display txt file content on textarea GUI Android 1 Answer
Move GUI elements. 0 Answers
GUITexture Button? 1 Answer
how to "blink" more often? 2 Answers