I have quite a big project with many tests and experiments in over 10 different scenes.
I wanted to change the GUI Skin so it would all look a bit better.
Does anyone know of a simple way to globally change the GUISkin?
I did it the hard way now, went into every scene, looked for the GUI-Script and included a public GUISkin-Variable which I then set in the Inspector. This took some time since I often have several GUI-Scripts for the same scene (its all a bit chaotic, but its only for testing after all…)
Molix
2
You may want to look into using a ‘singleton’, or something similar. For example:
public class MyGuiManager : MonoBehaviour
{
public GUISkin guiSkin;
private static MyGuiManager instance;
void Awake()
{
instance = this;
}
public static GUISkin GetSkin()
{
return instance.guiSkin;
}
}
As long as you have one game object in your scene with this script, then all your other OnGUI() functions can just call:
void OnGUI()
{
GUI.skin = MyGuiManager.GetSkin();
// ...
}
If the game object containing MyGuiManager is in a prefab, then changing the skin for everything only has to happen there.