Hi Chris,
I’m experiencing an issue where the inventory UI text does not update when the language is changed. I attempted to use the DynamicFontLanguage script, but it had no effect.
The inventory UI is implemented using Unity’s legacy Text component rather than TextMeshPro. Unfortunately, migrating to TextMeshPro isn’t an option, as the inventory script does not support TMP components.
Given these constraints, do you have any suggestions on how to force the inventory text to update correctly when the active language changes?
https://prnt.sc/yHPaG9Vr9F04
https://prnt.sc/sQAc42O0O6t-
https://prnt.sc/3E55dyKXbsIq
Inventory script:
using UnityEngine;
using AC;
public class InventoryHandler : MonoBehaviour
{
public Canvas canvas;
public AudioClip noHotspotSound;
void OnEnable () => EventManager.OnMenuElementClick += OnMenuElementClick;
void OnDisable () => EventManager.OnMenuElementClick -= OnMenuElementClick;
void OnMenuElementClick (Menu menu, MenuElement element, int slot, int buttonPressed)
{
if (menu.RuntimeCanvas != canvas) return;
MenuInventoryBox inventoryBox = element as MenuInventoryBox;
if (inventoryBox == null) return;
InvInstance clickedInstance = inventoryBox.GetInstance (slot);
if (!InvInstance.IsValid (clickedInstance)) return;
if (clickedInstance.InvItem.useActionList)
{
clickedInstance.Use (false);
menu.TurnOff ();
return;
}
var hotspot = KickStarter.player.hotspotDetector.GetSelected ();
if (hotspot == null || !hotspot.HasInventoryInteraction (clickedInstance.InvItem))
{
if (KickStarter.sceneSettings.defaultSound && noHotspotSound)
{
KickStarter.sceneSettings.defaultSound.audioSource.PlayOneShot (noHotspotSound);
}
return;
}
hotspot.RunInventoryInteraction (clickedInstance);
menu.TurnOff ();
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
The Inventory script makes no mention of Text objects, I'm not clear on your meaning about it not being compatible with TextMesh Pro.
The DynamicFontLanguage script simply changes which Font is used - it won't affect the text itself. Is it the Font you're looking to change, or the text?
The text displayed in Inventory menus is pulled from the Inventory Manager - not the Menu Manager. The Speech Manager lists Item names under the "Inventory Item" category - is your Flashlight item listed there with its translations?
Hi Chris,
Sorry, please ignore the inventory script part. AndI’m not looking to change the font—I just want the inventory items to display the other translations."
The text displayed in Inventory menus is pulled from the Inventory Manager - not the Menu Manager. The Speech Manager lists Item names under the "Inventory Item" category - is your Flashlight item listed there with its translations?
Yes, the flashlight is an inventory item and it’s listed with its translations. However, it always displays the English version instead of the other languages.
https://prnt.sc/_eQwEVGsWOIU
https://prnt.sc/Z513jj55OfUE
https://prnt.sc/SlyGHM5uU-3N
The ItemDesc menu element isn't set to display Item names, but a custom "DisplayName" property. Is this appearing in the Speech Manager? It will be under the "Inventory Property" category.
I completely forgot to include "Inventory Property" in the translatable text type. I’ve now ticked "Inventory Property" and re-gathered the text, so I can see the inventory translation. Thanks a lot for your help, Chris!