I started my application by modifying Video Playback sample only :) . I will look into that part of the code. Thank you for guiding.
But can you suggest me why the below event handler code is not working for me..
using UnityEngine;
using System.Collections;
public class InputHandler : MonoBehaviour {
private Ray m_Ray;
private RaycastHit m_RayCastHit;
private MovableObject m_CurrentMovableObject;
private float m_MovementMultipier = 10f;
void Update ()
{
Debug.Log("Sushh update input for button");
if(Input.touches.Length == 1)
{
Touch touchedFinger = Input.touches[0];
switch(touchedFinger.phase)
{
case TouchPhase.Began:
Debug.Log("Sushh button began");
m_Ray = Camera.mainCamera.ScreenPointToRay(touchedFinger.position);
if(Physics.Raycast(m_Ray.origin, m_Ray.direction, out m_RayCastHit, Mathf.Infinity))
{
MovableObject movableObj = m_RayCastHit.collider.gameObject.GetComponent<MovableObject>();
if(movableObj)
{
m_CurrentMovableObject = movableObj;
}
}
break;
case TouchPhase.Moved:
Debug.Log("Sushh button moved");
if(m_CurrentMovableObject)
{
m_CurrentMovableObject.gameObject.transform.Translate(Time.deltaTime * m_MovementMultipier * new Vector3(touchedFinger.deltaPosition.x, 0, touchedFinger.deltaPosition.y));
}
break;
case TouchPhase.Ended:
m_CurrentMovableObject = null;
break;
default:
break;
}
}
}
}
I added this script to my virtual button
thanks AlessandroB for your fast respont
maybe my statement earlier a bit confusing, I worked with a virtual button example, and I want to add a touch event in my application. when the user presses the object on the screen then it will produce an event like the sound. is it possible?
I've seen domino.cpp, i try harder to understand the code in dominoes, but i cant. and I've followed the instructions here
https://developer.vuforia.com/forum/faq/android-how-do-i-project-screen-touch-target
but fails to touch my event, what code / method i must export and edit form dominoes app into the app to touchthe object beside projectScreenPointToPlane and linePlaneIntersection methods.i really have to finish my problem about touch the object completely .. my thesis really depends on it .. please help me