private void PlayNode(bool manual, bool force = false)
        {
            if (canvas != null)
            {
                player = this;

                if (currentNode == null)
                {
                    CheckHubs();
                }
                else
                {
                    if (force || (currentNode.IsAuto() && !manual) || (!currentNode.IsAuto() && manual))
                    {
                        currentNode = currentNode.UpdateNode();
                    }
                }
            }
        }
        public override void OnInspectorGUI()
        {
            InitializeStyles();

            DialogPlayer playerInstance = player.player;

            GUILayout.Space(10f);

            EditorGUILayout.BeginVertical(GUI.skin.GetStyle("GroupBox"));

            GUILayout.Label(new GUIContent("Dialog Player Controls"), playbarHeader);

            GUILayout.Space(10f);

            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            EditorGUI.BeginDisabledGroup(!Application.isPlaying);

            playerInstance.playerState = GUILayout.Toggle(playerInstance.playerState == DialogPlayer.PlayerState.Playing,
                                                          new GUIContent(symbolPlay, "Plays the Canvas"), playbarPlay)
                ? DialogPlayer.PlayerState.Playing : playerInstance.playerState;
            playerInstance.playerState = GUILayout.Toggle(playerInstance.playerState == DialogPlayer.PlayerState.Paused,
                                                          new GUIContent(symbolPause, "Pauses the Player"), playbarPause)
                ? DialogPlayer.PlayerState.Paused : playerInstance.playerState;
            playerInstance.playerState = GUILayout.Toggle(playerInstance.playerState == DialogPlayer.PlayerState.Stopped,
                                                          new GUIContent(symbolStop, "Returns to the Canvas' start"), playbarStop)
                ? DialogPlayer.PlayerState.Stopped : playerInstance.playerState;
            playerInstance.playerState = GUILayout.Toggle(playerInstance.playerState == DialogPlayer.PlayerState.Skip,
                                                          new GUIContent(symbolSkip, "Forces a new Update of the current Node"), playbarFastForward)
                ? DialogPlayer.PlayerState.Skip : playerInstance.playerState;

            EditorGUI.EndDisabledGroup();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            player.isAutoplay        = GUILayout.Toggle(player.isAutoplay, "Autoplay", EditorStyles.miniButtonLeft, GUILayout.Width(96f));
            playerInstance.pauseGame = GUILayout.Toggle(playerInstance.pauseGame, "Pause Game", EditorStyles.miniButtonRight, GUILayout.Width(96f));

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            Node lastHub = playerInstance.GetCurrentHub();

            EditorGUI.BeginDisabledGroup(lastHub == null);

            int count = playerInstance.registeredHubs.Count;

            if (GUILayout.Button("Return to Hub: " + count + "/" + count, EditorStyles.miniButton, GUILayout.Width(192f)))
            {
                playerInstance.CheckHubs();
            }

            EditorGUI.EndDisabledGroup();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            EditorGUI.BeginDisabledGroup(lastHub == null);

            if (GUILayout.Button("Discard Hub: " + count + "/" + count, EditorStyles.miniButton, GUILayout.Width(192f)))
            {
                playerInstance.DiscardHub();
            }

            EditorGUI.EndDisabledGroup();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            EditorGUI.BeginDisabledGroup(lastHub == null);

            if (GUILayout.Button("Discard all Hubs", EditorStyles.miniButton, GUILayout.Width(192f)))
            {
                playerInstance.registeredHubs.Clear();
            }

            EditorGUI.EndDisabledGroup();

            GUILayout.Space(((Screen.width - 40f) - 192f) / 2f);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            GUILayout.Space(5f);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(new GUIContent("Dialog Name"));
            playerInstance.canvas = (DialogCanvas)EditorGUILayout.ObjectField(playerInstance.canvas, typeof(DialogCanvas), false);// DialogSettings.DialogsDropDown(playerInstance.dialogName);
            GUILayout.Space(5f);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10f);
        }
 public void ResetToStartNode()
 {
     player      = null;
     currentNode = canvas.startNode;
     registeredHubs.Clear();
 }