ARTICLE AD BOX
I'm developing a game in Unity and I'm stuck on a problem I've been debugging for almost two days.
I have a LockedDoor script that allows the player to interact with a door by pressing E.
The interaction itself works correctly (dialogue starts, door unlocks, etc.), but the UI interaction prompt never shows.
The weird part is that:
I'm using the exact same logic in other scripts (dialogues, scene transitions)
In those scripts, the UI works perfectly
Here, the string never appears at all
I verified that:
The player enters the trigger correctly
Pressing E works
Localization is not the issue (I even added a debug fallback string)
Layers and colliders are correct
Forcing ui.target manually didn’t help either
The code below is never executed, even though the conditions should be met.
if (ui.target == null || ui.target == this.transform) { ui.target = this.transform; ui.Show(GetInteractionPrompt()); }Update
private void Update() { if (isOpened) return; if (playerInRange) { bool canInteractNow = CanInteract(); var ui = Inventory.UI.UIInteractionPrompt.Instance; if (ui == null) return; if (canInteractNow) { if (ui.target == null || ui.target == this.transform) { ui.target = this.transform; ui.Show(GetInteractionPrompt()); } if (Keyboard.current.eKey.wasPressedThisFrame) { CheckKey(); } } else { if (ui.target == this.transform) { ui.Hide(); ui.target = null; } } } }Interaction checks
public bool CanInteract() { if (isOpened) return false; if (DialogueManager.Instance != null && !DialogueManager.Instance.CanStartDialogue()) return false; if (Documents.DocumentManager.Instance != null && !Documents.DocumentManager.Instance.CanStartInteraction()) return false; if (!requireSpecificDirection) return true; return IsPlayerInCorrectDirection(); }Trigger detection
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { playerInRange = true; playerTransform = other.transform; } } private void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("Player")) { playerInRange = false; var ui = Inventory.UI.UIInteractionPrompt.Instance; if (ui != null && ui.target == this.transform) { ui.Hide(); ui.target = null; } } }Interaction prompt
public string GetInteractionPrompt() { string localized = interactionPrompt.GetLocalizedString(); if (string.IsNullOrEmpty(localized)) return "DEBUG: TEST PORTA"; return localized; }What I don’t understand
The same UIInteractionPrompt system works in other scripts
playerInRange is true
CanInteract() returns true
Pressing E works
But ui.Show() is never called (or has no visible effect)
What could prevent this UI from showing only in this script, even though the logic is identical?
Any help would be hugely appreciated 🙏
