Hey guys… I was happy to have done all of the challenges pretty perfectly so far. However, I believe my code should be more efficient and even easier to read. So that makes me fear that there is something inherently wrong with it. Before I get further into the course and then magically things aren’t working I wanted to run it by you.
private void OnSelectionChanged()
{
if (Selection.activeObject is Dialogue)
{
selectedDialogue = Selection.activeObject as Dialogue;
}
else
{
selectedDialogue = null;
}
Repaint();
}
[OnOpenAsset(1)]
public static bool OnOpenAsset(int instanceID, int line)
{
if (EditorUtility.InstanceIDToObject(instanceID) is Dialogue)
{
ShowEditorWindow();
return true;
}
return false;
}
I also want to point out(and SURELY a later lecture should cover this) that you really need to set selectedDialogue to null so the window will switch to “No Dialogue Selected” if you click anything other than Dialogue(for now. Until we start actually making things happen).
I am still trying to understand why we are adding an extra variable and casting unless it is purely demonstrative for people to grasp casts better.