daniel
daniel

Reputation: 21

How to change a property of the URP asset via Script in Unity?

I want to change the Render Scale value via code. I don't want to create multiple assets just to change that but if there isn't other way I would also appreciate help on that. There is almost no documentation about this, everything seems outdated.

Thank you.

Upvotes: 1

Views: 7252

Answers (1)

You have to create a new instance of URP to edit its properties :


UniversalRenderPipelineAsset asset = new UniversalRenderPipelineAsset();
asset.renderScale = 0.1f;
GraphicsSettings.renderPipelineAsset = asset;

How to check the script:

You can check the default contents of UniversalRenderPipelineAsset by creating a new URP Pipeline Asset; then in the inspector, click the Gear icon on the top right corner and click "Edit Script". This will really help you.

Edit:

As @derHugo said, you can directly edit its properties using var.

var urpAsset = (UniversalRenderPipelineAsset)GraphicsSettings.renderPipelineAsset;
urpAsset.renderScale = 0.1f;

Upvotes: 1

Related Questions