| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL.Controllers; |
| | 4 | | using DCL.ECS7.UI; |
| | 5 | | using DCL.ECSRuntime; |
| | 6 | | using DCL.Models; |
| | 7 | | using UnityEngine; |
| | 8 | | using UnityEngine.UIElements; |
| | 9 | | using Random = UnityEngine.Random; |
| | 10 | |
|
| | 11 | | namespace DCL.ECSComponents |
| | 12 | | { |
| | 13 | | public class UITransformComponentHandler : IECSComponentHandler<PBUiTransform> |
| | 14 | | { |
| | 15 | | private readonly IUIDataContainer uiDataContainer; |
| | 16 | |
|
| 0 | 17 | | public UITransformComponentHandler(IUIDataContainer dataContainer) |
| | 18 | | { |
| 0 | 19 | | this.uiDataContainer = dataContainer; |
| 0 | 20 | | } |
| | 21 | |
|
| | 22 | | public void OnComponentCreated(IParcelScene scene, IDCLEntity entity) |
| | 23 | | { |
| 17 | 24 | | } |
| | 25 | |
|
| | 26 | | public void OnComponentRemoved(IParcelScene scene, IDCLEntity entity) |
| | 27 | | { |
| | 28 | | // If we remove an UITransform from a entity, it should have the root entity as parent |
| 1 | 29 | | entity.parentId = SpecialEntityId.SCENE_ROOT_ENTITY; |
| 1 | 30 | | uiDataContainer.RemoveUITransform(scene,entity); |
| 1 | 31 | | } |
| | 32 | |
|
| | 33 | | public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, PBUiTransform model) |
| | 34 | | { |
| 18 | 35 | | entity.parentId = model.Parent; |
| | 36 | |
|
| 18 | 37 | | uiDataContainer.AddUIComponent(scene,entity, model); |
| 18 | 38 | | } |
| | 39 | | } |
| | 40 | | } |