I’m trying to make an EditorWindow with its background textured, like the Animator. It works fine, except if I close Unity while my EditorWindow is open, and then reopen Unity, my EditorWindow is still open and docked, but the texture is no longer loaded into memory. Ideas?
Here’s my relevant code:
private static Texture2D BackgroundTexture;
private static string backgroundTexturePath = "Assets/Editor/Conversationalist/AdditionalAssets/background.png";
[MenuItem ("Window/Conversation Editor")] //add menu item to access editor window
static void Init () {
BackgroundTexture = AssetDatabase.LoadAssetAtPath (backgroundTexturePath, typeof(Texture2D)) as Texture2D;
// Get existing open window or if none, make a new one:
ConversationalistEditor window = (ConversationalistEditor)EditorWindow.GetWindow (typeof (ConversationalistEditor));
window.InitNodeCanvas ();
window.Show();
}
public void OnGUI () {
// Draw background when repainting
if (BackgroundTexture == null) {
Debug.Log ("Couldn't locate editor background texture");
}else {
Debug.Log ("painting that background!");
RepaintBackground();
}