Search Unity

Resolved Touch and Button

Discussion in 'Scripting' started by Deus69xxx, Feb 13, 2024.

  1. Deus69xxx

    Deus69xxx

    Joined:
    Dec 22, 2022
    Posts:
    6
    I've tried finding a solid answer to this, but it doesn't seem to exist, only something vague.

    out of the box, if you create a button, how would one get its OnClick() with touch only? like i stick a button in a scene, stick a hello world script on it, built it, installed it on my phone, and tapped the button? all the answers involving button make it seem like it's either 'the editor's simulator will treat it like a touch' or some variation, but don't make it clear if a build from unity will understand a touch on a button without going through all the scripting of touch handling x.x
     
  2. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    730
    Yes. A general rule is everything that happen during Editor's Play mode should happen in the build too. That's what Play mode is for, to test your game without having to build/deploy it to a device.
     
    Deus69xxx likes this.
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
  4. JoshuaMcKenzie

    JoshuaMcKenzie

    Joined:
    Jun 20, 2015
    Posts:
    916
  5. Deus69xxx

    Deus69xxx

    Joined:
    Dec 22, 2022
    Posts:
    6
    ok, i tied down a friend took his phone and tested it, and yessiree, it does indeed, thank you for giving me the confidence @Nad_B

    sorry, responses to my questions can be hard to find because i'm in kind of a middle place where the logic is easy, the language is the confusing part, and people are either past that and don't know that i need the 'words' to do what i want, or they're below that and they don't think of the concept i've already got lol.

    as for posting this here, it wasn't specifically meant as 'UI', it was actually for scripting how to get the OnClick() through code, because i never thought with all of the hubbub around input and all the stuff that goes in to raycasting, etc to get touches on game objects that they would have just made something naturally convert touch into a location.