| | 1 | | using DCL.Models; |
| | 2 | | using UnityEngine; |
| | 3 | | using System.Collections.Generic; |
| | 4 | |
|
| | 5 | | namespace DCL.Controllers |
| | 6 | | { |
| | 7 | | public class SceneBoundsFeedbackStyle_Simple : ISceneBoundsFeedbackStyle |
| | 8 | | { |
| 633 | 9 | | private readonly List<Renderer> disabledRenderers = new List<Renderer>(); |
| | 10 | |
|
| | 11 | | public void ApplyFeedback(MeshesInfo meshesInfo, bool isInsideBoundaries) |
| | 12 | | { |
| 94 | 13 | | if (meshesInfo?.renderers == null || meshesInfo.renderers.Length == 0) |
| 28 | 14 | | return; |
| | 15 | |
|
| 66 | 16 | | if (meshesInfo?.currentShape != null && !meshesInfo.currentShape.IsVisible()) |
| 1 | 17 | | return; |
| | 18 | |
|
| 296 | 19 | | for (int i = 0; i < meshesInfo.renderers.Length; i++) |
| | 20 | | { |
| 83 | 21 | | if (meshesInfo.renderers[i] == null) |
| | 22 | | continue; |
| | 23 | |
|
| 83 | 24 | | if (isInsideBoundaries == meshesInfo.renderers[i].enabled) |
| | 25 | | continue; |
| | 26 | |
|
| 62 | 27 | | meshesInfo.renderers[i].enabled = isInsideBoundaries; |
| | 28 | |
|
| 62 | 29 | | if (isInsideBoundaries && disabledRenderers.Contains(meshesInfo.renderers[i])) |
| 13 | 30 | | disabledRenderers.Remove( meshesInfo.renderers[i]); |
| 49 | 31 | | else if (!isInsideBoundaries && !disabledRenderers.Contains(meshesInfo.renderers[i])) |
| 49 | 32 | | disabledRenderers.Add( meshesInfo.renderers[i]); |
| | 33 | | } |
| 65 | 34 | | } |
| | 35 | |
|
| | 36 | | public void CleanFeedback() |
| | 37 | | { |
| 56 | 38 | | foreach (var renderer in disabledRenderers) |
| | 39 | | { |
| 0 | 40 | | renderer.enabled = true; |
| | 41 | | } |
| | 42 | |
|
| 28 | 43 | | disabledRenderers.Clear(); |
| 28 | 44 | | } |
| | 45 | |
|
| | 46 | | public List<Material> GetOriginalMaterials(MeshesInfo meshesInfo) |
| | 47 | | { |
| 0 | 48 | | List<Material> result = new List<Material>(); |
| | 49 | |
|
| 0 | 50 | | for (int i = 0; i < meshesInfo.renderers.Length; i++) |
| | 51 | | { |
| 0 | 52 | | result.AddRange(meshesInfo.renderers[i].sharedMaterials); |
| | 53 | | } |
| | 54 | |
|
| 0 | 55 | | return result; |
| | 56 | | } |
| | 57 | | } |
| | 58 | | } |