MCPcopy Create free account
hub / github.com/Tencent/xLua / CustomLoader

Class CustomLoader

Assets/XLua/Tutorial/LoadLuaScript/Loader/CustomLoader.cs:15–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace Tutorial
14{
15 public class CustomLoader : MonoBehaviour
16 {
17 LuaEnv luaenv = null;
18 // Use this for initialization
19 void Start()
20 {
21 luaenv = new LuaEnv();
22 luaenv.AddLoader((ref string filename) =>
23 {
24 if (filename == "InMemory")
25 {
26 string script = "return {ccc = 9999}";
27 return System.Text.Encoding.UTF8.GetBytes(script);
28 }
29 return null;
30 });
31 luaenv.DoString("print('InMemory.ccc=', require('InMemory').ccc)");
32 }
33
34 // Update is called once per frame
35 void Update()
36 {
37 if (luaenv != null)
38 {
39 luaenv.Tick();
40 }
41 }
42
43 void OnDestroy()
44 {
45 luaenv.Dispose();
46 }
47 }
48}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected