I’ve found a person with a similar problem here, but I still cannot fix the problem.
In short, Unity fails to recognize my custom GUISkin. I’ve deleted the skin and started from scratch because I did rename the skin (see problem linked above). Still, I’ve checked all of these possible problems (I’m using c#):
- The skin exists, it is named BaseSkin
- The GUISkin is a public property of my MonoBehavior (subclass name is PresetButtons, attached to empty game object named GUIPresetButtons). Property is: public GUISkin customSkin;
- The public property customSkin is definitely set via Inspector.
- in OnGUI, I set GUI.skin to customSkin
- NO compilation errors or warnings.
- The exact error is “Unable to find style ‘ButtonPreset01’ in skin ‘GameSkin’ Repaint” yet my skin is named BaseSkin.
- ‘ButtonPreset01’ clearly exists in BaseSkin’s Custom Styles (though it appears Unity is looking in the default skin anyway.
I feel like I’ve tried everything, read the GUISkin documentation thoroughly, and read all the related answers I could find. Here is the GUI.Button call:
void OnGUI () {
GUI.depth = 0;
GUI.skin = customSkin;
if (GUI.Button(new Rect(0,0,80,80), "", "ButtonPreset01")) {
Debug.Log("Clicked Preset 1 button");
}
}
Am I doing this wrong?