26 lines
604 B
C#
26 lines
604 B
C#
using UnityEngine;
|
|
|
|
public class MaskableProgressBar : MonoBehaviour
|
|
{
|
|
[SerializeField] private RectTransform MaskRectTransform;
|
|
|
|
private float MaxWidth;
|
|
private float LeftNRightPadding = 10;
|
|
public float FillAmount
|
|
{
|
|
get
|
|
{
|
|
return MaskRectTransform.rect.width / MaxWidth;
|
|
}
|
|
set
|
|
{
|
|
MaskRectTransform.sizeDelta = new Vector2(MaxWidth * value, MaskRectTransform.sizeDelta.y);
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
MaxWidth = this.GetComponent<RectTransform>().rect.width - (LeftNRightPadding * 2);
|
|
}
|
|
}
|