Search Unity

How to change stencil settings at runtime from script?

Discussion in 'Universal Render Pipeline' started by AytoMaximo, May 16, 2020.

  1. AytoMaximo

    AytoMaximo

    Joined:
    Aug 26, 2015
    Posts:
    76
    Hi!

    I want to change compare function value of stencil in the renderer feature from my script.
    It changes in the editor window, but nothing happens in the scene. However, if I change this variable with the editor's dropdown - everything works fine.

    Is it a bug or feature?

    I'm trying to create an AR portal with stencil buffer in URP and don't know how to control stencil state when user is entering or exiting the portal world.

    Thank you!