1.gif
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class SliderController : MonoBehaviour
{
public RectTransform image;
private float valuemax = -1200;
private float valuemin = 0;
private Vector2 orgoffMax;
private Vector2 orgoffMin;
// Use this for initialization
void Start()
{
orgoffMax = image.offsetMax;
orgoffMin = image.offsetMin;
ChangeAImage();
}
void ChangeAImage()
{
DOTween.To(() => valuemax, x => valuemax = x, 0, 2); //表示将一个类型的值valuemax 变为 0,所需时间是2秒
Invoke("ChangeOffestMin", 1);
}
void ChangeOffestMin()
{
DOTween.To(() => valuemin, x => valuemin = x, 1200, 1.5f).OnComplete(() =>
{
image.offsetMax = orgoffMax;
image.offsetMin = orgoffMin;
valuemax = -1200;
valuemin = 0;
ChangeAImage();
});
}
// Update is called once per frame
void Update()
{
image.offsetMax = new Vector2(valuemax, -10);
image.offsetMin = new Vector2(valuemin, 10);
}
}
原创性声明:严禁商用
网友评论