Why check for not touched in the update function like this?
void Update() { if(!Touchscreen.current.primaryTouch.press.isPressed) { return; } Vector2 touchPosition = Touchscreen.current.primaryTouch.position.ReadValue(); Debug.Log(touchPosition); }
Isn’t it better to check if touched like this:
void Update()
{
if(Touchscreen.current.primaryTouch.press.isPressed)
{
Vector2 touchPosition = Touchscreen.current.primaryTouch.position.ReadValue();
Debug.Log(touchPosition);
}
}
Is there an advantage to use “return;” or did you want to teach us how to use “return;”?
If I wanted to add anything else into the update function in the future, this could cause a problem if you add it after the If-statement.
But if you use my example, you could add anything before or after the If-statement without getting in troubble.