TestGameObject.cs

  1. using UnityEngine;
  2. using System.Collections;
  3. using LuaInterface;
  4. public class TestGameObject: MonoBehaviour
  5. {
  6. private string script =
  7. @"
  8. local Color = UnityEngine.Color
  9. local GameObject = UnityEngine.GameObject
  10. local ParticleSystem = UnityEngine.ParticleSystem
  11. function OnComplete()
  12. print('OnComplete CallBack')
  13. end
  14. local go = GameObject('go', typeof(UnityEngine.Camera))
  15. go:AddComponent(typeof(ParticleSystem))
  16. local node = go.transform
  17. node.position = Vector3.one
  18. print('gameObject is: '..tostring(go))
  19. --go.transform:DOPath({Vector3.zero, Vector3.one * 10}, 1, DG.Tweening.PathType.Linear, DG.Tweening.PathMode.Full3D, 10, nil)
  20. --go.transform:DORotate(Vector3(0,0,360), 2, DG.Tweening.RotateMode.FastBeyond360):OnComplete(OnComplete)
  21. GameObject.Destroy(go, 2)
  22. print('delay destroy gameobject is: '..go.name)
  23. ";
  24. LuaState lua = null;
  25. void Start()
  26. {
  27. lua = new LuaState();
  28. lua.LogGC = true;
  29. lua.Start();
  30. LuaBinder.Bind(lua);
  31. lua.DoString(script, "TestGameObject.cs");
  32. }
  33. void Update()
  34. {
  35. lua.CheckTop();
  36. lua.Collect();
  37. }
  38. void OnApplicationQuit()
  39. {
  40. lua.Dispose();
  41. lua = null;
  42. }
  43. }

?