feat: add assets access to gui elements

This commit is contained in:
Kazhnuz 2021-08-30 14:10:26 +02:00
parent 6f6b4e6d74
commit d972fccb13

View file

@ -13,6 +13,7 @@ function GuiElement:new(name, x, y, w, h)
self.depth = 0 self.depth = 0
self.tweens = TweenManager(self) self.tweens = TweenManager(self)
self.assets = self:getAssets()
self:register() self:register()
end end
@ -22,6 +23,11 @@ function GuiElement:getGui()
return scene.gui return scene.gui
end end
function GuiElement:getAssets()
local scene = core.scenemanager.nextScene or core.scenemanager.currentScene
return scene.assets
end
function GuiElement:register() function GuiElement:register()
local gui = self:getGui() local gui = self:getGui()
self.creationId = gui:addElement(self.name, self) self.creationId = gui:addElement(self.name, self)