How to set Cookie offset in URP Unity?

518 Views Asked by At

Here in manual we see described text about cookie offset "You can also animate this property to scroll the cookie" :

enter image description here

Here in Editor i can change the offset in runtime:

enter image description here

But how to do this from script if he tells me this:

'Light' does not contain a definition for 'cookieOffset' and no accessible extension method 'cookieOffset' accepting a first argument of type 'Light' could be found

1

There are 1 best solutions below

0
On

Use URP extantion UniversalAdditionalLightData instead

public class LightCookieDisplacer : MonoBehaviour
{
    private UniversalAdditionalLightData lightExtantion;

    private void Awake()
    {
        lightExtantion = GetComponent<UniversalAdditionalLightData>();
    }

    private void Update()
    {
        lightExtantion.lightCookieOffset += Vector2.one * Time.deltaTime;
    }
}