Forum rules - please read before posting.

Different Interactive UI on many Hotspot

edited November 2022 in Technical Q&A

Hello. In the Settings I have Interaction method "Choose Hotspot Then Interactive". I need to be able to assign my Interactive UI to each Hotspot with text names, not icons, but every time I have a prepared template in Unity UI with the Appear type "On Interactive". How can I make sure that I can assign a call to my Prefab UI to a separate Hotspot? Through Interactive methods "Custom Scripts"?
P.S. Reference Like in Sims. The circular interaction UI is unique for each object Hotspot

Comments

  • Welcome to the community, @Luxius.

    You can set your Interaction element's Display type property to Text Only to have it update the linked Button's Text child with the name of the Interaction, rather than the Image with the icon.

    To be clear: are you looking to display multiple interaction rings for different Hotspots at the same time? That would require custom scripting, yes.

    This typically involves locking the original Interaction menu, duplicating it, and then linking the copy to the intended Hotspot:

    private void ShowForHotspot (Hotspot hotspot)
    {
        Menu menuToCopy = PlayerMenus.GetMenuWithName ("Interaction");
        Menu myMenu = ScriptableObject.CreateInstance<Menu> ();
    
        myMenu.CreateDuplicate (menuToCopy);
        myMenu.appearType = AppearType.Manual;
        myMenu.isLocked = false;
        myMenu.title += this.name;
        myMenu.MatchInteractions (hotspot, false);
    
        // Turn the menu on
        myMenu.TurnOn ();
    
        // Register with PlayerMenus to handle updating
        KickStarter.playerMenus.RegisterCustomMenu (myMenu, true);
    }
    

    Have the interactions be arranged in a circle is a case of configuring your Unity UI prefab objects - AC won't strictly be involved in the styling of things. However, there are resources out there to help such as this one.

  • edited November 2022

    @ChrisIceBox Thanks for the quick response! Should I use this void on the hotspot object after I selected Custom Scripts in the Interaction Method?

    No, I don't need to display them at the same time. I need each Hotspot to have its own Interaction UI. For example, the object has a sofa: sit down, relax. On the kitchen stove: cook food, make coffee, make juice, etc.

  • For some reason, this script did not work for me. I tried this way, but for some reason both UI are activated when I click on Hotspot

    void Start()
        {
            _hotspotRef = GetComponent<Hotspot>();
            EventManager.OnHotspotSelect += ChangeInteractionUi;
            EventManager.OnHotspotDeselect += DisableInteractionUI;
        }
    private void ChangeInteractionUi(Hotspot hotspot)
        {
            initialMenu(AppearType.OnInteraction);
        }
    
    private void DisableInteractionUI(Hotspot hotspot)
        {
            initialMenu(AppearType.Manual);
        }
    
    private void initialMenu(AppearType type)
        {
            Menu menu = PlayerMenus.GetMenuWithName(_menuName);
            menu.appearType = type;
            menu.isLocked = false;
            menu.MatchInteractions(_hotspotRef, false);
        }
    
  • No, I don't need to display them at the same time. I need each Hotspot to have its own Interaction UI.

    The script I shared will duplicate the original Interaction UI so that it can be used to display for multiple Hotspots at the same time. If you're not looking to do that, the script won't be necessary.

    You might not need any custom scripting to achieve what you're looking for, if the styling of each Hotspot's Interaction UI is the same.

    If your Interaction UI has all of the possible icons defined as Interaction elements in the Menu Manager, you can check Auto-hide Interaction icons based on Hotspot? in the Settings Manager's "Interface settings" panel. This will cause the Interaction icons in the UI to hide if they aren't available for a given Hotspot.

    The 2D Demo demonstrates this when interacting with different Hotspots around the scene. Though the visuals are more basic than the "interaction ring" you mention, is this conceptually what you're asking about? It'll probably be best to share screenshots to elaborate if I'm misunderstanding.

  • edited November 2022

    The problem is that the UI for each Hotspot is not the same. Each can have a different number of elements with different names. Screenshot of the UI example
    https://ibb.co/tCBw9jr

  • edited November 2022

    So long as the styling is the same, you should be able to rely on the same Interaction UI.

    Again, AC can show/hide interaction elements dynamically based on the Hotspot involved. For example, if a Hotspot has "Use" and "Talk to" interactions, it won't show a "Look at" interaction even if a "Look at" interaction element is part of the Interaction UI.

    For that to work, however, you'd need to create a separate Interaction Icon in the Cursor Manager for each interaction label. "Make coffee", "Find a job", "Relax on the couch" etc.

    The alternative would be to rename your Interaction labels at runtime - so your Cursor Manager (and Hotspot Inspectors) would reference e.g. "Interaction A", "Interaction B" etc, and then you'd rely on a custom script - attached to the Hotspot - to dynamically alter the displayed labels in the InteractionUI as it turns on.

    Using your provided example, the Kitchen Stove and PC would then use Interation A, B, C, and the Sofa would use Interacton B and C only.

    Since you'd still be hiding these icons dynamically (so that e.g. some Hotspot show 2 interactions, others show 3), you'd still need to rely on the Auto-hide Interaction icons based on Hotspot? option to show/hide your defined interactions based on the clicked Hotspot.

    I can assist with such a custom script, but that'd be a secondary step - the first would be to get the interactions defined in the Cursor Manager, defined by the Hotspots, and shown/hidden dynamically of the Interaction UI - ignoring the wording of what's shown for now.

  • I just didn't know that it was possible to rename the names of interactions using Interaction UI methods. I will try and write later here how I solved this problem.

    Or I'll just add a lot of interactions A,B,C,D,E and etc and hide or show what is needed.

    Thanks for the support!

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.