Can't click on a button; nothing happens when clicking
Hi Guys,
I have a Problem with the buttons. I'm currently working with Unity 5.3.1.f1. So I have a Panel in a Canvas in which I have buttons (named 1-4).
As you can see on one of the Buttons I have added a function of a script, which should change from Pause to the game so I can play on (Button 1/"SPIEL FORTSEZTEN" in Pic #1). The function used is the last one in the following sript. I even added a little Animation which should make it bigger when it's highlighted, but neither I can resume the Gameplay nor is there an Animation when I get over the button with my mouse.
"PauseManager" is an empty GameObject onto which the script "Pause" is attached. "HudCanavas" is a Canvas. (obviously) "Panel" is a Panel. (no Shit Sherlock) 1/2/3/4 are buttons.
(Sorry for any mistakes as I'm not a native speaker)
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using System;
using UnityEngine.EventSystems;
public class Pause : MonoBehaviour
{
public GameObject panel;
public bool isPaused;
void Start()
{
isPaused = false;
}
void Update()
{
if(isPaused)
{
GamePause(true);
}
else
{
GamePause(false);
}
if(Input.GetKeyDown (KeyCode.Escape))
{
SwitchPause();
}
}
void GamePause(bool state)
{
if(state)
{
Time.timeScale = 0.0f; //Pause
}
else
{
Time.timeScale = 1.0f; //Pause zuende
}
panel.SetActive(state);
}
public void SwitchPause()
{
if(isPaused)
{
isPaused = false;
panel.SetActive(false);
Debug.Log("YEEEEEEEEAAAAAAAAH");
}
else
{
isPaused = true;
}
}
}
Time.timeScale = 0.0f;
Look at the Timescale page in the docs and you will find your answer.
How can I change it, so it is paused but I'm still able to interact with buttons?