You can only call GUI functions from inside OnGUI but I'm inside OnGUI

This is my code: using UnityEngine;using UnityEngine.UI;using System.Collections;public c - Pastebin.com I don’t know how to format code on here so I used pastebin. I made a game object and attatched this script. Then I have an input field and under On End Edit I added the game object. Using UIController.SetPlayerName works. When I type something in and hit enter then inputText variable equals what was typed. Then I added clicked “+” under On End Edit and added the game object again and tried to use UIController.OnGUI to show the text that the player entered but I get the error “You can only call GUI functions from inside OnGUI” but I have a function called OnGui and it’s inside that function that I’m trying to show the text entered by the player. What’s going wrong and how can I fix this? I’m just trying to have the player enter something, then I show what the player entered on the screen.

I feel like I’m missing something very obvious.

You shouldn’t call the OnGUI function manually, Unity will call it for you every frame.

What part is calling it manually? You mean I just take out “public void OnGUI()”?

It sounds like you are calling UIController.OnGUI when the input field is finished editing.

Ah I see what you mean now. With that part out, it isn’t giving errors but it also isn’t doing anything. Is there something I should do to set text size and color to be visible? Or maybe something to bring it to the front and not be behind other layers? It’ll be over a black panel. I changed the color to white but it still doesn’t show up.