Integration of ToLua with Ellan Jiang's UnityGameFramework
- URL: UnityGameFramework
- Used as a submodule.
- Exclude LuaJit for now.
- Remove the examples.
- Copy Unity 5.x meta files to the right locations.
- Change path constants in CustomSettings.cs and LuaConst.cs. (See comments like
- Add label 'LuaScript' for lua files so that they could be built into assetbundles. (Could be done by the editor script
- Core functionality:
GameFrameworkComponentand provides features of loading and running Lua scripts.
CustomLuaLoaderhacks ToLua's file reading mechanism so that asset bundles built by Game Framework will work.
- Usage example:
- Editor helper scripts:
How to play the example
- Download this repo, initialize the submodule, and open it in Unity (5.3 or newer).
- Create your own AssetBundleBuilder.xml file according to Game Framework examples, especially the output directory for asset bundles.
- When assets are imported and source files are compiled, there will be a
Gamemenu showing in the Unity editor. Select it and click
Build AssetBundlesto build lua scripts into asset bundles.
- Copy all
Packageassetbundles of the platform on which you're going to run the project into
- Run the game in the editor or build and run the game on any platform.
If you tick
Editor resource modeon the
Base Componentof Game Framework,
CustomLuaLoaderreads the Lua files on the disk. Otherwise, the project, when launched, first loads the asset bundles that contain Lua scripts so that
CustomLuaLoadergets the script contents later from the loaded (and hence cached) texts.
.luafiles will be recoginized by Unity as default assets, rather than text assets, so that you cannot load them directly from some asset bundle. So
.bytesextension to the file names before building asset bundles and revert them afterwards.