| | 1 | | using System.Collections.Generic; |
| | 2 | | using DCL.Controllers; |
| | 3 | | using DCL.ECS7.InternalComponents; |
| | 4 | | using DCL.ECSRuntime; |
| | 5 | | using DCL.Models; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | public class InternalMaterialHandler : IECSComponentHandler<InternalMaterial> |
| | 9 | | { |
| | 10 | | internal IList<Renderer> renderers; |
| | 11 | |
|
| 5 | 12 | | public void OnComponentCreated(IParcelScene scene, IDCLEntity entity) { } |
| | 13 | |
|
| | 14 | | public void OnComponentRemoved(IParcelScene scene, IDCLEntity entity) |
| | 15 | | { |
| 3 | 16 | | if (renderers == null) |
| 0 | 17 | | return; |
| | 18 | |
|
| 16 | 19 | | for (int i = 0; i < renderers.Count; i++) |
| | 20 | | { |
| 5 | 21 | | Renderer r = renderers[i]; |
| 5 | 22 | | if (r is null) |
| | 23 | | continue; |
| 3 | 24 | | r.sharedMaterial = null; |
| | 25 | | } |
| 3 | 26 | | } |
| | 27 | |
|
| | 28 | | public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, InternalMaterial model) |
| | 29 | | { |
| 15 | 30 | | if (model.renderers != null) |
| | 31 | | { |
| 8 | 32 | | renderers = model.renderers; |
| | 33 | | } |
| 15 | 34 | | } |
| | 35 | | } |