I’m using the following code:
using UnityEngine;
using System.Collections;
public class TestScript{
private GUISkin custom_skin;
public bool guiEnabled;
public TestScript(GUISkin new_skin){
custom_skin = new_skin;
}
public void OnGUI(){
if(guiEnabled){
GUI.skin = custom_skin;
GUI.Label(new Rect(0,0,50,50),"Blah");
}
}
}
The problem is that I’m also getting the following error: ArgumentException: You can only call GUI functions from inside OnGUI.
It works fine in another script that is running in the same scene, but for some reason this one won’t. I looked at the other script, and it’s all set up in exactly the same way, but for some reason I’m getting this error all of a sudden.