Your main problem is that you define two classes in one file. Unity need it’s classes in seperate files and the file name has to match the class name. Since you can omit the class construct for classes that are derived from MonoBehaviour, you have to write it out for classes derived from Editor or EditorWindow.
Your two variables “dialog” and “player” are declared outside of both classes. I guess the filename match one of your classes, so the variable will belong to this class.
You can’t just cross access member variables between classes. If you want to access a variable from another class you need a reference to an instance of the class.
It would help to know your script file names and to see how “DialogController” is defined.
To answer your question in the comments, serializedObject is a variable in the Editor class. An Editor is an inspector “plugin” which shows the GUI for a certain class when it’s selected. In the first place an EditorWindow has nothing to do with the inspector or the current selection. However you can use the Selection class in your EditorWindow to get the current selected onject.
I suggest you read the docs on Editor and EditorWindow again. Pay attention to the first paragraph which explains what this classes are good for. There are also examples on the pages.
Also like phodges said, take a look at SerializedObject and SerializedProperty.
edit
Since you want to use your EditorWindow like an inspector you have to obtain a serialized object manually. Something like that:
class Dialog extends EditorWindow
{
var serObj : SerializedObject;
@MenuItem("Tools/Dialog Editor")
static function Init()
{
var window = GetWindow(Dialog);
window.Show();
}
function OnSelectionChange()
{
var objs = Selection.GetFiltered(DialogController, SelectionMode.Editable);
if (objs != null && objs.Length > 0)
{
serObj = new SerializedObject(objs)
// setup any SerializedProperties you need here
}
else
serObj = null;
}
function OnGUI()
{
if (serObj == null)
return; //No object selected that contains a DialogController
serObj.Update();
// Draw your GUI here
}
}
I’m not sure why you want this in an Editorwindow. The Inspector is made for editing selected components, so why don’t use extend the inspector for your DialogController?
When you implement the OnInspectorGUI like this you still have the same inspector but with additional GUI elements at the end (or start)
@CustomEditor(DialogController)
class MyPlayerEditor extends Editor
{
var player : SerializedProperty;
function OnEnable ()
{
// Setup SerializedProperties
player = serializedObject.FindProperty ("playerDialog");
}
function OnInspectorGUI()
{
serializedObject.Update();
// Draw additional GUI before the normal inspector
DrawDefaultInspector();
// Draw additional GUI after the normal inspector
}
}