Editor: Create LunyScript Assets

Use Case

You need to create a LunyScript subclass with an associated Lua script.

Create Asset Menu

The Create Asset menu has been extended. Under the Scripting category you will find two new options:

  • Empty Lua Script
  • Empty LunyScript (C# + Lua)
Create LunyScript Asset

Choose Empty LunyScript to create a companion pair of C# and Lua script files.

Created Assets

After entering the asset name in Project view, both a C# and a Lua script asset will appear:

Both scripts contain some boilerplate code and comments to get you started.

Usage Example

Add the C# component to a GameObject. The companion Lua script will automatically be assigned:

No need to go looking for the companion Lua script asset. 🫡

If you run this scene, the LunyShellExplosion.lua will execute and log a message:

This is done by the sample Start() function in the Lua script:

function script.Start()
	print("Hello, " .. script.name .. ".lua on " .. tostring(script.gameObject))
end

Happy Scripting! 😄

Leave a Reply

Your email address will not be published. Required fields are marked *