I am trying to implement a system for an exp bar where the player hovers the mouse over the bar and it displays the current exp percentage. I am using the new ui system (4.6) and event triggers on a blank image that is placed over the actual exp bar. The setup on my trigger system is shown in the screen shot. The script implemented to display the exp percentage is as shown below:
public class Exp_Bar : MonoBehaviour
{
bool isHovering = false;
void OnGUI()
{
if (isHovering)
{
decimal exp = (decimal)Math.Round((active_player_profiler.plvl_exp / 1000f) * 100f, 2);
GUI.Box(new Rect(Input.mousePosition.x + 15f, Screen.height - Input.mousePosition.y, 70f, 20f), exp.ToString() + "%");
Debug.Log("yooooooo");
}
}
public void enableHover()
{
isHovering = true;
Debug.Log("enabled");
}
public void disableHover()
{
isHovering = false;
Debug.Log("disabled");
}
}
I placed the debug messages for testing purposes. When in game, nothing seems to work. I don’t see the debug messages or the exp display. Also, I removed the EventSystem object as a test. I had it before on my canvas but it did not fix the issue. My canvas also has its default graphic raycaster. What seems to be the problem?