using UnityEngine; using UnityEngine.Rendering; namespace Artngame.SKYMASTER { [ExecuteInEditMode] public class CopyShadowMapSM : MonoBehaviour { private CommandBuffer cb; private void OnEnable() { Light component = GetComponent(); if ((bool)component) { cb = new CommandBuffer(); cb.name = "CopyShadowMap"; cb.SetGlobalTexture("_DirectionalShadowMask", new RenderTargetIdentifier(BuiltinRenderTextureType.CurrentActive)); component.AddCommandBuffer(LightEvent.AfterScreenspaceMask, cb); } } private void OnDisable() { Light component = GetComponent(); if ((bool)component) { component.RemoveCommandBuffer(LightEvent.AfterScreenspaceMask, cb); } } } }