Forum rules - please read before posting.

OnClick event for hotpots?

Hi

I have the settings set to "see interactions with click on hotspot". However there doesn't appear to be an event for clicking on a hotspot. There's one for clicking the interactions of a hotspot, mouse over a hotspot, double clicking a hotspot, but none of them seem to fire if I click to show the interactions.

I may be able to do it on the OnMenuShowOn event but that won't give me the hotspot and I'm also trying to capture the event BEFORE the menu shows, which won't help there.

Any ideas how I can do that? Can that event be added?

Olly

Comments

  • It sounds like the OnEnableInteractionMenus is what you're looking for. It's script-only, so you'd use something along the lines of:

    void OnEnable () { EventManager.OnEnableInteractionMenus += OnEnableInteractionMenus; }
    void OnDisable () { EventManager.OnEnableInteractionMenus -= OnEnableInteractionMenus; }
    
    void OnEnableInteractionMenus (Hotspot hotspot, InvInstance invInstance)
    {
        //
    }
    
  • edited August 2023

    Thanks Chris. One more thing on that note. Is there a way for an interaction Menu (when using a Unity UI prefab) to know which hotspot was clicked to trigger the interaction menu to appear?

    Is that passed somewhere? THat would allow me to gather some data from a custom component on the Hotspot object.

    Or is there a way to access the gameobject of a Menu when it's TurnOn'd, or access a custom component on that menu? That would allow me to send it some data for the menu.

    Olly

  • Yes - it'll be assigned to the Menu's TargetHotspot property.

  • Thanks Chris. Will take a look and see if that exposes the hot-spot game object and or its components.

    If not I'll go back to passing values via AC variables but it doesn't feel nice having anotger layer between components to move data through.
  • Thanks Chris. Can I ask for a bit of help? In your example above, in OnEnableInteractionMenus I have this;

    if(hotspot.getfulllabel(0) == myHotspot.getfulllabel(0))
    {
                Menu popupMenu = PlayerMenus.GetMenuWithName("Interaction");
                popupMenu.TurnOn();
                Debug.LogWarning(popupMenu.TargetHotspot);
    }
    

    However, my popupMenu.TargetHotspot is always Null. Any ideas? I'm doing something wrong I know it.

  • I should say (doesn't let me edit for some reason) that when the menu is set to Appear On Interaction then the above works, debug outputs the hotspot name. However when the Appear On for that menu ("Interaction") is set to Manual then it doesn't get the hotspot name.

    I want to use Manual as with On Interaction the player can click anywhere to close the menu, but I want to force them to use a Close button on the UI to close the menu.

  • edited August 2023

    The "TargetHotspot" property is only automatically assigned to a Menu if its set to appear On Interaction.

    If set to Manual, then you'll need to assign it manually - which can be done with the MatchInteractions function:

    popupMenu.MatchInteractions (hotspot);
    
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.