Forum rules - please read before posting.

Dynamically prefix hotspot label

I am using 'choose hotspot then interaction', and my hotspot menu is a Unity UI prefab.

In 'Cursor' -> 'Hotspot cursor' I have checked 'Prefix cursor labels', however when I run the game, click a hotspot, and hover over an interaction icon, the hotspot label still only displays the hotspot's name without a prefix.

I'm not sure if 'Prefix cursor labels' only works if my hotspot menu is set to an 'Adventure creator' source, but even if I set it to AC source, my hotspot label still only displays the hotspot's name.

Anyway, I'd to be able to dynamically prefix my hotspot label in a totally customizable way. I.e. to not just prefix with 'Use', 'Look at', etc., but to be able to specify a custom prefix for each interaction type for each hotspot, such that if I click on my 'TV' hotspot and hover over the 'Use' icon, my hotspot label will display 'Turn on TV' (instead of just 'Use TV').

Also I need to be able to dynamically change the prefixes based on variable values - e.g. such that for my 'TV' hotspot I can have a bool variable 'TVTurnedOn', the value of which I change to 'true' and 'false' with actionlists, and then depending on whether TVTurnedOn is currently true or false, if I click the TV hotspot and hover over the Use icon, my hotspot label will display either 'Turn on TV' or 'Turn off TV'.

What would be the best way to achieve this?

Comments

  • edited September 2018
    Hi, I've recently worked on something very similar that allows you to specify a custom hotspot prefix dependant on which inventory item you are using on which hotspot. You can see the full code here: https://www.adventurecreator.org/forum/discussion/7987/override-use-syntax You could amend the script to reference a variable and then provide the relevant prefix depending on it's state. To make it generic, you could just have a integer state value attached to the object, and use the editor to add different prefixes based on the integer value. Then you could use it on any object. I hope this is of some help? Kev
  • Thank you @KevRev !

    I will take a look at that. I'm not a very seasoned scripter, and it's been a while since the last time I worked with C#, so it'll probably take me some time to decipher your scripts.

    Do your scripts also work for interactions that don't involve inventory items? I.e. plain 'use', 'look at', etc.?
  • I've only coded it to look at invitems, but it should be pretty easy to include the other actions too. I say easy... I'm rusty with c# too and it took me days to get that right! Lol
  • The intended way to do this is to create separate Icons for each verb, and then select those specific verbs in the Hotspot Inspector.

    Though they might share the same "use" icon, you'd then have separate "Turn On" and "Turn Off" verbs defined in the Cursor Manager.

    Creating a separate interaction for each in the Hotspot Inspector, you'd then disable the "Turn Off" Interaction by default (assuming the TV is off to begin with), and then use the Hotspot: Change interaction Action to disable "Turn on" and enable "Turn off" as part of the "Turn on" interaction.

    (To simplify your variables, you could then also use the Hotspot: Check interaction instead of setting/checking a dedicated variable, provided it was local).

    As for having prefix labels show up at all, the interface you've described matches the 2D Demo.  Labels will show up regardless of the Menu's Source property - are you relying on the default interface?
  • @ChrisIceBox I'm not sure what you mean, if I'm 'relying on the default interface'?

    My 'interaction method' is 'Choose hotspot then interaction', 'Select interactions by' is set to 'Clicking menu', and 'See interactions with' is set to 'Click on hotspot'. My interaction menu is a Unity UI Prefab with appear type 'On interaction', my Interaction elements are hooked up to the respective cursors, and the cursors have different labels.

    What I'd like is when I click on a hotspot and the interaction menu appears, when I hover over one of the interaction buttons, my hotspot label should prefix the label value of the cursor hooked up to that interaction element. But right now my hotspot label is only showing the name of the hotspot with no prefix.
  • By the default interface, I'm referring to the standard set of Menus that the New Game Wizard assigns you, if you opt to make use of them.  The Pause, Hotspot, Interaction menus etc - see the Manual's "The default interface" chapter.

    Again, what you're describing is the behaviour of the 2D Demo - please try it and confirm.  You can load it in your own project via the top toolbar - just be sure to re-assign your own game's Managers afterwards.  See the Manual's "Running the demo games" chapter.

    What are your AC/Unity version numbers?
  • @ChrisIceBox thanks for clarifying.

    I'm currently using AC version 1.64.5 and Unity version 2018.2.8f1.

    I'm not using the standard menus, I created new ones myself. Like I mentioned earlier, I have checked 'Prefix cursor labels' under 'Hotspot cursor', and I thought this was supposed to prefix the label string of the interaction icon I'm currently hovering over. But perhaps I'm misunderstanding something?
  • As Chris suggested, backup your game managers, then import the 2d demo ones. See if the prefix works properly there, and it'll help rule out issues with your menus etc.
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.