| | 1 | | using DCL.Helpers; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | public class AssetPromiseSettings_Rendering : IAssetPromiseSettings<Transform> |
| | 8 | | { |
| | 9 | | public enum VisibleFlags |
| | 10 | | { |
| | 11 | | INVISIBLE, |
| | 12 | | VISIBLE_WITHOUT_TRANSITION, |
| | 13 | | VISIBLE_WITH_TRANSITION |
| | 14 | | } |
| | 15 | |
|
| 275 | 16 | | public VisibleFlags visibleFlags = VisibleFlags.VISIBLE_WITH_TRANSITION; |
| 275 | 17 | | public MaterialCachingHelper.Mode cachingFlags = MaterialCachingHelper.Mode.CACHE_EVERYTHING; |
| | 18 | | public Shader shaderOverride; |
| | 19 | |
|
| | 20 | | public Transform parent; |
| | 21 | | public Vector3? initialLocalPosition; |
| | 22 | | public Quaternion? initialLocalRotation; |
| | 23 | | public Vector3? initialLocalScale; |
| | 24 | | public int? layer; |
| | 25 | |
|
| | 26 | | public bool forceNewInstance; |
| | 27 | |
|
| | 28 | | public void ApplyBeforeLoad(Transform t) |
| | 29 | | { |
| 272 | 30 | | if (parent != null) |
| | 31 | | { |
| 154 | 32 | | t.SetParent(parent, false); |
| 154 | 33 | | t.ResetLocalTRS(); |
| | 34 | | } |
| | 35 | |
|
| 272 | 36 | | if (initialLocalPosition.HasValue) |
| | 37 | | { |
| 22 | 38 | | t.localPosition = initialLocalPosition.Value; |
| | 39 | | } |
| | 40 | |
|
| 272 | 41 | | if (initialLocalRotation.HasValue) |
| | 42 | | { |
| 4 | 43 | | t.localRotation = initialLocalRotation.Value; |
| | 44 | | } |
| | 45 | |
|
| 272 | 46 | | if (initialLocalScale.HasValue) |
| | 47 | | { |
| 4 | 48 | | t.localScale = initialLocalScale.Value; |
| | 49 | | } |
| | 50 | |
|
| 272 | 51 | | if (layer.HasValue) |
| 18 | 52 | | Utils.SetLayerRecursively(t, layer.Value); |
| 272 | 53 | | } |
| | 54 | |
|
| 286 | 55 | | public void ApplyAfterLoad(Transform transform) { ApplyAfterLoad(new List<Renderer>(transform.GetComponentsInChi |
| | 56 | |
|
| | 57 | | public void ApplyAfterLoad(List<Renderer> renderers = null) |
| | 58 | | { |
| 143 | 59 | | int renderersCount = renderers.Count; |
| | 60 | |
|
| 966 | 61 | | for (int i = 0; i < renderersCount; i++) |
| | 62 | | { |
| 340 | 63 | | Renderer renderer = renderers[i]; |
| 340 | 64 | | renderer.enabled = visibleFlags != VisibleFlags.INVISIBLE; |
| | 65 | | } |
| 143 | 66 | | } |
| | 67 | | } |
| | 68 | | } |