API for managing URP asset parameters, including hacking of parameters that are forbidden to change.
Problem
Unity closed access to change important parameters such as shadows casting, shadow resolution, lighting modes, etc.
If you want to give the user the ability to customize the resolution of shadows, then the suggestion from unit sounds like this: "create multiple assets and rearrange them"
If you follow this way, you will have to create hundreds of pipeline assets to give users the ability to customize the graphics settings.
At the moment the Unity dev team does not disclose the reasons why they closed the ability to change many important parameters.
Solution
Create a wrapper to bypass the restrictions to modify private parameters.
URP | LINK |
---|---|
11.0.0 | ⬇️ |
10.3.1, 10.3.2 | ⬇️ |
- Add wrapper to your project (installation)
- Include wrapper library in code (how)
- Change any parameters of the URP Asset in one line. In the bag 👏
The package is available on the openupm registry. It's recommended to install it via openupm-cli.
openupm add com.inc8877.graphicsconfigurator
Open Packages/manifest.json
with your favorite text editor. Add the following line to the dependencies block.
{
"dependencies": {
"com.inc8877.graphicsconfigurator": "https://github.com/inc8877/GraphicsConfigurator.git",
}
}
Add .dll
to your project, you can find it in every release. You can find a suitable version here
First, plugin necessary libraries
using GraphicsConfigurator.API.URP;
using UnityEngine.Rendering.Universal;
using ShadowResolution = UnityEngine.Rendering.Universal.ShadowResolution;
To change the active URP Asset, you need to do the following:
// ...
// code somewhere
Configuring.CurrentURPA.OpaqueDownsampling(Downsampling._4xBox);
Configuring.CurrentURPA.AntiAliasing(MsaaQuality._4x);
Configuring.CurrentURPA.MainLightMode(LightRenderingMode.PerPixel);
Configuring.CurrentURPA.MainLightShadowsCasting(true);
Configuring.CurrentURPA.MainLightShadowResolution(ShadowResolution._1024);
// ...
If you want to work with a specific URP Asset, do it like this:
private URPAssetConfiguring URPA = new URPAssetConfiguring(target);
// ...
// code somewhere
URPA.MainLightShadowsCasting(true);
URPA.Cascade3Split(new Vector2(0.1f, 0.3f));
// ...
CPU | GPU | OS | Graphics API | Backend | .Net |
---|---|---|---|---|---|
SD 855 | Adreno 640 | Android 10.3.8 | Vulkan | IL2CPP | 4.x |
SD 845 | Adreno 630 | Android 10.3.7 | Vulkan | IL2CPP | 4.x |
i7 6700HQ | AMD Randeon Pro 450 | macOS 11.2.1 | Metal | IL2CPP | 4.x |
- When there is a change in the additional light rendering mode with the display of the target asset in the inspector, then the mode changes briefly, after which it has the parameters that were set before the change was attempted. This happens only in editor mode, it is not observed in assemblies. If, in editor mode, you try to change the rendering mode of the additional light and do not display the target asset in the inspector, then everything is successful. Presumably the problem lies in the way the asset editor works.