Forum rules - please read before posting.

Enabling Menu Element on MouseOver

I'm trying to enable a menu element to be visible when the mouse hovers over it. Currently, I have a menu titled Build and within it I have elements titled Warehouse and another titled Warehouse Stats. Is there a way to show the menu element Stats when the menu element Warehouse is being moused over?

Comments

  • Welcome to the community, @Arsenal52.

    As it's non-standard behaviour, this'd take a small bit of custom scripting. AC provides ways to both toggle an element's visibility, and check if the mouse is over a given element, through its API.

    Something like this ought to do it:

    using UnityEngine;
    using AC;
    
    public class ToggleStats : MonoBehaviour
    {
    
        public string menuName = "Build";
        public string elementToHover = "Warehouse";
        public string elementToShow = "Warehouse Stats";
    
        void Update ()
        {
            Menu buildMenu = PlayerMenus.GetMenuWithName (menuName);
            MenuElement warehouseElement = buildMenu.GetElementWithName (elementToHover);
            MenuElement statsElement = buildMenu.GetElementWithName (elementToShow);
    
            bool showStats = buildMenu.IsPointerOverSlot (warehouseElement, 0, KickStarter.playerInput.GetInvertedMouse ());
            statsElement.IsVisible = showStats;
        }
    }
    

    Place that in a new C# script named ToggleStats.cs, and add it as a component in your scene.

  • Thank you Chris will try it out!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.