Question by
maracepoc · Jul 31, 2017 at 05:21 PM ·
raycastinputfieldclone
How do I not deactivate all clone's inputfields?
I attach the below scrip to my instantiated prefab (GameObject + myinputfield (child)). When I try to click on one of the instantiated prefab GameObject, myinputfield is deactivated correctly but this happens in all my clones. How can I deactivate just the input field of the GameObject I've hit with the Ray? Thank you!
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class ClickToSee : MonoBehaviour { [SerializeField]
public LayerMask gameobjectslayer;
public GameObject myinputfield;
void Update(){
if (Input.GetMouseButtonDown (0)) {
RaycastHit rayHit; //we shoot ray and hits
//if the ray hits the gameobjects layer...
if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out rayHit, Mathf.Infinity, newcubeslayer)) {
myinputfield.SetActive (false);
Comment