OnMouseUp equivalent?

Hi
Im trying to use a object as a button, in PC works perfectly with OnMouseUp event, but it doesnt work in Android, what’s the equivalent of OnMouseUp for Android?
Thanks:smile:

You’ll need to use the Input.GetTouch method and poll for input changes. Check if the Touch phase goes to TouchPhase.Ended (not sure if you need to check for canceled as well), then do a screen raycast and see if it intersects with the object in the world.

The Input.GetTouch documentation has an example you can use to start at the bottom of the page

First of all, thanks for you answer.
Im trying that examples, but it doesnt work for a specific object, it works for “whenever” you touch.
I need to do a GUI with objects, I have finished completely my app except the GUI -.-
Thanks :smile:

there is no function thats related to specific objects on mobiles. The specific object part has to be developped by you, using Physics.Raycast to check if you touch something or not (the onMouse functions would be performance deadly on mobile, thats why they don’t exist)

And anyone can show me an example how to check if the Raycast is touching any object?
I have found a sample script, but it doesnt work correctly, because I can use in more than 1 object =/
Thanks in advance

I found some bricks here :
http://www.unifycommunity.com/wiki/index.php?title=Scripts

and they work for me :
(see there the “Finger manager” and “Touch Look” script samples)

You can use “OnTouchDown” script in conjunction with a “picking” script on the GameObject

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class a_OnTouchDown : MonoBehaviour
{
    void Update () {
        
        RaycastHit hit = new RaycastHit();
        for (int i = 0; i < Input.touchCount; ++i) {
            if (Input.GetTouch(i).phase.Equals(TouchPhase.Began)) {
			//if (Input.GetTouch(i).phase.Equals(TouchPhase.Stationary)) {	
            // Construct a ray from the current touch coordinates
            Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);
            if (Physics.Raycast(ray, out hit)) {
                hit.transform.gameObject.SendMessage("OnMouseDown");
              }
           }
		  
		   
       }
    }
}

______________ picking________________________________

using UnityEngine;
using System.Collections;

public class a_myPicking : MonoBehaviour {
public bool  isHighlighted = false; 
public int HighlightCount = 0;	


void OnMouseDown(){
	if(isHighlighted == false){
	isHighlighted = true; 
	HighlightCount++;	
   //gameObject.transform.renderer.material.color = new Color(0.0f/255.0f,255.0f/255.0f,255.0f/255.0f, 190.0f/255.0f);
		}
     if (isHighlighted = true  HighlightCount%2==0){
	gameObject.transform.renderer.material.color = new Color(0.0f/255.0f,0.0f/255.0f,255.0f/255.0f, 124.0f/255.0f);
	  }
	if (isHighlighted = true  HighlightCount%2!=0){
	gameObject.transform.renderer.material.color = new Color(255.0f/255.0f,255.0f/255.0f,255.0f/255.0f, 124.0f/255.0f);
	  isHighlighted = false;
		}
   
   }
  }

hope it may help

thanks
finally I have found a simpler solution :stuck_out_tongue:

IS this the solution above? It would be a great help if you would share.

please share it :slight_smile:

Yes, please do share :slight_smile:

what is the solution

actually is possible to use OnMouse functions on Androids… but i´m not sure if it is better than touches… i´m on a dilema haha .