How to add GUIText to an C# script
Hello Community Members
I am learning how to script at the moment, but I have a problem in one point. I've made a intercat script and a select script. They make it possible, by hovering over an object with the script to change the color. Now I wanted to add a text when I am hovering. I found the solution for using a GUIText, but I can't find it.
This is the select script.
 // Use this for initialization
 void Start () {
 
 }
 // Update is called once per frame
 void Update()
 {
     Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
     if (Physics.Raycast(ray, out hit, 10))
     {
         if(hit.collider.gameObject.GetComponent<interact>() != null)
         {
             hit.collider.gameObject.GetComponent<interact>().OnLockEnter();
         }
     }
 }
 
               And This is the interact script.
 public GUIText target;
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     GetComponent<Renderer>().material.color = Color.white;
 }
 public void OnLockEnter()
 {
     GetComponent<Renderer>().material.color = Color.red;
     target.text = "Press E to interact!";
 }
 
               Now I wanted to add the target.text into the game! I would like to interact with dialogs later on. That means I want that you can see this Text around the character, if you are looking at it.
 It changes the color already.
 I would like to get it similar like this by hovering with the cursor over it.
Thanks a lot for your help!
 
                 
                interface.jpg 
                (121.6 kB) 
               
 
                
                 
                likeiwantit.jpg 
                (12.0 kB) 
               
 
              
               Comment
              
 
               
              Your answer