| | 1 | | using DCL.Models; |
| | 2 | |
|
| | 3 | | public static class ECSTransformParentingSystem |
| | 4 | | { |
| | 5 | | public static void Update() |
| | 6 | | { |
| 4 | 7 | | if (ECSTransformUtils.orphanEntities == null || ECSTransformUtils.orphanEntities.Count == 0) |
| | 8 | | { |
| 0 | 9 | | return; |
| | 10 | | } |
| | 11 | |
|
| 4 | 12 | | int count = ECSTransformUtils.orphanEntities.Count; |
| | 13 | |
|
| 16 | 14 | | for (int i = count - 1; i >= 0; i--) |
| | 15 | | { |
| 4 | 16 | | var data = ECSTransformUtils.orphanEntities.Pairs[i].value; |
| | 17 | |
|
| 4 | 18 | | if (ECSTransformUtils.TrySetParent(data.scene, data.entity, data.parentId, out IDCLEntity parent)) |
| | 19 | | { |
| 3 | 20 | | if (data.entity.parentId != SpecialEntityId.SCENE_ROOT_ENTITY) |
| | 21 | | { |
| 2 | 22 | | parent.childrenId.Add(data.entity.entityId); |
| | 23 | | } |
| 3 | 24 | | ECSTransformUtils.orphanEntities.RemoveAt(i); |
| | 25 | | } |
| | 26 | | } |
| 4 | 27 | | } |
| | 28 | | } |