• RuntimesUnity
  • How can I access the URP Sprite Shader Code Variable

I'm using the URP Spine Shader in ( Universal Render Pipeline/2D/Spine/Sprite ) path.
I wanna access the value 'Lighting Mode' in runtime and change the value.
How can I access to this variable in my script?

Related Discussions
...

@swnyy The Lighting Mode property is just an Editor GUI parameter which switches between shaders. You can check out the code in SpineSpriteShaderGUI.cs, line 368.

Why would want to change Lighting Mode at runtime when using URP? When using URP with a 2D Renderer, the only valid Sprite shader is "Universal Render Pipeline/2D/Spine/Sprite" and when using URP with a normal (non-2D) Renderer, "Universal Render Pipeline/Spine/Sprite" is the only valid one.

    Harald

    Cause I'm using a different Renderer for each scene. The A scene uses the Normal Renderer, and the B scene uses the 2D Renderer. Is there a way to change this in the script in runtime?
    Is just changing the shader the only way?

      Thanks for the clarification.

      swnyy Is there a way to change this in the script in runtime?
      Is just changing the shader the only way?

      Changing the shader is the only way to change the shader, yes 🙂.
      https://docs.unity3d.com/ScriptReference/Material-shader.html
      Why do you want to avoid changing the shader?

      Of course you could also prepare a second Material with the second shader and then switch Materials.