- Home /
Button waits 3 clicks before working
Hi,
I have quite a problem here: I created a button "Menu" thats works like a dropdown. Basically, it makes a panel with icons appear/disappear (with Gameobject.SetActive()).
Here is the script for the dropdown menu. I attached it to the event OnClick().
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Drop_Down_Menu : MonoBehaviour
{
public GameObject panel;
private bool isActive;
public void Start ()
{
isActive = false;
panel.SetActive (false);
}
public void DropDown (GameObject panel)
{
if (isActive) {
panel.SetActive (false);
isActive = false;
} else if (!isActive) {
panel.SetActive (true);
isActive = true;
}
}
}
It seems to work quite well, except that I have to wait the 3rd click for it to activate and actually make my panel visible. I'm sure I've seen a topic like this in the forum, but I can't find it anymore.
Did anyone have the same problem before?
Thanks for your help!
I've got more information for you! After test, it seems that the problem occurs only on one scene. The one with an AR Camera (using the Vuforia SD$$anonymous$$ for Unity). On the other scenes without this camera the button works perfectly well. I'm working on it, but still have no idea...
Check if you are using Screen Space : Camera , if so change it to screenspace : overlay
Problem solved. I had the script attached also to another object, which created some confusion in the app. Thanks for the help anyway!
Your answer
![](https://koobas.hobune.stream/wayback/20220611230017im_/https://answers.unity.com/themes/thub/images/avi.jpg)