using UnityEngine;
using UnityEditor;
using System.Collections;
public class EditorTest : EditorWindow
{
string b = null;
[MenuItem ("Window/TestNull")]
static void Init ()
{
EditorTest editor = (EditorTest)EditorWindow.GetWindow(typeof(EditorTest));
}
void OnGUI ()
{
if (b != null) {
Debug.Log ("b is not Null");
}
}
}
This prints “b is not Null” the first time I open the window after a recompile of this script. It does not happen after I close and reopen the window.
if I put Debug.Log(b) I get blanks so b is empty
Where does b ever get set to anything but null?
If I can not rely on initialization on declaration where is the the proper place for initialization?