Skip to content

Commit 16a1cd9

Browse files
committed
Add extension methods for UI graphics
1 parent 61f943c commit 16a1cd9

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

Runtime/Extensions.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using UnityEngine.UI;
2+
3+
namespace Zigurous.UI
4+
{
5+
/// <summary>
6+
/// Extension methods for UI graphics.
7+
/// </summary>
8+
public static class GraphicExtensions
9+
{
10+
/// <summary>
11+
/// Fades the alpha of the graphic to 100% over the given
12+
/// <paramref name="duration"/>.
13+
/// </summary>
14+
/// <param name="graphic">The graphic to fade.</param>
15+
/// <param name="duration">The amount of seconds it takes to fade the graphic.</param>
16+
/// <param name="ignoreTimeScale">Ignores the time scale when fading the graphic.</param>
17+
public static void FadeIn(this Graphic graphic, float duration, bool ignoreTimeScale = false)
18+
{
19+
graphic.CrossFadeAlpha(1.0f, duration, ignoreTimeScale);
20+
}
21+
22+
/// <summary>
23+
/// Fades the alpha of the graphic to 0% over the given
24+
/// <paramref name="duration"/>.
25+
/// </summary>
26+
/// <param name="graphic">The graphic to fade.</param>
27+
/// <param name="duration">The amount of seconds it takes to fade the graphic.</param>
28+
/// <param name="ignoreTimeScale">Ignores the time scale when fading the graphic.</param>
29+
public static void FadeOut(this Graphic graphic, float duration, bool ignoreTimeScale = false)
30+
{
31+
graphic.CrossFadeAlpha(0.0f, duration, ignoreTimeScale);
32+
}
33+
34+
}
35+
36+
}

Runtime/Extensions/GraphicExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)