XLua继续学习 2.0
1,、自定义加载器
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 using XLua; 5 6 public class CreateLoader : MonoBehaviour 7 { 8 // Start is called before the first frame update 9 void Start() 10 { 11 LuaEnv env = new LuaEnv(); 12 13 env.AddLoader(MyLoader); 14 15 env.DoString("require 'helloworld'"); 16 17 env.Dispose(); 18 } 19 20 private byte[] MyLoader(ref string filePath) 21 { 22 print(filePath); 23 string s = "print(123)"; 24 return System.Text.Encoding.UTF8.GetBytes(s); 25 } 26 }
2、若在调用是,中文出现乱码的情况,处理方式如下图 将编码改成UTF-8即可

浙公网安备 33010602011771号