I have a class [InitializeOnLoad] SceneViewWindow which draws buttons and a window into the scene view by calling the onSceneGUIDelegate. It appears to work fine, see first picture. All buttons are dark gray (I haven’t set that style, it just was the default).
However, as soon as I toggle down a different component, which has a Custom Inspector with a OnSceneGUI function on it, the style/skin of the scene view GUILayout elements seem to change and I don’t know why.
This is my code to draw to the scene view:
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
public class SceneViewWindow
{
static SceneViewWindow()
{
SceneView.onSceneGUIDelegate += OnSceneGUI;
}
static void OnSceneGUI(SceneView sceneView)
{
Handles.BeginGUI();
Rect windowRect = new Rect(Screen.width - 183, Screen.height - 65, 180, EditorGUIUtility.singleLineHeight * 2f);
GUILayout.Window(666, windowRect, DrawWindowForSpriteRenderer, "Satellite Tool");
Handles.EndGUI();
}
static void DrawWindowForSpriteRenderer(int windowID)
{
...
GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
buttonStyle.margin = new RectOffset(0, 5, 2, 0);
if(GUILayout.Button(plusTexture, buttonStyle, GUILayout.Width(buttonSize), GUILayout.Height(buttonSize)))
{
...
}
...
}
}
Next, my Custom Inspector, which shouldn’t have to do anything with the previous class:
[CustomEditor(typeof(OrbitingBehaviour), true), CanEditMultipleObjects]
public class OrbitingBehaviourEditor : Editor
{
void OnEnable ()
{
_altitude = serializedObject.FindProperty("_altitude");
Tools.hidden = true;
}
void OnDisable ()
{
Tools.hidden = false;
}
void OnSceneGUI ()
{
//MoveWithHandle((OrbitingBehaviour)target);
//DrawGizmos((OrbitingBehaviour)target);
}
}
Right now the OnSceneGUI function doesn’t do anything. However, as soon as the OrbitingBehaviour component is toggled down, the scene view elements turn light gray. If I completely remove OnSceneGUI from the script, the scene view elements remain dark gray.
I’m not actually changing any Editor styles or skins in any script, so I have no clue what might be going on here. Any ideas? Maybe this is just a bug. I’m using Unity Free, but the dark gray skin should only be available to Pro users anyway, right?