Fragments in a scene: On fragment state change
From ESOUI Wiki
Careful: SCENE_MANAGER is initialised some time after EVENT_ADDON_LOADED, so you might run into nil exceptions there.
Fragments are attached, reusable parts of a scene.
A bank scene e.g. got multiple fragments which will change if you switch between Deposit (inventory_fragment) and withdraw (bank_fragment).
The game will reuse these fragments e.g. in the player inventory if you press the I key on your keyboard, and if you are at the bank's deposit tab as well.
Fragments can contain/have attached some controls (where the fragment is the parent) which will assure that the controls are shown/hidden as the fragments are shown/hidden.
Fragments have a "StateChange" point where you can register a callback function (just like within a scene) to check if the fragment is shown or hidden:
local function fragmentChange(fragmentName, oldState, newState) if (newState == SCENE_FRAGMENT_SHOWN ) then -- do stuff elseif (newState == SCENE_FRAGMENT_HIDDEN ) then -- do stuff end end local fragment = INVENTORY_FRAGMENT fragment:RegisterCallback("StateChange", fragmentChange)