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);
}
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.
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.
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With