Exemplo n.º 1
0
    public void OpenMenuButtonClick()
    {
        InteractiveObject selectedObject = SelectorMenu.Instance.GetSelectedObject();

        if (selectedObject is null)
        {
            return;
        }

        if (!SelectorMenu.Instance.gameObject.activeSelf && !OpenMenuButton.GetComponent <Image>().enabled) //other menu/dialog opened
        {
            SetActiveSubmenu(CurrentSubmenuOpened);                                                         //close all other opened menus/dialogs and takes care of red background of buttons
        }

        if (OpenMenuButton.GetComponent <Image>().enabled)
        {
            OpenMenuButton.GetComponent <Image>().enabled = false;
            SelectorMenu.Instance.gameObject.SetActive(true);
            selectedObject.CloseMenu();
        }
        else
        {
            OpenMenuButton.GetComponent <Image>().enabled = true;
            SelectorMenu.Instance.gameObject.SetActive(false);
            selectedObject.OpenMenu();
        }
    }