RawObject

RawObjectTest.cs

  1. using UnityEngine;
  2. using XLua;
  3. namespace XLuaTest
  4. {
  5. public class IntObject : RawObject
  6. {
  7. int mTarget;
  8. public IntObject(int i)
  9. {
  10. mTarget = i;
  11. }
  12. public object Target
  13. {
  14. get
  15. {
  16. return mTarget;
  17. }
  18. }
  19. }
  20. public class RawObjectTest : MonoBehaviour
  21. {
  22. public static void PrintType(object o)
  23. {
  24. Debug.Log("type:" + o.GetType() + ", value:" + o);
  25. }
  26. // Use this for initialization
  27. void Start()
  28. {
  29. LuaEnv luaenv = new LuaEnv();
  30. //直接传1234到一个object参数,xLua将选择能保留最大精度的long来传递
  31. luaenv.DoString("CS.XLuaTest.RawObjectTest.PrintType(1234)");
  32. //通过一个继承RawObject的类,能实现指明以一个int来传递
  33. luaenv.DoString("CS.XLuaTest.RawObjectTest.PrintType(CS.XLuaTest.IntObject(1234))");
  34. luaenv.Dispose();
  35. }
  36. // Update is called once per frame
  37. void Update()
  38. {
  39. }
  40. }
  41. }

?