-
Notifications
You must be signed in to change notification settings - Fork 545
LUA en
Initialization
Window -> Lua设置编辑器(Lua Settings Editor) -> Lua项目初始化(Lua project initialization)
Initialization of what to do:
- Create an export list file to declare which classes will be called by Lua and located in Assets / Script / UI / Editor / Lua / LuaExportList.cs
- Create a blank LuaBinder file, the file is automatically generated
- Copy the framework's native Lua library to Resources / LuaLib
- LuaDataHelper
- LuaStatusManager
- LuaUIManager
- LuaUpdater
- LuaEventDispatcher
- LuaJson
- LuaPrintTable
- Lua automatically generated configuration file, which is used to record the Lua file
- Create a Lua startup file, including a Lua main function, which is called at the beginning of the game
- Add the precompiled directive USE_LUA
- Warp initialization
Generate LuaWarp file
Lua设置编辑器 (Lua Settings Editor) -> 重新生成Lua Warp脚本 (Regenerate Lua Warp Script)
Clear LuaWarp file
Lua设置编辑器 (Lua Settings Editor) -> 清除Lua Warp脚本(Clear Lua Warp script)
Rebuild Package Configuration
Lua设置编辑器(Lua Settings Editor) -> 自动生成Lua配置文件(Lua automatically generated configuration file)
LuaManager
static void Init ()
LuaManager initialization (will be automatically called in ApplicatioManager)
static void LoadLua ()
Load Lua file
static void DoLuaFile (string fileName)
Loads the specified Lua file
static void LaunchLua ()
Launches Lua
LuaStatus
LuaFunction GetFunction (string name, bool beLogMiss = true)
Get a Lua function for calling
public class LuaTestStstus: IApplicationStatus
{
public override void OnEnterStatus ()
{
LuaManager.LoadLua ();
LuaManager.LaunchLua ();
}
}
public static void LaunchLua ()
{
//Debug.Log("LaunchLua ");
try
{
s_state.GetFunction ("Main"). Call ();
s_isUpdate = true;
s_updateFunction = s_state.GetFunction ("LuaUpdate");
}
catch (Exception e)
{
Debug.LogError ("Lua Lunch Execption" + e.ToString ());
}
}
- Toggle 使用Lua(use Lua) in the UI设置编辑器(UI Settings Editor)
- Override method in automatically generated Lua file, under Resources / Lua / UI /, format is "Lua" + UIWindowName + ".txt"
- OnInit
- OnOpen
- OnClose
- EnterAnim
- ...
- The USE_LUA macro is not set
- No warp or warp file error
- No Lua configuration files have been regenerated
- The ToLua integration in the framework removes some of the optimizations for Vector3 in ToLua
- Each time you add a Lua file, remember to regenerate the Lua settings file and update the package settings
- Warp error code can be emptied Warp rebuild after modifying the code
- C # and Lua call each other do not directly use the LuaTable class, it is recommended to use Json to pass the message
- All Lua files use .txt for suffixes in the framework