- Home /
Can I display the console ouput on the 3D object?,Can I display output from the console on the 3D object?
Hello, I am c# and unity beginner. When I write script with "Debug.Log("Hello world");, I see that message inside the console. But what if I would like this message on my 3D object (for example on the cube) or as a text via the camera? Is it possible? If yes can you give me some advice what functions are responsible for that?
Thank you all in advance.
Edit: I forgot to mention that the message which I want to display on the object is generated by the C# script.
Answer by swanne · Jul 05, 2018 at 07:13 PM
Hi,
When you write Debug.Log, you are explicitly telling unity to output to the console. If you want to have 'Hello World' written in your game space, you can use 3D text, via a Textmesh or use UI text components.
If you are a beginner, I really recommend working through the free tutorials on the Unity site. They are a great reference to get you learning. If you need clarification on any points come back here to Answers and ask away :)
Hi thank you for your reply! Yea sorry I am aware of 3D text option. I wasn't too detailed in my previous message, the output is generated by my C# script so I think I can't use that option?
Yes you can use c#. For the example of 3D text:
In your script include the line following line public Text$$anonymous$$esh myText;
Save the script and go back to unity. Select the gameobject that your script is on, and you'll see an new field call $$anonymous$$y Text - with an empty place holder next to it.
Drag and drop the 3D text game object from the scene hierarchy and place it into this field.
Now back in your script, make the start function look like this:
void Start () {
myText.text = "Hello World";
}
Save the script, run the game and you'll see the 3D text represent what you've told it to in the script