Legacy Reference

Loading Canvases in Lua

CryLua is deprecated and will be removed in a future version of Lumberyard.

The Lumberyard UI Editor uses the concept of a UI canvas as an invisible backdrop for user interface elements. You can use the Lua scripting language to load and unload UI canvases in Lumberyard.

To load a canvas in Lua

  1. Create a new, plain text file in your game project directory with a .lua file extension.

  2. Type or paste the following sample script into your new Lua file:


    The following script uses a Lua file named loadcanvas.lua and loads a canvas file named menu.uicanvas saved at the root of the game project directory. Substitute the appropriate file names for your script.

    loadcanvas = { Properties = { }, } function loadcanvas:OnActivate() self.uiCanvasLuaProxy = UiCanvasLuaProxy() self.uiCanvasLuaProxy:LoadCanvas("menu.uicanvas") end
  3. In Lumberyard Editor, right-click in the Viewport and click Create Component Entity.

  4. If the Entity Inspector does not open automatically, click Tools, Entity Inspector.

  5. Click Add Component.

  6. Select Scripting, Lua Script.

  7. Under Lua Script, click ... and open the Lua script file that you created.

  8. In Lumberyard Editor, click Game, Switch to Game to enter game mode. Verify that your canvas file loads.

See Also

For more information, consult the following resources.