- Home /
Help with Custom Editor GUIStyle - Loading custom textures from Resources
Hello, good day! I'm experimenting with Unity's Custom Editor because I've been needing it. Obviously. I have this piece of code that isn't quite working the way I expected:
header = Resources.Load("Textures/header.png", typeof(Texture2D)) as Texture2D;
style = new GUIStyle();
style.normal.background = header;
style.richText = true;
Rect r = EditorGUILayout.BeginHorizontal(style);
if (GUI.Button(r, GUIContent.none, style))
basicSettings = !basicSettings;
EditorGUILayout.Foldout(basicSettings, "");
EditorGUILayout.LabelField("<b>Basic Settings</b>", style);
EditorGUILayout.EndHorizontal();
What's happening there is, basically, I'm trying to make a cool header with a custom texture. For that, I've created a GUIStyle and changed the GUIStyle.normal.background to use a Texture2D located at the Resources Folder.
The only problem is that, even though the text properties of that GUIStyle are working properly, the Texture2D loaded won't show up. Any ideas on why is that happening? Here are the settings for the sprite:
Your answer
Follow this Question
Related Questions
How to customize guistyle 0 Answers
Editor Object Field Select From List 2 Answers
DrawDefaultInspector crash 1 Answer
Can't modify custom class variables in the Inspector tab 1 Answer
Access serialized field in custom editor 2 Answers