20 lines
506 B
C#
20 lines
506 B
C#
using UnityEngine;
|
|
|
|
public class SizeProgressBar : MonoBehaviour, IProgressBar{
|
|
public float Progress { get{return progress;}}
|
|
private float progress =0;
|
|
|
|
public RectTransform target;
|
|
|
|
public Vector3 start,end;
|
|
|
|
|
|
void OnValidate(){
|
|
if(target==null){target=GetComponent<RectTransform>();}
|
|
if(start==end){start = end = target.sizeDelta;}
|
|
}
|
|
public void SetProgress(float val){
|
|
progress = val;
|
|
target.sizeDelta = Vector3.Lerp(start,end, val);
|
|
}
|
|
} |