I’m setting up some tests for a new menu system, and working out how to display various elements of the UI.
My new script has a GUIStyle in it to store the font attributes for my text. While I’m setting things up I decided to just copy over a GUIStyle I am currently using in my game’s HUD just to fill out all the basic values before I make my tweaks.
But when I ran the script, I found my changes were overriding the values in the HUD’s GUIStyle.
I’m baffled here. I thought I was copying over the values, but instead it seems to have established a reference.
If I have two ints and I write “intA = intB” and then change intA, that doesn’t change intB. But that’s what’s going on with these GUIStyles. What’s going on here? Why is it doing it this way, and how do I get it to just COPY the values between these two GUIStyles, not link them?
protected GUIStyle Style;
void Start()
{
Style = GameManager.HUD.HUDFont;
}