Shader effect on UI element ?

Hello,

Is there a way to add special FX to UI element ? For animation and more, to make some effect better.

Can I add a script to a UI Element ?

In unity, you can change the material of the UI object. So you are able to change the shader.

And adding scripts (animator, particle systems) to UI objects is completely fine. However, you mustn’t forget that UI elements are actually 2D objects.
Hope I helped.

Thanks for your answer.
When I have a game object in my hierarchy folder, it’s easy to add script or material.

How to do it with the new UI system : UI builder ?

I’m sorry however I’m not familiar with the UI builder. I guess I can come up with something. After you finish editing the UI, does the UI builder builds the UI in the editor or in the runtime? If it builds your UI in the editor you can modify it. However, if it builds the UI in the runtime I think you can copy it and paste it into the editor (I know this would render the UI builder useless). Or you can have a script that will assign a component to the UI element in the runtime.

UI Toolkit doesn’t support custom materials. Few options…

  1. They say they’re planning it, so if you can wait a year or two, that’s probably your best bet
  2. If you want to apply a shader to the whole UI at once, that’s easy enough to do to a render target
  3. If the effect can be done completely on GPU without any source textures… render target
  4. If it’s just a single element that needs a shader, then make that element a render target and incorporate that into your UI. This isn’t very performant/scalable, though (and is a lot of work!)
  5. If the effect can be done with a combination of colors, textures, and geometry, you can manually draw the geometry in a callback. I’m using that technique for this (ignore the jumpy animation; it looks smooth in game i just captured it wrong):

7597483--942565--Animation.png

(as you can see, no anti-aliasing, though)

2 Likes

Ok it’s quite long to wait… So I need to make classic UGui ?

Well we don’t know how long we’ll have to wait; the Unity devs have said they want to add it eventually. But it probably will not be stable when it first releases, so if you have a project that needs it, UGUI is the way to go.

1 Like

Thank you for your infos. Do you have a thread related to > They say they’re planning it < I could follow ?

1 Like

Have there been any updates on this?

2 Likes

Can you share an example, it would be really helpful!