Hi, I have a 3d cube in prefabs.
I istanziate this cubes in Start() of a gameobject named init_playground:
caselle=newGameObject[9][];
for(intr=0;r<9;r++){
caselle[r]=newGameObject[9];
for(intc=0;c<9;c++){
caselle[r][c]=(GameObject)Instantiate(casella,newVector3((c-4)*offset,-1,(4-r)*offset),Quaternion.identity);
caselle[r][c].GetComponent<CasellaSelect>().riga=r;
caselle[r][c].GetComponent<CasellaSelect>().colonna=c;
in the cube I have a script "CasellaSelect" to detect touch:
[code=CSharp]using UnityEngine;
using System.Collections;
public class CasellaSelect : MonoBehaviour {
public int riga,colonna;
public void eventOnMouseDown(){
Debug.Log ("cliccato r:"+riga+" c:"+colonna);
}
}
The script sometimes not trigger the event…
I attach the cube prefab.
Why sometimes the event is triggered, sometimes not?
EDIT: I have notices that only clicks that are in the upper area to the center of the screen are not triggered
The code you posted won’t compile, but probably because your sharing two snippets in one block. Maybe share the whole script(s) in its original format, with commenting using “// this does…” or “/* another comment */” so others can easily copy paste your code into an ide and look at it for errors.