Hi there im working on a pause menu and i have a couple of issues with it firstly when i call the pause menu it appears but the game doesnt actually pause the dialogue still types out. And secondly when i click on the button that has the onClick event to hide the pause menu it doesnt hide it despite the button having the onClick event. Im not too worried about the actually pausing for now, ill work on that next my main concern right now is why its not hiding the pause menu any ideas?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DialogueScript : MonoBehaviour
{
public static int TextboxCounter = 0;
public int index = 0;
public int referenceToTextboxCounter;
DialogueSystem dialogue;
public GameObject pauseMenu;
public static bool isPaused = false;
public string[] s;
private void Awake()
{
referenceToTextboxCounter = TextboxCounter;
}
void Start()
{
dialogue = DialogueSystem.instance;
dialogue.Say(s[index]);
index++;
TextboxCounter ++;
referenceToTextboxCounter++;
}
// Update is called once per frame
void Update()
{
if(isPaused == false)
{
if (Input.GetMouseButtonDown(0))
{
if (!dialogue.isSpeaking || dialogue.isWaitingForUserInput)
{
if (index >= s.Length)
{
SceneChange();
}
Say(s[index]);
index++;
TextboxCounter++;
referenceToTextboxCounter++;
}
}
else if (Input.GetKeyDown(KeyCode.Return))
{
if (!dialogue.isSpeaking || dialogue.isWaitingForUserInput)
{
if (index >= s.Length)
{
SceneChange();
}
Say(s[index]);
index++;
TextboxCounter++;
referenceToTextboxCounter++;
}
}
else if (Input.GetKeyDown(KeyCode.Space))
{
if (!dialogue.isSpeaking || dialogue.isWaitingForUserInput)
{
if (index >= s.Length)
{
SceneChange();
}
Say(s[index]);
index++;
TextboxCounter++;
referenceToTextboxCounter++;
}
}
}
if (Input.GetMouseButtonDown(1))
{
if (pauseMenu != null)
{
isPaused = true;
pauseMenu.SetActive(true);
}
}
}
void Say(string s)
{
string[] parts = s.Split(':');
string speech = parts[0];
string speaker = (parts.Length >= 2) ? parts[1] : "";
dialogue.Say(speech, speaker);
}
public void SceneChange()
{
if (TextboxCounter == 10)
{
SceneManager.LoadScene(7);
}
else if (TextboxCounter == 21)
{
SceneManager.LoadScene(8);
}
else if (TextboxCounter == 32)
{
SceneManager.LoadScene(9);
}
else if(TextboxCounter == 42)
{
SceneManager.LoadScene(10);
}
}
public void returnToGame()
{
if(pauseMenu.activeSelf && isPaused == true)
{
if(Input.GetMouseButtonDown(0))
{
pauseMenu.SetActive(false);
isPaused = false;
}
}
}
}