Reputation: 11
I must change the list background texture, that list are located in a node I use the asset xNode to do that.
That is the code of NodeEditor, is the class I use to edit the node layout.
using UnityEditor;
using UnityEngine;
using XNodeEditor;
[CustomNodeEditor(typeof(BaseNode))]
public class BaseNodeEditor : NodeEditor
{
private static GUIStyle gl_label_normal;
private static GUIStyle gl_label_bold;
private static GUIStyle gl_header;
private static GUIStyle gl_numberField;
private static GUIStyle gl_objectField;
public override void OnBodyGUI()
{
if (gl_label_normal == null) gl_label_normal = new GUIStyle(EditorStyles.label);
if (gl_label_bold == null) gl_label_bold = new GUIStyle(EditorStyles.boldLabel);
if (gl_numberField == null) gl_numberField = new GUIStyle(EditorStyles.numberField);
if (gl_objectField == null) gl_objectField = new GUIStyle(EditorStyles.objectField);
EditorStyles.objectField.normal.background = GetBackgroundTexture("#00000080");
EditorStyles.numberField.normal.background = GetBackgroundTexture("#00000080");
EditorStyles.numberField.normal.textColor = Color.white;
EditorStyles.label.focused.textColor = Color.blue;
EditorStyles.label.hover.textColor = Color.black;
EditorStyles.label.normal.textColor = Color.black;
EditorStyles.boldLabel.normal.textColor = Color.black;
EditorStyles.boldLabel.hover.textColor = Color.black;
base.OnBodyGUI();
EditorStyles.label.normal = gl_label_normal.normal;
EditorStyles.boldLabel.normal = gl_label_bold.normal;
EditorStyles.numberField.normal = gl_numberField.normal;
EditorStyles.objectField.normal = gl_objectField.normal;
}
public override void OnHeaderGUI()
{
if (gl_header == null) gl_header = new GUIStyle(NodeEditorResources.styles.nodeHeader);
NodeEditorResources.styles.nodeHeader.normal.textColor = Color.black;
base.OnHeaderGUI();
NodeEditorResources.styles.nodeHeader.normal = gl_header.normal;
}
private Texture2D GetBackgroundTexture(string hexColor) {
Color color = Color.white;
ColorUtility.TryParseHtmlString(hexColor, out color);
Texture2D texture = new Texture2D(1, 1);
texture.SetPixel(0, 0, color);
texture.Apply();
return texture;
}
}
I don't know how to do that, if some one knows please can help me?
I tryed to find in EditorStyles the element responsible to manage the background in list.
What I want is find the element responsible to change the list background texture.
Upvotes: 0
Views: 173