Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soft shadow for Unity UI Image

Tags:

unity3d

What is the best approach to implement a soft shadow around the outline of a Unity UI Image? I want to achieve the effect below:

desired-soft-shadow

(Image Source: YouTube video: Soft Shadow UI || Unity 5)

My current approach is to manually add a shadow Image behind the main Image. For example, see below screenshots:

button-with-soft-shadow

scene-heirarchy

shadow-inspector

However, I find this approach tedious and messy from a workflow perspective, because I have to manually add this shadow GameObject to my GameObject hierarchy every time I want to add a soft shadow to a UI Image.

While I think it's possible to improve on this current workflow slightly, is there a better approach?


Note that I also tried Unity's built-in Shadow effect component:

built-in-drop-shadow

This is a drop shadow and not a soft shadow effect I am looking for.

But I think this approach shows an ideal workflow, where it's as simple as adding a shadow component to a GameObject with an Image.

like image 967
sonny Avatar asked Sep 04 '18 19:09

sonny


1 Answers

Procedural UI Image by Josh H on the Unity Asset Store looks promising.

Create an infinite number of basic shapes without a ton of image resources. Control and animate border-width and border-radius. It is perfect for creating flat styled UI. Easy to understand and well-commented code along with a PDF documentation will keep this package extendable.

Main features:

[...]

➤ Fall-off: can be used for soft shadow effect or glow

fall-off-distance-param


Other "procedural UI" packages may also support soft shadows.

There are some new UI assets on the Asset Store that have been released since this question was asked, e.g. True Shadow - UI Soft Shadow and Glow (beta) by Tai's Assets.

like image 159
sonny Avatar answered Sep 20 '22 10:09

sonny