So, I want to make an Android game and i write a script for touch input with Raycast. When I touch the gameobject the script is activated and works perfectly but opens a new window with my project folder.
It isn’t an error but I want to know how it happens. I test it with unity remote 4.
Here is the script:
var thx1 : GameObject;
var thx2 : GameObject;
var buton1 : GameObject;
var buton2 : GameObject;
var nameOfGameObj : String;
function Start () {
thx1.SetActive (true);
thx2.SetActive (false);
}
function Update ()
{
if (Input.touchCount > 0)
{
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit))
{
Debug.Log(" You just hit " + hit.collider.gameObject.name);
if(hit.collider.gameObject.name == nameOfGameObj)
{
thx1.SetActive (false);
thx2.SetActive (true);
Destroy (buton1);
Destroy (buton2);
}
}
}
}
Thanks