2022-02-18 02:48:23 +08:00
|
|
|
|
using UnityEngine;
|
2020-10-07 08:20:52 +08:00
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Coffee.UIExtensions.Demos
|
|
|
|
|
|
{
|
2022-02-18 02:48:23 +08:00
|
|
|
|
public class Unmask_Demo : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
[SerializeField] Unmask unmask = null;
|
2022-02-18 03:01:19 +08:00
|
|
|
|
[SerializeField] Unmask[] smoothingUnmasks = new Unmask[0];
|
2022-02-18 02:48:23 +08:00
|
|
|
|
[SerializeField] Graphic transition = null;
|
|
|
|
|
|
[SerializeField] Image transitionImage = null;
|
|
|
|
|
|
[SerializeField] Sprite unity_chan = null;
|
|
|
|
|
|
[SerializeField] Sprite unity_frame = null;
|
2020-10-07 08:20:52 +08:00
|
|
|
|
|
2022-02-18 02:48:23 +08:00
|
|
|
|
public void AutoFitToButton(bool flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
unmask.fitOnLateUpdate = flag;
|
|
|
|
|
|
}
|
2020-10-07 08:20:52 +08:00
|
|
|
|
|
2022-02-18 02:48:23 +08:00
|
|
|
|
public void SetTransitionColor(bool flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
transition.color = flag ? Color.white : Color.black;
|
|
|
|
|
|
}
|
2020-10-07 08:20:52 +08:00
|
|
|
|
|
2022-02-18 02:48:23 +08:00
|
|
|
|
public void SetTransitionImage(bool flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
transitionImage.sprite = flag ? unity_chan : unity_frame;
|
|
|
|
|
|
transitionImage.SetNativeSize();
|
|
|
|
|
|
var size = transitionImage.rectTransform.rect.size;
|
|
|
|
|
|
transitionImage.rectTransform.sizeDelta = new Vector2(150, size.y / size.x * 150);
|
|
|
|
|
|
}
|
2022-02-18 03:01:19 +08:00
|
|
|
|
|
|
|
|
|
|
public void EnableSmoothing(bool flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var unmask in smoothingUnmasks)
|
|
|
|
|
|
{
|
|
|
|
|
|
unmask.edgeSmoothing = flag ? 1 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-02-18 02:48:23 +08:00
|
|
|
|
}
|
2020-10-07 08:20:52 +08:00
|
|
|
|
}
|