Or you could attach it to the scene you'd like to attach it to directly:
Code:
local InventoryScene = SCENE_MANAGER.scenes.inventory
InventoryScene:RegisterCallback("StateChange", function(oldState, newState)
-- states: hiding, showing, shown, hidden
if(newState == "showing") then
-- do something if the inventory is beginning to show
elseif(newState == "hiding") then
-- do something if the inventory is beginning to hide
end
end)
That way it really only triggers when the inventory-scene changes (and not for any other scene)
and you're actually able to begin fading in your window on the exact same moment
it begins to fadein the inventory (or after it is done -> shown, hidden).
/zgoo SCENE_MANAGER.scenes
for a list of all scenes