Forum rules - please read before posting.

Feature request: Show all hotspot texts

edited October 2014 in Engine development
Hi,

I'm aware about the FlashHotspots script which highlights hotspots when the input key is pressed. I'm looking for similar functionality: When an input key is pressed down (tab for instance), all hotspot text descriptions should be shown.

This is a quite common feature, especially in 2d adventure games. So I would appreciate a standard solution for this.

Comments

  • Not through the standard menu system - since you'd need to create one menu for each possible on-screen hotspot, and it wouldn't be a good way of working.

    Instead, you can use a simple custom script to read the object's highlight amount, and display a GUI text box as needed.  The Highlight script has a public function, GetHighlightIntensity (), which returns a float ranging from 0 to 1.  You can therefore write a script that accesses it's GameObject's Highlight component, reads the intensity value, and displays a label if necessary.
  • I'm trying to do something similar to this, though just displaying an icon over each hotspot. I'm having difficulty getting it to work. Currently I am trying to find all active hotspots and create an instance of a simple "graphic" menu over each hotspot. I'm able to find the hotspots but not able to create an icon over each. Any thoughts on what I'm doing wrong? I tried leveraging the existing FlashHotspots() function as a base:

    private void FlashHotspots ()
    {
    Hotspot[] hotspots = FindObjectsOfType (typeof (Hotspot)) as Hotspot[];
    snoopMenu = AC.PlayerMenus.GetMenuWithName ("Snoop");
    foreach (Hotspot hotspot in hotspots)
    {
    if (hotspot.IsOn () && hotspot != KickStarter.playerInteraction.GetActiveHotspot ())
    {
    AC.Menu hotspotSnoopIcon = snoopMenu;
    hotspotSnoopIcon.Copy (snoopMenu);
    Debug.Log(hotspot.GetIconScreenPosition ().ToString());
    hotspotSnoopIcon.SetPosition( hotspot.GetIconScreenPosition () );
    hotspotSnoopIcon.TurnOn(true);
    }
    }
    }


  • Copying menus mid-game isn't guaranteed to work, but you may get lucky.  However, you need to add the copied menu onto the PlayerMenu script's list of Menus:

    AC.KickStarter.playerMenus.menus.Add (hotspotSnoopIcon);

    You'd then have to remove the Menu from the list once you want to turn it off - I'd recommend displaying a texture or icon through an OnGUI function instead, but see if that works at least.
  • I ended up using your recommendation and used Unity's GUI system rather than the menus. Thanks for the assistance.

    It's not the cleanest code ever, but here's the code in case others are interested.

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.