So here is my Manager to make things all clean, :3 The point in this is to make everything GUI Related in one script… Just having a problem with the GUI…
You used to be able to draw GUI functions in Update()
although now you can’t, you must put them in OnGUI(), but the problem is… you can’t call OnGUI() from another script, you can only call Update()… Which makes this very confusing for me.
This is the way I used to do it
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ApplicationManager : MonoBehaviour {
//Declaring HealthManager as an instance
public static ApplicationManager instance;
// getting the instance, if it doesn't exist create a new one.
public static ApplicationManager GetInstance()
{
if (instance == null)
{
instance = new ApplicationManager();
}
return instance;
}
public ApplicationManager() {
}
// Use this for initialization
void Start () {
instance = this; // Sets the instance to itself
}
// Update is called once per frame
void Update () {
HealthManager.GetInstance().Update();
ExperienceManager.GetInstance().Update();
StatManager.GetInstance().Update();
GUIManager.GetInstance().Update();
}
}
Although I get the error “GUI Functions can only be called from within OnGUI”
So I attempted to change GUIManager.GetInstace().OnGUI();
Which gave me the same error… O_O