S-C-A-N / SCANsat

Real Scanning, Real Science, at Warp Speed!
217 stars 97 forks source link

KSP style button overriding Unity style buttons #47

Closed DMagic1 closed 9 years ago

DMagic1 commented 10 years ago

I've noticed that this only seems to affect buttons using the "style_button" GUIStyle. The 'close' button on the big map, for instance, doesn't use this style and appears to always be unaffected.

Maybe this is something as simple as other mods using that same name? Changing the name would be a good first step, but I have no consistent way of triggering this bug, and therefore no real way to test it.

technogeeky commented 10 years ago

My current plan is to make sure each button has its own style set. I am not sure if I will follow through with this, but that's the plan.

technogeeky commented 10 years ago

BTW: I don't think it makes sense that other mods using 'style_button' should be affecting our buttons. The GUIStyle element is declared private in our file.

technogeeky commented 10 years ago

I sit corrected. It seems as though using GUISkin.GetStyle can indeed find GUIStyle objects by name:

From GUISkin:

        public GUIStyle GetStyle (string styleName)
        {
            GUIStyle gUIStyle = this.FindStyle (styleName);
            if (gUIStyle != null)
            {
                return gUIStyle;
            }
            Debug.LogWarning (string.Concat (new object[]
            {
                "Unable to find style '",
                styleName,
                "' in skin '",
                base.name,
                "' ",
                Event.current.type
            }));
            return GUISkin.error;
        }
        public GUIStyle FindStyle (string styleName)
        {
            if (this == null)
            {
                Debug.LogError ("GUISkin is NULL");
                return null;
            }
            if (this.styles == null)
            {
                this.BuildStyleCache ();
            }
            GUIStyle result;
            if (this.styles.TryGetValue (styleName, out result))
            {
                return result;
            }
            return null;
        }
DMagic1 commented 10 years ago

I do believe I've found a way to reproduce this.

I believe the problem has something to do with setting style_button = new GUIStyle (GUI.skin.button)

Perhaps a new GUISkin would help here, I just don't know how exactly to set it up to replicate the behavior of the default GUI.skin.button.