If you're starting a conversation with the player without using a Dialogue System Trigger, the player will still receive "OnConversationStart" and "OnConversationEnd" events, so you can add a Dialogue System Events component or a script to the player, like this one:
ConversationGameControl.cs
Code: Select all
using UnityEngine;
public class ConversationGameControl : MonoBehaviour
{
public bool pauseGameDuringConversation = true;
public bool showCursorDuringConversation = true;
private float previousTimeScale;
private bool previousCursorVisible;
void OnConversationStart(Transform actor)
{
if (pauseGameDuringConversation)
{
previousTimeScale = Time.timeScale;
Time.timeScale = 0;
}
if (showCursorDuringConversation)
{
previousCursorVisible = Cursor.visible;
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
}
void OnConversationEnd(Transform actor)
{
if (pauseGameDuringConversation)
{
Time.timeScale = previousTimeScale;
}
if (showCursorDuringConversation)
{
Cursor.visible = previousCursorVisible;
Cursor.lockState = previousCursorVisible ? CursorLockMode.None : CursorLockMode.Locked;
}
}
}