Forum rules - please read before posting.

How to add a border when displaying text and background texture in the Hotspot Menu?

Hi Chris,

I am making a hidden object game. I want a string (a clue) to be displayed when mousing over the Inventory Items (hidden objects) at the bottom of the screen. I am using a container to store them.

I have set Hotspot Labels to be displayed and have left all label names blank except for the Inventory Items. I went to Settings > Menu > Hotspot > Label 0: 'HotspotLabel' Properties and set a background texture so the text is clear. It works well and looks like this:

1 - https://ibb.co/5xPX5qW

However, I don't want the text to touch the edges of the background. I have tried all the settings and can't enlarge it. I can add a texture to Settings > Menu > Hotspot > Menu 11: 'Hotspot' Properties and increase the element spacing and it looks great, but the background texture then displays when the mouse is over any Hotspot, leaving a square in the middle of the screen like this:

2- https://ibb.co/t3BWKYX

It is so close to working, can you recommend any tweaks? I just need a small gap between the edge of the text and the background textures so the text is clear to read.

Thank you in advance :smile:

Comments

  • For anything beyond very basic styling, I'd recommend using Unity UI to render your Menu instead of the built-in "Adventure Creator" option.

    You can enable this by setting the Source to Unity Ui Prefab, and then tweak its appearance by editing the Linked Canvas Prefab asset towards the bottom.

    However, the Menu will still appear even if the text inside is an empty string. To get around this, you'd need to lock the Menu when the mouse is not over the Menu that displays the Inventory items. When a Menu is "locked", it will not turn on even if its Appear type condition is met.

    There's a couple of ways you can do this, but the easiest is probably just to use a simple custom script:

    using UnityEngine;
    using AC;
    
    public class AutoLockHotspotMenu : MonoBehaviour
    {
    
        private void Update ()
        {
            Vector2 mousePosition = KickStarter.playerInput.GetInvertedMouse ();
            bool unlockHotspotMenu = PlayerMenus.GetMenuWithName ("Inventory").IsPointInside (mousePosition);
            PlayerMenus.GetMenuWithName ("Hotspot").isLocked = !unlockHotspotMenu;
        }
    
    }
    

    Replace the names "Inventory" and "Hotspot" with the names of your Menus, if they differ.

  • Thank you very much Chris! It works perfectly. I'm creatively gifted but a complete doofus when it comes to coding so I appreciate the help. One of the main themes for my current project is simplicity, so I'm sticking to the most basic methods wherever possbile. I will certianly learn more about Unity UI for the future though, cheers.

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.