Are there plans to add support for box-shadow property in uss? What’s a good way to add a drop shadow to a button using what’s currently available?
It is planned!
Right now, however, your best bet would probably to create a 9-sliced texture and assign it as the background an element that will act as the shadow.
To make slices, you can either use the USS styles (-unity-slice-left
, etc.). Or simply use a sprite with borders (Unity - Manual: 9-slicing Sprites ).
2 Likes
mcoted3d:
It is planned!
Right now, however, your best bet would probably to create a 9-sliced texture and assign it as the background an element that will act as the shadow.
To make slices, you can either use the USS styles (-unity-slice-left
, etc.). Or simply use a sprite with borders (https://docs.unity3d.com/Manual/9SliceSprites.html ).
Thanks for the reply @mcoted3d !
mikejm
December 27, 2021, 12:25am
4
mcoted3d:
It is planned!
Right now, however, your best bet would probably to create a 9-sliced texture and assign it as the background an element that will act as the shadow.
To make slices, you can either use the USS styles (-unity-slice-left
, etc.). Or simply use a sprite with borders (https://docs.unity3d.com/Manual/9SliceSprites.html ).
It’s been a year. I am just switching my project over to the Unity UI Toolkit.
I was using the True Shadow addon:
https://assetstore.unity.com/packages/tools/gui/true-shadow-ui-soft-shadow-and-glow-beta-176322
On my regular UI, but now that I am moving to UI Toolkit it seems I am stuck. Is this something someone could develop a similar third party solution script for or do you have an ETA on completion of your shadow option?
This is honestly quite critical and it’s hard to work without it.
1 Like
tattyd
January 17, 2023, 3:28pm
6
Hello, I refer you all to this Soft Shadow component that I made for UI Toolkit
Hey all,
Like many others, I was in need of a soft shadow for some of my elements in UI Toolkit. I decided this was a good time to learn about OnGenerateVisualContent
Here's my Soft Shadows component:
https://gist.github.com/tattyd/6807d6be9e550a1f24ad17f21d69177e
Usage:
Wrap whatever VisualElement should be shadowed with a component.
Control shadow colour using the USS color style property (shows as 'text color' in the editor). This allows you to do fun mouseover effects, as wel…
2 Likes