Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.0KB

  1. #if UNITY_5 || UNITY_5_3_OR_NEWER
  2. using Svelto.DataStructures;
  3. using UnityEngine;
  4. namespace Svelto.ECS.Extensions.Unity
  5. {
  6. ///The class that wrap the OOP library must be known by the package only as much as possible.
  7. ///what cannot be use through the package, is exposed through a public interface. Note though that this may
  8. ///be considered a work around to better design. In this case, no methods are exposed.
  9. public class GOManager
  10. {
  11. public uint RegisterEntity(PrimitiveType type)
  12. {
  13. var cubeObject = GameObject.CreatePrimitive(type);
  14. objects.Add(cubeObject.transform);
  15. return (uint) (objects.count - 1);
  16. }
  17. public void SetParent(uint index, in uint parent)
  18. {
  19. objects[index].SetParent(objects[parent], false);
  20. }
  21. public void SetPosition(uint index, in Vector3 position) { objects[index].localPosition = position; }
  22. readonly FasterList<Transform> objects = new FasterList<Transform>();
  23. }
  24. }
  25. #endif