Highlight Button not working
It was working before I made the script, then put it into the main camera and also change the input cancel to pause. I was following this video(https://www.youtube.com/watch?v=xIevsYimJYc) but the highlight stop working for me at the end. I tried to make another button unrelated to the script and main camera but it still didn't work. I also downloaded a button example project and that one seem to work. I am thinking that it has something to do with input but I compare the input for both project and I don't see any differences.
Hello. I would recommend you go back through the video tutorial and check your code carefully.
If you are still struggling to solve your problem then posting the code will help, otherwise it's just guess work.
This is the code that i follow from the video, I went ahead and add the resume function as well to see if the click works and that doesn't seem to work as well. Which made me believe that its not recognizing mouse actions.
using UnityEngine;
using System.Collections;
public class Pause$$anonymous$$enu : $$anonymous$$onoBehaviour
{
public GameObject PauseUI;
private bool paused = false;
void Start()
{
PauseUI.SetActive(false);
}
void Update()
{
if(Input.GetButtonDown("Pause"))
{
paused = !paused;
}
if(paused)
{
PauseUI.SetActive(true);
Time.timeScale = 0;
}
if(!paused)
{
PauseUI.SetActive(false);
Time.timeScale = 1;
}
}
public void Resume()
{
paused = false;
}
}
TL;DR Stick a Debug.Log Statement inside the below condition I identified or use a breakpoint.
A quick check would be to run the game in debug mode and stick a breakpoint as identified below. Check perform the Pause action and check to see if it hit's the breakpoint. If you don't know how to use breakpoints then check out: https://unity3d.com/learn/tutorials/modules/beginner/scripting/monodevelops-debugger
if(Input.GetButtonDown("Pause"))
{
paused = !paused; //Add a breakpoint here
}
Edit: That will check to see if the button press is working. I believe Unity flags any problems in the log window if the name of the button was incorrect. Also check Unity3d > Edit > Project Settings > Input. Confirm Pause is defined as an Input and check the Type is set to "$$anonymous$$ey or $$anonymous$$ouse Button" and "Positive Button" has the value "mouse 1" or "mouse 2" depending on 1st or 2nd mouse button (no quotation marks).
Answer by linzhijun · Oct 29, 2015 at 01:30 PM
Did what you told me and when I went to concole/Clear on play I saw that it wanted me to make an input Cancel which I change to Pause. So i change that back and use an extra input and change that one to pause instead after that everything seems to work again. Thank you