Lua.cs 765 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2012-2016 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. using System;
  6. namespace Crown
  7. {
  8. /// <summary>
  9. /// Functions to encode C# types to Lua.
  10. /// </summary>
  11. public static class Lua
  12. {
  13. public static string FromBool(bool b)
  14. {
  15. return b == true ? "true" : "false";
  16. }
  17. public static string FromVector2(Vector2 v)
  18. {
  19. return string.Format("Vector2({0}, {1})", v.x, v.y);
  20. }
  21. public static string FromVector3(Vector3 v)
  22. {
  23. return string.Format("Vector3({0}, {1}, {2})", v.x, v.y, v.z);
  24. }
  25. public static string FromQuaternion(Quaternion q)
  26. {
  27. return string.Format("Quaternion.from_elements({0}, {1}, {2}, {3})", q.x, q.y, q.z, q.w);
  28. }
  29. }
  30. }