Is it possible to change the default UI material to use a different shader? Or is the only way to specify an override material for every Graphic in the scene?
I’d like to experiment with adjusting the UI-Default shader, but I can’t find a way to easily apply the modified version of the shader to all UI elements in the scene.
I was hoping there’d be a “Graphic Settings > Default UI Material” field or script call somewhere. Graphic.defaultGraphicMaterial seemed promising, but it’s read only.
Sorry to resurrect this thread from the dead, but I’m wondering if changing the default ui is possible yet.
Or would I need to change every graphic to set a material?
Also sorry to resurrect this old thread, but this feature could save me a lot of time. We need to use our custom optimized UI shader for ALL graphic elements in all our scenes and prefabs. Something like the “default physic material” in the Physics settings would be absolutely amazing. If there is not already some way to achieve this.
EDIT: Found a solution - Canvas.GetDefaultCanvasMaterial().shader = _defaultGUIShader;
As a setting in the UI of the Editor no. But has Gorren said, you can do Canvas.GetDefaultCanvasMaterial() = myNewMaterial and that will assign it back to the one you set. A simple script that has that line in Start() should work until we find a way to have a preset.
Create a new material and name it “DefaultUIMaterial”. (Optionally create a FastUIMaterial with your other UI shader)
Open Resource Checker
Select all UI elements using Resource Checker. (Click the relevant button to select the relevant gameojbects)
Since it auto selects all elements in the active scene you can change any property. (Thanks to the Multi Edit feature for certain components)
Drag and drop the “DefaultUIMaterial” to all the UIElements you care about. A single change will effect 1000’s of elements on your scene so make sure you check in your code before you make this change.
Done.
If you need certain elements to have a different material just repeat the above steps and use your other material.
Is there still no decent solution for this problem?
This is especially problematic as the current default UI shader does not work correctly with linear color space.
You can replace “UI/Default” in the Graphics Settings’s Always Included Shaders with a custom shader(the name should be “UI/Default”) in your project. It works in 2019.4.29f1, but I’m not sure whether it works in other versions.
Place the shader to the resource folder and name it “UI-Default”. The BuiltIn Material with that name replaces its shader with the previously mentioned one. This works also for other BuiltIn-Materials.
But I found no way to reverse that action without downloading the original shaders to replace again. It is also redundant since the builtInShaders are always in the projects.
How can I reset the shader reference of the builtIn default Material back to the built In shader? I Can’t change it in DebugMode since the variable is private and the inspector doesnt allow it to change. Calling Reset from the context menu does nothing.
Just an FYI, I tried this with 2022.1.16f1 and it didn’t work, until after restarting Unity.
That said, thank you so much. this saved me having to manually apply an override material to every UI element to address URP single pass instanced world space UI issues.
It only work on editor mode, if build to app,it not work,all the ui material ref the default shader from unity build-in,not ref my custom UI.default shader