Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

URP Light2D freeform shape editing at runtime.

Discussion in 'Graphics Experimental Previews' started by dlich, Jun 22, 2020.

  1. dlich

    dlich

    Joined:
    Apr 21, 2019
    Posts:
    11
    It would be nice if we could modify the Light2D freeform shape(Light2D.shapePath) at runtime from script. At the moment the property only has a getter and even if you modify the existing points, an OutOfRange exception is being thrown by the LightUtility. Am I missing something or is there really no way to achieve that at the moment?

    Here's the full stack trace:
    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <437ba245d8404784b9fbab9b439ac908>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <437ba245d8404784b9fbab9b439ac908>:0)
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <437ba245d8404784b9fbab9b439ac908>:0)
    UnityEngine.Experimental.Rendering.Universal.LightUtility.GenerateShapeMesh (UnityEngine.Mesh& mesh, UnityEngine.Vector3[] shapePath, System.Single falloffDistance) (at Library/PackageCache/com.unity.render-pipelines.universal@7.3.1/Runtime/2D/LightUtility.cs:290)
    UnityEngine.Experimental.Rendering.Universal.Light2D.GetMesh (System.Boolean forceUpdate) (at Library/PackageCache/com.unity.render-pipelines.universal@7.3.1/Runtime/2D/Light2D.cs:393)
    UnityEngine.Experimental.Rendering.Universal.Light2D.UpdateMesh () (at Library/PackageCache/com.unity.render-pipelines.universal@7.3.1/Runtime/2D/Light2D.cs:344)
    UnityEngine.Experimental.Rendering.Universal.Light2D.LateUpdate () (at Library/PackageCache/com.unity.render-pipelines.universal@7.3.1/Runtime/2D/Light2D.cs:555)