I would like to add a in game search engine that searches for gameobjects and selects the gameobject using its’ collider.
Take my simple example with four blocks
Lets say I add a Input Text Field and a search button like this:
Currently I have a highlight gameobject script and also this upcoming script : which displays the gameobjects name on screen once selected.
using UnityEngine;
using System.Collections;
public class Cube : MonoBehaviour
{
public GUISkin Border;
float native_width = 720;
float native_height = 1280;
public bool CubeInfo = false;
public GUIStyle style;
string Cube_Name = "".PadLeft(100);
public bool Cube_Buttons = false;
private Rect NameRect;
void Start()
{
Cube_Name = gameObject.name;
SetGUIAspectRatio();
}
void OnMouseDown()
{
Display();
}
//Display Object Name
private void Display()
{
Cube[] Cubes = FindObjectsOfType(typeof(Cube)) as Cube[];
foreach (Cube o in Cubes)
{
o.Cube_Buttons = false;
}
Cube_Buttons = true;
}
//Sets the Aspect Ratio of GUI
void SetGUIAspectRatio()
{
NameRect = new Rect(75, 0, Screen.height, 75);
}
void OnGUI()
{
float rx = Screen.width / native_width;
float ry = Screen.height / native_height;
GUI.matrix = Matrix4x4.TRS(new Vector3(0f, 0f, 0f), Quaternion.identity, new Vector3(rx, ry, 1f));
if (Cube_Buttons)
{
// Make a Name Button
GUI.Button(NameRect, Cube_Name.PadRight(50), style);
}
}
}
Using C# what would I need in a script that if I type “Yellow” in the Input Text field and click select, the Yellow box is selected and the name is displayed using the same script as listed above. Since I am just starting this off, I think a complete answer from start to finish is to much to ask for without providing preexisting scripts to piggyback off of. A Tutorial, or a point in the right direction with a link would be much appreciated

