r2mods/ilspy_dump/ror2_csproj/EnableCustomRenderTextureOn...

55 lines
1.1 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using UnityEngine;
[RequireComponent(typeof(Light))]
public class EnableCustomRenderTextureOnLight : MonoBehaviour
{
private Light targetLight;
private bool targetLightHasCustomRenderTexture;
private CustomRenderTexture targetLightCookie;
private void Awake()
{
targetLight = GetComponent<Light>();
InitRenderTexture();
}
private void Start()
{
SetUpdateMode(CustomRenderTextureUpdateMode.Realtime);
}
private void InitRenderTexture()
{
if (!(targetLight == null) && !(targetLight.cookie == null) && targetLight.cookie is CustomRenderTexture)
{
targetLightHasCustomRenderTexture = true;
targetLightCookie = targetLight.cookie as CustomRenderTexture;
}
}
private void SetUpdateMode(CustomRenderTextureUpdateMode mode)
{
if (targetLightHasCustomRenderTexture)
{
targetLightCookie.updateMode = mode;
}
}
private void OnEnable()
{
SetUpdateMode(CustomRenderTextureUpdateMode.Realtime);
}
private void OnDisable()
{
SetUpdateMode(CustomRenderTextureUpdateMode.OnDemand);
}
private void OnDestroy()
{
SetUpdateMode(CustomRenderTextureUpdateMode.OnDemand);
}
}