using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; public class SkySwitch : MonoBehaviour { [System.Serializable] public sealed class SkyTexture { public float multiplier; public float average; public Texture texture; } int currentTexture = 0; public List textures; const string btnLA = "XRI_Left_PrimaryButton"; const string btnLB = "XRI_Left_SecondaryButton"; const string btnRA = "XRI_Right_PrimaryButton"; const string btnRB = "XRI_Right_SecondaryButton"; // Start is called before the first frame update void Start() { HDRISky sky; Adaptation3 adapt; GetEffects(out sky, out adapt); Switch(10, sky, adapt); } void GetEffects(out HDRISky sky, out Adaptation3 adapt) { var pipeline = (HDRenderPipeline)RenderPipelineManager.currentPipeline; var volume = GetComponent(); volume.profile.TryGet(out sky); volume.profile.TryGet(out adapt); //pipeline.RequestSkyEnvironmentUpdate(); } // Update is called once per frame void Update() { int target = currentTexture; if (Input.GetButtonDown(btnLA)) target++; if (Input.GetButtonDown(btnLB)) target += textures.Count - 1; HDRISky sky; Adaptation3 adapt; GetEffects(out sky, out adapt); if (target != currentTexture) Switch(target, sky, adapt); if (Input.GetButtonDown(btnRA)) { int m = (int)adapt.mode.value; m = ++m % 3; adapt.mode.Override((Adaptation3.Adaptation3Mode)m); } if (Input.GetButtonDown(btnRB)) adapt.colour.Override(!adapt.colour.value); } void Switch(int textureId, HDRISky sky, Adaptation3 adapt) { currentTexture = textureId % textures.Count; var tex = textures[currentTexture]; Debug.unityLogger.Log("Sky Texture: " + tex); sky.hdriSky.Override(textures[currentTexture].texture); sky.multiplier.Override(1f); adapt.multiplier.Override(textures[currentTexture].multiplier); adapt.average.Override(textures[currentTexture].average); } }