TestLuaTableConf.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using LuaInterface;
  5. //此类为测试用例类,正式发布不会执行
  6. public class TestLuaTableConf : SingletonMono<TestLuaTableConf>
  7. {
  8. public bool noDo = true;
  9. public void ParseLuaTableConf(LuaTable luaTable_)
  10. {
  11. LuaTable luaTable = luaTable_;
  12. LuaTable lt = (LuaTable)luaTable["Actor"];
  13. LuaTable lt1 = (LuaTable)luaTable["Building"];
  14. //第一种方式的解析
  15. for (int i = 1; i <= lt.Length; ++i)
  16. {
  17. LuaTable ltt = (LuaTable)lt[i];
  18. //string str1 = ltt["id"].ToString();
  19. //string str2 = ltt["pos"].ToString();
  20. //string str3 = ltt["dir"].ToString();
  21. //Vector3 vec1 = RYZUtil.ConverVector3Float(str2);
  22. //Vector3 vec2 = RYZUtil.ConverVector3Int(str3);
  23. //DebugHelper.Log(vec1);
  24. //DebugHelper.Log(vec2);
  25. }
  26. //第二种方式的解析
  27. for (int i = 1; i <= lt1.Length; ++i)
  28. {
  29. LuaTable ltt = (LuaTable)lt1[i];
  30. for (int j = 1; j <= ltt.Length; ++j)
  31. {
  32. //string str = ltt[j].ToString();
  33. //DebugHelper.Log(str);
  34. }
  35. }
  36. //使用另外一种方式获取lua配置文件信息
  37. if (noDo)
  38. {
  39. noDo = false;
  40. Test();
  41. }
  42. }
  43. public void Test()
  44. {
  45. //LuaTable luaTable = LuaUtil.GetLuaTable2Func("TestPreAsset");
  46. //if(luaTable != null)
  47. //{
  48. // ParseLuaTableConf(luaTable);
  49. //}
  50. }
  51. }