//All applicator stuff happens in LateUpdate, after things are done moving void LateUpdate() { if (TargetSky.Dirty) { foreach (Renderer rend in AffectedRenderers) { if (rend == null) { continue; } //This should never be missing //if(rend.GetComponent<SkyAnchor>() == null) TargetSky.Apply(rend); //else //rend.GetComponent<SkyAnchor>().BlendToSky(TargetSky); //BlendToSky does not work here right now, it currently ignores the TargetSky == currSky case TargetSky.Apply(rend, 0); } TargetSky.Dirty = false; } if (transform.position != LastPosition) { HasChanged = true; } }
//delayed setup for blending between global skies private void HandleGlobalSkyChange() { //Switch skies if (nextSky != null) { ResetLightBlend(); if (BlendingSupport && nextBlendTime > 0f) { //BLEND mset.Sky currSky = GlobalBlender.CurrentSky; GlobalBlender.BlendTime = nextBlendTime; GlobalBlender.BlendToSky(nextSky); mset.Sky[] allSkies = GameObject.FindObjectsOfType <mset.Sky>(); foreach (mset.Sky sky in allSkies) { sky.ToggleChildLights(false); } GlobalBlender.SkipTime(nextSkipTime); StartLightBlend(currSky, nextSky); } else { //SNAP GlobalBlender.SnapToSky(nextSky); nextSky.Apply(0); nextSky.Apply(1); mset.Sky[] allSkies = GameObject.FindObjectsOfType <mset.Sky>(); foreach (mset.Sky sky in allSkies) { sky.ToggleChildLights(false); } nextSky.ToggleChildLights(true); } _GlobalSky = nextSky; nextSky = null; if (!Application.isPlaying) { this.EditorApplySkies(true); } } //Update UpdateLightBlend(); }
//global apply public void Apply() { if (IsBlending) { mset.Sky.EnableGlobalProjection(CurrentSky.HasDimensions || PreviousSky.HasDimensions); mset.Sky.EnableGlobalBlending(true); CurrentSky.Apply(0); PreviousSky.Apply(1); mset.Sky.SetBlendWeight(BlendWeight); } else { mset.Sky.EnableGlobalProjection(CurrentSky.HasDimensions); mset.Sky.EnableGlobalBlending(false); CurrentSky.Apply(0); } }
public void UnregisterApplicator(mset.SkyApplicator app, HashSet <Renderer> renderersToClear) { skyApplicators.Remove(app); foreach (Renderer rend in renderersToClear) { if (_GlobalSky != null) { _GlobalSky.Apply(rend, 0); } } }