I have a few game objects that each have colliders. When I click the game object the console prints its name. Here is the script I have attached to each game object.
public void Start ()
{
string name = gameObject.name;
}
public void OnMouseDown()
{
Debug.Log(name);
}
I also have a input field and a button that I currently can type in the name of a game object and destroy it.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEditor;
public class Search : MonoBehaviour
{
public Cube cube;
public InputField Name;
public void start ()
{
GameObject selected = GameObject.Find (Name.text);
Destroy (selected);
}
}
Instead of Destroying the gameobject in the second script, how can I instead select the game objects collider as if I used OnMouseDown() from the first script; even more specifically How can I search the game object in the input field and “select” the gameobject as if I simple clicked on it by hand. This is what I am looking for:
public void start ()
{
GameObject selected = GameObject.Find (Name.text);
Activate (selected); //activate the mesh collider to trigger
//OnMouseDown from first script.
//I know this won't work, but I am not
// sure what the proper syntax is here.
}
Very useful link, thanks !
– Eldoir