mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
Update UIExtension.cs
This commit is contained in:
@@ -7,6 +7,7 @@ using TEngine;
|
|||||||
public static class UIExtension
|
public static class UIExtension
|
||||||
{
|
{
|
||||||
#region SetActive
|
#region SetActive
|
||||||
|
|
||||||
public static void SetActive(this GameObject go, bool value, ref bool cacheValue)
|
public static void SetActive(this GameObject go, bool value, ref bool cacheValue)
|
||||||
{
|
{
|
||||||
if (go != null && value != cacheValue)
|
if (go != null && value != cacheValue)
|
||||||
@@ -15,6 +16,7 @@ public static class UIExtension
|
|||||||
go.SetActive(value);
|
go.SetActive(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static IEnumerator FadeToAlpha(this CanvasGroup canvasGroup, float alpha, float duration,
|
public static IEnumerator FadeToAlpha(this CanvasGroup canvasGroup, float alpha, float duration,
|
||||||
@@ -110,4 +112,46 @@ public static class UIExtension
|
|||||||
|
|
||||||
return hadMouseDown;
|
return hadMouseDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetSprite(this Image image, string spriteName, UIBase uiBase, bool isSetNativeSize = false)
|
||||||
|
{
|
||||||
|
if (image == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(spriteName))
|
||||||
|
{
|
||||||
|
image.sprite = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image.sprite = uiBase.LoadAsset<Sprite>(spriteName);
|
||||||
|
if (isSetNativeSize)
|
||||||
|
{
|
||||||
|
image.SetNativeSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetSprite(this UIBase uiBase, string spriteName, Image image, bool isSetNativeSize = false)
|
||||||
|
{
|
||||||
|
if (image == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(spriteName))
|
||||||
|
{
|
||||||
|
image.sprite = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image.sprite = uiBase.LoadAsset<Sprite>(spriteName);
|
||||||
|
if (isSetNativeSize)
|
||||||
|
{
|
||||||
|
image.SetNativeSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user