Hello!
Is there a way for AC to identify the choices made on a TMP dropdown and change a variable value accordingly?
I am not sure the above sentence was clear, so here goes another attemp to explain my problem: my game includes TMP dropdown menus in which players should make choices. Correct answers will add points, which at a specific point wil define how their gameplay advances. As I see it, I need pairings to affect variables (or one variable)
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Is the Dropdown part of an AC menu, or treated independently?
If your game uses AC's provided TMPro integration, you can link Cycle menu elements to TMP Dropdown components - allowing you to sync its value with an AC Global Variable.
To do this, enable AC's integration by adding "TextMeshProIsPresent" to your project's Scripting Define Symbols, and then set your Cycle element's UI basis property to Linked Dropdown.
Otherwise, you'll need to extract the Dropdown's value through script, which can be read with:
This value can then be assigned to an AC Global Float value with:
Thanks, Chris.
The dropdown is not part of an AC menu, but I'm going to change that because, living proof of the miracles performed by the AC that I am, I wouldn't know how to include the scripted lines.
I'll return to let you know if I succeed, or ask for further help if I don't
And back I am, in need of help on how to assign the Dropdown to the Menu's "Linked Dropdown" field. It works fine with Buttons (Linked Button) but does not recognise Dropdowns
(in case it is of any use, screen image link at https://drive.google.com/file/d/17tng4JWuTm5_ptdjZE8MNqGadzDkUe9k/view?usp=sharing )
Thank you in advance
The AC Menu currently expects a regular Unity UI Dropdown - not a Text Mesh Pro one. Though they function similarly, they're technically separate components - so you need to tell AC to use TMPro instead.
You can do this by entering "TextMeshProIsPresent" as a Scripting Define Symbol in Unity's Project settings.
Bear in mind, however, that this is a global setting: AC will now rely on TMPro variants for all Text-related UI components, e.g. TMPro Text instead of Unity UI Text. You'll now be able to use TMPro Dropdown, but you'll also need to switch over to TMPro for Text boxes for any other Unity UI-based Menus.
I had done that. I tried starting a new project from scratch and it still does not find the dropdown (image, in case it helps - https://drive.google.com/file/d/1lb0mx3e6c4h3h-5UFyBt9fDWWcnoRJwR/view?usp=sharing)
Your AC version doesn't support it - the ability to map TMPro Dropdowns was introduced in v1.76.2.
Updating AC will allow for this. If you'd like to keep your current version, you can import the latest release into a fresh project, and copy over the MenuCycle script to your project (backing up first).
this was great news - I already have a version of my project using 1.78 (I just tend not to test anything on it)
Thank you, Chris, you have saved my project again!
I tried everything I could think of to avoid bothering the forum folk (most likely Chris) again but I cannot get my head around how to sync a variable according to dropdown choices selected. I have tried to do it with the dropdown in a menu, as suggested above, and also with an independent dropdown (fiddling with the VariableLinkingExample.cs), as either would suit my needs.
Images A and B show my basic setting with the dropdown as part of a menu. I guess there is something very obvious missing, but I haven't got a clue what
Thank you in advance,
Sue
IMAGE A https://drive.google.com/file/d/1lebR6vgsTI-03Sw4n_eIwZT5M03BgJdn/view?usp=sharing
IMAGE B https://drive.google.com/file/d/1vhzUAtc0SCs1Pg5BR0ABzZF7pIx__osP/view?usp=sharing
To correct myself above: its Integer and PopUp variables that get linked, not Float - though you've already made this correction going by your screenshots.
If you're linking the Variable directly in the Menu Manager, set its Link to property back to None.
What's the exact behaviour of the element in-game? When linked to a PopUp, the Dropdown values should take the number and form of the PopUp's labels. Is the Dropdown being updated automatically to reflect the PopUp it should be linked to?
on sheer gut feeling
several dropdowns, which become cumulatively available for the player, must be used to select correct answers for each case (image DD-1 https://drive.google.com/file/d/1SX8EUE1fH2rV6LB-TnWmEbztPeNwJYUG/view?usp=sharing)
hmn, no...
I am not sure I understood the implications of your questions, so I will describe how the dropdowns are used and when I really need the variable(s):
There are 14 dropdowns, all have the same text-labeled options (image DD-1 https://drive.google.com/file/d/1SX8EUE1fH2rV6LB-TnWmEbztPeNwJYUG/view?usp=sharing). The player must see all the options (preferably at once)
As the game progresses, the player finds clues indicating each case's most likely option. A custom script (SaveDropdownValue.cs https://drive.google.com/file/d/1oXVvtpJDUKFxhT91ZLD1Kyo58NRNOu_8/view?usp=sharing ) (generously made for me by one of my previous design students) has been added to each dropdown as a component to save the selections
At one point, there is a "last chance to change the selections" warning
After the player makes final adjustments, the game proceeds to one of 8 endings
As I see it, it would be a matter of (A) checking the option chosen in each dropdown, (B) adding or subtracting accordingly to define a final score, then (C) use this final score to define which action is going to be triggered
The previously mentioned ex-student created a script that is likely to be taking care of (A - Resultado.cs https://drive.google.com/file/d/1Rz1x0UqVs1IqDKpjUsi4RqkQ-HW4bBJo/view?usp=sharing) but, not being an AC user, he could not help me with C (this is why I was fiddling with VariableLinkingExample.cs but, although everything is described and explained very clearly, it is beyond my abilities)
Thank you again,
Sue
So long as the Dropdown and Variable can get properly linked, there'll be no need for a custom script. AC Variables are saved automatically, and the Variable: Check / Variable: PopUp switch Actions can be used to run extra logic if they have certain values.
When a Dropdown is linked to a PopUp variable, its available values should match those of the PopUp's labels - in your example's case: "0", "1" and "2".
For your existing Dropdown that isn't linking correctly: do the Constant ID values match, and do you get any related Warning messages in the Console at runtime?
It might be worth trying things afresh, with a new PopUp variable and TMPro UI Dropdown component created in a new Menu in the Menu Manager. Make sure the Variable's Link to is set to None, and the Cycle element's Cycle type is set to Variable. With the absence of any extra scripts, are the two then able to link together?
unfortunately the answer appears to be no
Built from scratch:
1) the dropdown - https://drive.google.com/file/d/1caaazKuqfQQnO3hiAeNtyegRJj2qRxYu/view?usp=sharing
2) the variable - https://drive.google.com/file/d/1yR7PT7j5lSMBqllMylOx51VqpeWJg7Xn/view?usp=sharing
3) the menu - https://drive.google.com/file/d/1JIap2ke8v4uczMyg1958jVAcN5x_Ttj-/view?usp=sharing
4) the logic - https://drive.google.com/file/d/1TvcuZ9Gmb2UmaQnCRbpeOxBXZjpOZEaI/view?usp=sharing
5) the result -
option 0 - https://drive.google.com/file/d/1Hy5YMICppYdUJ-wxYhk1eCh2Brr7P0kl/view?usp=sharing
option 3 - https://drive.google.com/file/d/1x08_bWWwqYVw5tPm_1GrxfoqODHvE34W/view?usp=sharing
option 5 - https://drive.google.com/file/d/1Q5wVywHz_CF1bCBG9GmNHnX5VcSH2FWN/view?usp=sharing
sorry for taking so much from your time and thank you in advance
Going by the screenshots, I'm seeing a couple of things to note:
Be sure to drag in the Canvas object in your Hierarchy into this field, and then save the scene, to link it to the Menu.
It's typically easier to work with Unity Ui Prefab mode, however, as it makes the Menu available in any scene. Unity Ui In Scene mode is typically best for 3D menus that need to appear in a specific part of a given scene.
Try making the Canvas a prefab, removing it from the scene, switching to Unity Ui Prefab, and then assigning the prefab in this field. If the link is succesfull, AC will then spawn the prefab into the scene when the Menu is turned on.
it makes sense but unfortunately, I did not manage to link the Canvas successfully
what I did:
a) as Unity Ui Prefab Menu does not have the Linked Canvas field, I placed the Canvas prefab in RectTransform boundary (Image-1 https://drive.google.com/file/d/1GmH0bcsQGimogLmpFeZ8HsqtWFZ0-aPW/view?usp=sharing)
b) having found the warning about Addressables, I imported the Unity's package and added AddressableIsPresent to the Scripting Define Symbols box (Image-2 https://drive.google.com/file/d/1InzGq2_5QSIfFkkvRXTYnc4IZOZTQtSd/view?usp=sharing)
c) opened the Canvas prefab and made sure it was an addressable (Image-3 https://drive.google.com/file/d/1pqO4jj35S3HxEnmXQ_gB9LniVuaeriFa/view?usp=sharing)
d) the Canvas with the dropdown was not spawn (Image-4 https://drive.google.com/file/d/12JftcBbTy-7Rh6iUL1q0y43-ek_Zxgx_/view?usp=sharing) and clicking the hotspot always returns a yes (as if one of the options of the dropdown - which is not the default - had been selected)
Action List is triggered by a hotspot associated with the gray image in Image-0 https://drive.google.com/file/d/1caaazKuqfQQnO3hiAeNtyegRJj2qRxYu/view
Let's stay away from Addressable for the moment - it's adding another layer of complexity into the mix.
Uncheck the Menu Manager's Use Addressables for UI prefab references? option and the "Linked Canvas" field will re-appear. Assign the prefab in the field, and then remove / disable the original Canvas in the scene (so as not to have duplicates when the prefab is spawned in at runtime).
ok... now the Canvas prefab spawns but the connection between the Dropdown and the variable appears to be missing (Image-5 https://drive.google.com/file/d/1_hkIVyTOGzeBaQAwvnOOVdDveA-POg8g/view?usp=sharing)
in addition to the above, the hotspot no longer works even when the actions in the associated ActionList are totally independent of the menu or the variable (it returns to working when that specific menu is disabled or if I remove the Canvas prefab from its Linked Canvas field)
(sorry for needing so much help)
The apologies should be mine, as it looks like there is an issue with this final step. The Dropdown links, but it appears to become severed after changing an option.
What are your AC and Unity versions?
Stand by - I'll look into this and see what the issue is.
Well.. this is odd. I can't recreate the issue anymore.
Let me know your versions, and if you can: PM me your Manager asset files, as well as the Canvas-test prefab your Menu refers to. I'll see if I can spot the issue.
thank you very much, everything works fine now