Jump to content

Getting error: Unable to find style


linuxgurugamer

Recommended Posts

Hi,

I'm getting what is, for me, an unknown error.

First, here is the code:


public void OnGUI()
{
.....
.....
GUIStyle s = new GUIStyle (HighLogic.Skin.textField);


s.onNormal = HighLogic.Skin.textField.onNormal;


// s.fontSize = 15;
s.name = "listitem";
s.alignment = TextAnchor.MiddleLeft;
//s.fontStyle = FontStyle.Bold;
//s.fixedHeight = 50;
s.imagePosition = ImagePosition.ImageLeft;
GUI.skin.customStyles [0] = s;

.....
.....
(various GUILayout, etc)
}

Further down, the following is done:


return SelectionList (selected, list, "listitem", callback);
}


public static int SelectionList (int selected, GUIContent[] list, GUIStyle elementStyle, DoubleClickCallback callback)
{
elementStyle = GUI.skin.customStyles [0];
for (int i = 0; i < list.Length; ++i) {
//elementStyle.fontSize = 15;


Rect elementRect = GUILayoutUtility.GetRect (list [i], elementStyle);
bool hover = elementRect.Contains (Event.current.mousePosition);
if (hover && Event.current.type == EventType.MouseDown && Event.current.clickCount == 1) {
selected = i;
Event.current.Use ();
} else if (hover && callback != null && Event.current.type == EventType.MouseDown && Event.current.clickCount == 2) {
callback (i);
Event.current.Use ();
} else if (Event.current.type == EventType.repaint) {
elementStyle.Draw (elementRect, list [i], hover, false, i == selected, false);
}
}
return selected;
}

And here are some of the errors:


Unable to find style 'listitem' in skin 'GameSkin' Layout
(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)
.....
(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 56)
Unable to find style 'listitem' in skin 'GameSkin' Repaint

Now, I know that the code at the beginning works, since if I delete it, I see the very obvious change in the window.

So, what is generating these errors, and should I be concerned?

I'm guessing that I should set a couple of other GUIStyles in other skins, but I have no idea what, or where.

Thanks in advance

Link to comment
Share on other sites

As the errors are in two different places (Layout and Repaint), my suspicion is that the "GUI.skin.customStyles[0]" reference is not behaving as you expect.

I'd stick some debug lines in checking to make sure you are getting the data out of that you expect.

D.

Link to comment
Share on other sites

As the errors are in two different places (Layout and Repaint), my suspicion is that the "GUI.skin.customStyles[0]" reference is not behaving as you expect.

I'd stick some debug lines in checking to make sure you are getting the data out of that you expect.

D.

This is in my CraftImport mod.

I hear what you are saying, but here the thing:

This code is for the file selection dialog. If I don't put in that custom style, the file selection dialog is mostly black, both the background, hover and text are very dark. When I have it there, they are the way I want.

So right now I'm at a loss. Unfortunately, I'm at work now, and can't do anything about it, but feel free to grab the code from github and take a look.

It's a little messy, and due for a refactoring, but I'm going to wait until 1.1 so that I don't have to do it twice.

LGG

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...