У меня есть сетка объекта на сцене:

На основной камере есть один компонент сценария C# с кодом:< /p>
Код: Выделить всё
using UnityEngine;
using System.Collections;
public class cameraAnim3 : MonoBehaviour
{
void Update() {
if (Input.GetMouseButtonDown (0)) { // if left button pressed...
print ("cli!!!");
// create a ray passing through the mouse pointer:
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray, out hit)) { // if something hit...
print ("clicked on object!!!");
// if you must do something with the previously
// selected item, do it here,
// then select the new one:
Transform selected = hit.transform;
selected.gameObject.SetActive (true);
print (selected.gameObject.name);
// do whatever you want with the newly selected
// object
}
}
}
}
Как поймать клик по этой сетке?
[img]https://s6. postimg.org/fb5u4qj1t/image.png[/img]
Подробнее здесь: https://stackoverflow.com/questions/299 ... -on-object
Мобильная версия