Godot Version
4.2.1
Question
SOLVED
after 6 days (i’ve been doing maintenance on my computer for the past week so i didn’t actually work on the project at all), i figured out i was setting the modulate to zero in the _ready()
function…
yes i am going to cry, but i am nonetheless happy it’s solved now. let this post be a comedic lesson to always read your own code very carefully (plus, why did I even set the modulate to zero there?? I should’ve used RESET, what…?)
Hello, earlier today I’ve tried to replace the entrance/exit animation of the UI of my inventory, expecting it to be pretty simple, but clearly something went seriously wrong because now the inventory refuses to make itself visible (even when visibility is set to true!), no matter what I do.
First, the node structure of the UI in question is as follows:
MenuContainer
|-InventoryPanel (TextureRect)
|-SideMenusContainer (VBoxContainer)
|-BackAudio (AudioStreamPlayer)
MenuContainer is a child of the CanvasLayer
node UIManager
.
Please excuse the naming. InventoryPanel
holds the the items (labels), while SideMenusContainer
holds things like item information and player information.
Previously, there was an AnimationPlayer
node in there, but I have deleted it in my attempt to solve the problem.
Second, the problematic script is attached the MenuContainer
, and the problematic function looks like this:
func change_selection_mode(selection_mode : SelectionMode):
match selection_mode:
SelectionMode.ITEM_LIST_FOCUSED:
color_rect.set_visible(true)
self.set_visible(true)
$InventoryPanel.set_focus(true)
$SideMenusContainer/ItemInfoPanel.set_focus(false)
SelectionMode.ITEM_OPTIONS_FOCUSED:
$SideMenusContainer/ItemInfoPanel.set_focus(true)
$InventoryPanel.set_focus(false, false) #do not reset the selected index.
SelectionMode.UI_DISABLED:
$SideMenusContainer/ItemInfoPanel.set_focus(false)
$InventoryPanel.set_focus(false)
self.set_visible(false)
color_rect.set_visible(false)
current_selection_mode = selection_mode
The two self.set_visible()
calls were previously
if current_selection_mode == SelectionMode.UI_DISABLED:
#make sure the animation doesn't play again
#in case the inventory is opened while it is opened.
$AnimationPlayer.play("fade")
and
if current_selection_mode != SelectionMode.UI_DISABLED:
#make sure the animation doesn't play again
#in case the inventory is disabled while it is disabled
$AnimationPlayer.play_backwards("fade")
I am confident that the set_focus()
calls are not the culprit, because they have remained unchanged since before, and they also do not affect visibility of the affected nodes.
In trying to wire up the animation, I also changed the type of MenuContainer
from HBoxContainer
to Control
, but I have changed it back to HBoxContainer
and it still doesn’t work.
The animation I was going to use was named "slide"
and would have involved InventoryPanel
and SideMenusContainer
sliding out of the screen and back. Which was why I changed MenuContainer
to Control
, to gain control over their position. Again, I have reverted those changes.
slide
did not change any values other than their position. fade
did not change any values other than their modulate.
WHAT I’VE TRIED:
I have looked in the remote hierarchy while the game is running, and I found that all the above nodes were open and visible. Moreover, I’m pretty sure their positions were in the expected places (not out of bounds), and their modulate alphas were fully opaque.
I removed the AnimationPlayer
, as I have mentioned, and replaced the calls with a simple set_visible
, though that didn’t work.
I’ve looked and I don’t believe there to be discrepancies in the node structure between the UI_Manager
scene and all the scenes that have it instantiated.
I checked with Github version control, and the only scripts that were changed were either irrelevant, or the script I showed you above.
Tomorrow (I’m writing this right before I have to go offline), I will compare the project with an earlier backup. In the meantime, please share your ideas with me!
I hope I’ve given enough information. Any help would be greatly appreciated!