How can I find objects with using inputfield

How can I find an object when I write something into the inputfield in scene? When I write the object name into the textbox(InputField) it will find and choose it.
alt text

In order to do the things correctly, I suggest using two scripts. The first one will be responsible for searching the gameObject in your scene given a string, the secondd one will just check whether an object has been found.

1. Attach the following script to the gameobject you want (an empty at the root of the scene for example)

using UnityEngine;

[System.Serializable]
public class GameObjectEvent : UnityEngine.Events.UnityEvent<GameObject> { }

public class ObjectFinder : MonoBehaviour
{
    /// <summary>
    /// Raised when an object has been found
    /// </summary>
    public GameObjectEvent OnGameObjectFound;

    /// <summary>
    /// Raised when no object has been found
    /// </summary>
    public UnityEngine.Events.UnityEvent OnGameObjectLost;

    /// <summary>
    /// The last target
    /// </summary>
    private GameObject lastTarget;

    private void Start()
    {
        OnGameObjectLost.Invoke();
    }

    /// <summary>
    /// Finds the object with the given name
    /// </summary>
    /// <param name="input">The name of the object to search.</param>
    public void Find( string input )
    {
        GameObject target = GameObject.Find(input);

        if( target != null )
        {
            if ( lastTarget == null )
                OnGameObjectFound.Invoke( target );
        }
        else if (lastTarget != null )
        {
            OnGameObjectLost.Invoke();
        }

        lastTarget = target;
    }
}

2. Select your InputField, and in the OnEndEdit event, provide the Find function of the ObjectFinder script

3. Then, you will have to create a script listening for the events defined in the ObjectFinder script. In this script, create two functions : one with no parameters, which will be called if no gameObject has been found, and an other function with a GameObject as parameter, which will be called if a GameObject has been found. Here is an example script which customize the InputField

using UnityEngine;
using UnityEngine.UI;

public class InputFieldPainter : MonoBehaviour
{
    /// <summary>
    /// The input field to customize
    /// </summary>
    public InputField inputField;

    /// <summary>
    /// Indicates an object has been found
    /// </summary>
    /// <param name="target">The target.</param>
    public void TurnOn( GameObject target )
    {
        // Customize the input field according to the gameObject
        // Do whathever you want
        switch( target.name )
        {
            case "Sphere":
                inputField.targetGraphic.color = Color.cyan ;
                break;

            case "Cube":
                inputField.targetGraphic.color = Color.yellow;
                break;
        }
        inputField.textComponent.color = Color.black;
    }

    /// <summary>
    /// Indicates an object has been lost
    /// </summary>
    public void TurnOff()
    {
        inputField.targetGraphic.color = Color.red;
        inputField.textComponent.color = Color.white;
    }
}

4. Select the gameObject created step #1 and provide the functions of the script created step #3 in the two events. Here is an example. I’ve attached all the scripts on the InputField and provided the appropriate functions: