Search Unity

How to access ScriptableRendererData from script?

Discussion in 'Universal Render Pipeline' started by FranFndz, Nov 26, 2020.

  1. FranFndz

    FranFndz

    Joined:
    Sep 20, 2018
    Posts:
    178
    Hi there,

    Im trying to get reference to the ScriptableRendererData with no luck...

    I have tried from the UniversalCameraRenderData component, GraphicSetting.renderdata, reflection (it does work but feels wrong).

    Any ideas or reflection is the only solution? Please :(

    From the camera get the render,

    Screen Shot 2020-11-26 at 20.48.05.png

    From the render get the default

    Screen Shot 2020-11-26 at 20.48.55.png

    finally, change those value by code;
    Screen Shot 2020-11-26 at 20.50.14.png
     

    Attached Files:

  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,264
    Reflection is the only way to go, sadly. Since the list of renderers and their render features are either private or internal. Why? Your guess is as good as mine.
     
  3. FranFndz

    FranFndz

    Joined:
    Sep 20, 2018
    Posts:
    178
    Finally is working... with a lot of reflection and specific unity version.
    URP still expiremental so many diferent version of unity / many codes missing added.

    Pretty sure my company wont like this and move back to unity 2018 lol

    Add, remove Feafures by script and change ForwardData settings.

    FPSCounterURP.gif
     
  4. weiping-toh

    weiping-toh

    Joined:
    Sep 8, 2015
    Posts:
    192
    The included ForwardRenderer is kind of restrictive to stop users from shooting themselves in the foot.
    You are probably better off with using it as a Template for your own implementation of ScriptableRenderer and ScriptableRenderData that you can access via your own scripting methodology(DI and such).
    I also made implemented my own ScriptableRenderers for my project because of the need for flexibility to include and exclude RenderPasses during runtime that is controlled via scripts.
     
    Yashiz likes this.
  5. FranFndz

    FranFndz

    Joined:
    Sep 20, 2018
    Posts:
    178
    i get that, but as we make/proto many games with different renderers pipeline i need to make a tool that work on all settings.
    Before was easy, but now changing unity versions the exposed properties and even inspector menu change a lot. (URP)
     
    weiping-toh likes this.
  6. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    We should be able to expose this. We need to give it a pass to make sure we feel confident with the API, and then it'll need documentation. I've added it to our backlog :) Keep in mind that some settings might not be possible to change at run-time due to affecting which shader variants are included in the build.
     
    FranFndz likes this.
  7. LAS_btalotta

    LAS_btalotta

    Joined:
    May 11, 2023
    Posts:
    1
    is there a unity version that this change has made it into?