| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using DCL.Providers; |
| | 3 | | using System; |
| | 4 | | using System.Threading; |
| | 5 | | using System.Threading.Tasks; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | namespace DCL.Skybox |
| | 9 | | { |
| | 10 | | public class SkyboxElements : IDisposable |
| | 11 | | { |
| | 12 | | public SkyboxDomeElements domeElements; |
| | 13 | | public SkyboxSatelliteElements satelliteElements; |
| | 14 | | public SkyboxPlanarElements planarElements; |
| | 15 | | public SkyboxElementsReferences references; |
| | 16 | |
|
| | 17 | | public async UniTask Initialize(IAddressableResourceProvider addresableResolver, MaterialReferenceContainer mate |
| | 18 | | { |
| 0 | 19 | | references = await SkyboxElementsReferences.Create(addresableResolver, ct); |
| | 20 | |
|
| 0 | 21 | | domeElements = new SkyboxDomeElements(references.domeElementsGO, materialReferenceContainer); |
| 0 | 22 | | satelliteElements = new SkyboxSatelliteElements(references.satelliteElementsGO); |
| 0 | 23 | | planarElements = new SkyboxPlanarElements(references.planarElementsGO); |
| 0 | 24 | | } |
| | 25 | |
|
| | 26 | | public void ApplyConfigTo3DElements(SkyboxConfiguration config, float dayTime, float normalizedDayTime, Light di |
| | 27 | | { |
| 0 | 28 | | domeElements.ApplyDomeConfigurations(config, dayTime, normalizedDayTime, directionalLightGO, cycleTime); |
| 0 | 29 | | satelliteElements.ApplySatelliteConfigurations(config, dayTime, normalizedDayTime, directionalLightGO, cycle |
| 0 | 30 | | planarElements.ApplyConfig(config.planarLayers, dayTime, cycleTime, isEditor); |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | internal void AssignCameraInstance(Transform currentTransform) |
| | 34 | | { |
| 0 | 35 | | if (currentTransform == null) |
| 0 | 36 | | return; |
| | 37 | |
|
| 0 | 38 | | domeElements.ResolveCameraDependency(currentTransform); |
| 0 | 39 | | satelliteElements.ResolveCameraDependency(currentTransform); |
| 0 | 40 | | planarElements.ResolveCameraDependency(currentTransform); |
| 0 | 41 | | } |
| | 42 | |
|
| | 43 | | public void Dispose() |
| | 44 | | { |
| | 45 | | #if UNITY_EDITOR |
| 0 | 46 | | UnityEngine.Object.DestroyImmediate(references.gameObject); |
| | 47 | | #else |
| | 48 | | UnityEngine.Object.Destroy(references.gameObject); |
| | 49 | | #endif |
| 0 | 50 | | references = null; |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | |
|
| | 54 | | } |
| | 55 | | } |