private void HandlePlayModeStateChanged()
        {
#if DEBUG_QUEST_EDITOR
            Debug.Log("<color=magenta>QuestEditorWindow.OnPlaymodeStateChanged. Application.isPlaying=" + Application.isPlaying + "</color>");
#endif
            SelectQuestBasedOnCurrentSelection();
            QuestEditorStyles.ResetImages(); // Unity loses dynamically-created textures when switching playmode.
            QuestEditorPrefs.SavePrefs();
            Repaint();
        }
 private void DrawNodeWindow(int id)
 {
     //UnityEngine.Assertions.Assert.IsTrue(0 <= id && id < m_nodeListProperty.arraySize, "Quest Machine: Internal error - node ID is outside m_nodeList range.");
     if (!(0 <= id && id < m_nodeListProperty.arraySize))
     {
         return;
     }
     try
     {
         var rect         = EditorGUILayout.GetControlRect();
         var nodeProperty = m_nodeListProperty.GetArrayElementAtIndex(id);
         UnityEngine.Assertions.Assert.IsNotNull(nodeProperty, "Quest Machine: Internal error - m_nodeList[id] property is null.");
         if (nodeProperty == null)
         {
             return;
         }
         var canvasRect = GetCanvasRect(nodeProperty);
         var nodeType   = GetNodeType(nodeProperty);
         var text       = GetNodeText(nodeProperty);
         var barWidth   = rect.width + (EditorGUIUtility.isProSkin ? 5 : 7); // A bit of pixel fine-tuning.
         var barRect    = new Rect(rect.x - 3, rect.y - 3, barWidth, QuestEditorStyles.nodeBarHeight);
         var textRect   = new Rect(barRect.x - 1, barRect.y - 1, barRect.width, barRect.height);
         GUI.Label(barRect, text, QuestEditorStyles.GetNodeBarGUIStyle(nodeType));
         GUI.Label(textRect, text, QuestEditorStyles.nodeTextGUIStyle);
         if (nodeType != QuestNodeType.Start)
         {
             GUI.DrawTexture(new Rect(rect.x + (rect.width / 2) - (QuestEditorStyles.connectorImage.width / 2), rect.y - 16, QuestEditorStyles.connectorImage.width, QuestEditorStyles.connectorImage.height), QuestEditorStyles.connectorImage);
         }
         if (nodeType != QuestNodeType.Success && nodeType != QuestNodeType.Failure)
         {
             GUI.DrawTexture(new Rect(rect.x + (rect.width / 2) - (QuestEditorStyles.connectorImage.width / 2), rect.y + canvasRect.height - 23 - QuestEditorStyles.connectorImage.height, QuestEditorStyles.connectorImage.width, QuestEditorStyles.connectorImage.height), QuestEditorStyles.connectorImage);
         }
     }
     finally
     {
         if (!m_connecting)
         {
             GUI.DragWindow();
         }
     }
 }