Hello, I am looking for a code to replace the void OnMouseDown for Android but I have read and it cannot be done, I need you to click on the object to make the animation but I need to know how to program that touching the object activates the animation.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Button : MonoBehaviour
{
Animator anim;
void Start()
{
anim = GetComponent<Animator>();
}
void OnMouseDown()
{
anim.SetTrigger("Activate");
}
}
@PraetorBlue I agree with you but I think it only works when there are no other touches… Unity combines all the touches and presents them as the Input.mousePosition value, which I think is also what these OnMouseX() events use. BUT: I have not used the OnMouseX() stuff coz I roll all my own touch input.
OP, if you wanna look at some touch input helpers, check out my proximity buttons package. It’s not definitive by any stretch and it doesn’t really directly replace any of the OnMouseX() stuff, but it has a few handy helpers in it like my MicroTouch() class that gives you all the touches, including the mouse, in a single easy-to-digest form.
proximity_buttons is presently hosted at these locations: