Search Unity

Hot to producer a click/tap with code in Unity?

Discussion in 'Scripting' started by denisatglaza, Jun 22, 2018.

  1. denisatglaza

    denisatglaza

    Joined:
    May 14, 2018
    Posts:
    18
    I am developing a facial recognition feature that will producer a click/tap when user blinks. Is there a way to "produce" the click with code? It doesn't look like I can use onMouseDown or Button.onClick since there is no button or a mouse. Essentially what I have is:

    public void Blink(){
    *code that lets computer know that user blinked* }

    What I need to add is:

    public void ClickedByBlinking(){
    *some code to producer a click (Blink) }
     
  2. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
  3. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    I dont get your intention. You want to fire an event when the user blinks? Or do you want the generate a click-sound?

    If you want to have your own "onEyeBlink()" method, then you need an delegate first, fire an event to that delegate and than you need to subscribe your "onEyeBlink()" to your delegate.