hey guys
just a little question
I’m making material using shadergraph and I want to attach it on mu UI element. how is it possible?
hey guys
just a little question
I’m making material using shadergraph and I want to attach it on mu UI element. how is it possible?
Hello giosto,
I don’t use shader graph, but in general, there is no a lot of difference between shaders for UI and world objects.
If it’s possible, take a look on built-in UI shaders and compare it with the shader that shader graph gives you.
Simple shaders should work both on UI elements and 3D objects. It it’s not - find differences between your resulting shader and built-in one.
You can download build-in shaders from here: Download Archive
I havent used shadergraph so forgive my ignorance but I believe you can add a material to UI components, for example if you look at Image components you’ll notice an object field named material. You set it there.
UI materials are handled a little differently then normal 3D materials and there are some special considerations.
An example of special considerations is how _MainTex is handled in shaders designed for the Text component, _MainTex is passed a texture by the Text component itself and it is an image of the relevant letter I think.
It will depend on the UI element you are using, sounds like this will be an Image component if it is a health bar.
You can make shaders for the UI, though mine only seem to work in editor and not play mode unless I set the canvas to use screen space-camera, otherwise its just black for me.
FYI if you want to get the colour of the UI element add a vertex colour node.
I’ve used shader graph for UI Image (also works for RawImage) and made a tutorial about it!
hope you will find it useful:
No make a sprite in a paint program shader graph is 3d only. Out of curiosity, why do you want to do this?