Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity - How to write console

I add an AR camera my unity project. I use vuforia sdk for AR functions. I want to handle mouse/finger click on screen and get pixel position on screen image. I write below code. To check pixel values, I try to write them on the console. But I don't see anything. AR camera has a .cs file named DefaultTrackableEventHandler.cs. I modified it. I run my application an android real device.

DefaultTrackableEventHandler.cs

if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began) {
        float x = Input.GetTouch(0).position.x;
        float y = Input.GetTouch(0).position.y;
        print("x " + x + " - y " + y);
    }
like image 910
zakjma Avatar asked Apr 24 '15 07:04

zakjma


People also ask

Does console write work in Unity?

Console writes to Unity's standard Debug logging so it'll show up like you'd expect. The key to redirecting System. Console writes is to use the System. Console.

What is Console tab in Unity?

The Console Window (menu: Window > Console) shows errors, warnings and other messages generated by Unity. To aid with debugging, you can also show your own messages in the Console using the Debug. Log, Debug. LogWarning and Debug.


1 Answers

Use the Debug class to write to the Unity console.

E.g.:

if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began) {
    float x = Input.GetTouch(0).position.x;
    float y = Input.GetTouch(0).position.y;
    Debug.Log("x " + x + " - y " + y);
}
like image 156
Peter Duniho Avatar answered Oct 08 '22 22:10

Peter Duniho