| | 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 | |
|
| 455 | 16 | | public VisibleFlags visibleFlags = VisibleFlags.VISIBLE_WITH_TRANSITION; |
| 455 | 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 | | public bool forceGPUOnlyMesh = false; |
| | 28 | |
|
| | 29 | | public void ApplyBeforeLoad(Transform t) |
| | 30 | | { |
| 380 | 31 | | if (parent != null) |
| | 32 | | { |
| 250 | 33 | | t.SetParent(parent, false); |
| 250 | 34 | | t.ResetLocalTRS(); |
| | 35 | | } |
| | 36 | |
|
| 380 | 37 | | if (initialLocalPosition.HasValue) |
| | 38 | | { |
| 95 | 39 | | t.localPosition = initialLocalPosition.Value; |
| | 40 | | } |
| | 41 | |
|
| 380 | 42 | | if (initialLocalRotation.HasValue) |
| | 43 | | { |
| 4 | 44 | | t.localRotation = initialLocalRotation.Value; |
| | 45 | | } |
| | 46 | |
|
| 380 | 47 | | if (initialLocalScale.HasValue) |
| | 48 | | { |
| 4 | 49 | | t.localScale = initialLocalScale.Value; |
| | 50 | | } |
| | 51 | |
|
| 380 | 52 | | if (layer.HasValue) |
| 91 | 53 | | Utils.SetLayerRecursively(t, layer.Value); |
| 380 | 54 | | } |
| | 55 | |
|
| 72 | 56 | | public void ApplyAfterLoad(Transform transform) { ApplyAfterLoad(new List<Renderer>(transform.GetComponentsInChi |
| | 57 | |
|
| | 58 | | public void ApplyAfterLoad(List<Renderer> renderers = null) |
| | 59 | | { |
| 164 | 60 | | int renderersCount = renderers.Count; |
| | 61 | |
|
| 1108 | 62 | | for (int i = 0; i < renderersCount; i++) |
| | 63 | | { |
| 390 | 64 | | Renderer renderer = renderers[i]; |
| 390 | 65 | | renderer.enabled = visibleFlags != VisibleFlags.INVISIBLE; |
| | 66 | | } |
| 164 | 67 | | } |
| | 68 | | } |
| | 69 | | } |