Question by
llacomba · May 15, 2021 at 11:55 PM ·
c#textfieldonmouseover
How to change GUI textfield using OnMouseOver script
I'm trying to have specific information display whenever the users mouse hovers over one of multiple squares. I can get the first square's name to appear, but, I need the text in the GUI field to change depending on which square the mouse is over. In addition to this, for some reason the further the squares get from "square1", they more they seem to appear translucent in the text box behind "square1". Here's my Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
public class HoverInfo : MonoBehaviour
{
public List<float> listTi = new List<float>();
public List<float> listVe = new List<float>();
public List<float> listTe = new List<float>();
public static GameObject square;
public bool displayInfo;
public string stringToEdit;
void Start()
{
}
void OnMouseOver()
{
stringToEdit = (gameObject.name);
}
void OnGUI()
{
stringToEdit = GUI.TextField(new Rect(520, 10, 150, 20), stringToEdit, 25);
}
void update()
{
stringToEdit.text = (gameObject.name);
}
Comment