Слетают стили, если их определять в момент объявления(Unity)
Слетают стили, если их определять в момент объявления. Должно быть:
Но слетает:

public class DataObject : GUIDraggableObject
// This class just has the capability of being dragged in GUI - it could be any type of generic data class
{
...
static internal GUIStyleState styleStateHeadlineblack = new GUIStyleState()
{
textColor = Color.white,
background = LofP.MakeTex(Screen.width, 100, Color.black)
};
static internal GUIStyle styleHeadlineblack = new GUIStyle()
{
normal = styleStateHeadlineblack,
fixedHeight = 20
};
static internal GUIStyleState styleStateHeadlinegray = new GUIStyleState()
{
textColor = Color.white,
background = LofP.MakeTex(Screen.width, 100, Color.gray)
};
static internal GUIStyle styleHeadlinegray = new GUIStyle()
{
normal = styleStateHeadlinegray,
fixedHeight = 17
};
internal GUIStyle style = new GUIStyle()
{
padding = new RectOffset(20, 0, 0, 0)
};
...
public int m_OrderValue;
public void OnGUI()
{
...
m_OrderValue = EditorGUILayout.IntField("Порядок:", m_OrderValue, styleHeadlineblack);
...
}
}
...
#if UNITY_EDITOR
public class LofP {
public static Texture2D MakeTex(int width, int height, Color col)
{
Color[] pix = new Color[width * height];
for (int i = 0; i < pix.Length; i++)
pix[i] = col;
if(width == 0) {
width = Screen.width;
}
if(height == 0) {
height = Screen.height;
}
Texture2D result = new Texture2D(width, height);
result.SetPixels(pix);
result.Apply();
return result;
}
...
}
#endif
В чём может быть проблема?