3
0

UnloadThisCanvasButton.lua 958 B

1234567891011121314151617181920212223242526272829303132
  1. ----------------------------------------------------------------------------------------------------
  2. --
  3. -- Copyright (c) Contributors to the Open 3D Engine Project.
  4. -- For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. --
  6. -- SPDX-License-Identifier: Apache-2.0 OR MIT
  7. --
  8. --
  9. --
  10. ----------------------------------------------------------------------------------------------------
  11. local UnloadThisCanvasButton =
  12. {
  13. }
  14. function UnloadThisCanvasButton:OnActivate()
  15. self.buttonHandler = UiButtonNotificationBus.Connect(self, self.entityId)
  16. end
  17. function UnloadThisCanvasButton:OnDeactivate()
  18. self.buttonHandler:Disconnect()
  19. end
  20. function UnloadThisCanvasButton:OnButtonClick()
  21. -- get canvas name from element
  22. canvasId = UiElementBus.Event.GetCanvas(self.entityId)
  23. if (canvasId:IsValid()) then
  24. UiCanvasManagerBus.Broadcast.UnloadCanvas(canvasId)
  25. end
  26. end
  27. return UnloadThisCanvasButton