Seaside Studios
HomeOverviewFAQsContactReview
Sprite Shader
Sprite Shader
  • What is All In 1 Sprite Shader
  • Overview
  • First Steps (Must Read)
  • Render Pipeline And Post Processing Setup
  • Asset Component Features
  • Right Click Create Material
  • Asset Window
  • Textures Setup
  • Custom Sort Axis
  • Saving Prefabs
  • Sprite Atlases
  • How to animate effects
  • Scripting
  • How to Enable/Disable Effects at Runtime
  • Random Seed
  • Scaled Time
  • UI Masking
  • 2D Renderer URP Lights
  • 3D Lights
  • Unified Outline
  • Render Material To Image
  • Compatibility with other assets
  • Effects and Properties Breakdown
  • Considerations
  • Running out of Shader Keywords
  • FAQ (Frequently Asked Questions)
Powered by GitBook
On this page

How to animate effects

PreviousSprite AtlasesNextScripting

Last updated 6 months ago

The custom material inspector properties can be animated through the Animation window as any other Unity component.

If you don’t know how this is done you can follow this video:

Please keep in mind that UI material properties can’t be animated using the Animator, the reason being that Unity won’t allow you to animate shared material properties. Unity UI Images materials are always shared, which means that all Images use the exact same material instance of a particular Image and therefore if a property is changed for one Image material all the other Images that share material will change too. Since Unity won’t allow this behavior it doesn’t support using the Animator in UI Material properties. And unfortunately I can’t do anything about it.

I recommend using an amazing free asset in the store called DoTween to animate the UI material properties through code or if you prefer you can use the function calls described in the following section.

Alternatively you can also use this free asset called (Animate UI Materials):

void Awake()
{
        Image uiImage = GetComponent<Image>();
        uiImage.material = new Material(uiImage.material);
}

Also consider that since UI material instances are shared you may want to create a copy of each material through script on an Awake method:

https://assetstore.unity.com/packages/2d/gui/animate-ui-materials-253197