using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 图片提示上下浮动
/// </summary>
public class ImgTipsPosCtrl : MonoBehaviour
{
private Transform trans;
/// <summary>
/// 高度
/// </summary>
private float posY = 0;
/// <summary>
/// 上升最高位置
/// </summary>
private float posYMax = 0;
private float posYMin = 0;
private bool isUp;
private void Awake()
{
trans = GetComponent<Transform>();
posY = trans.localPosition.y;
posYMax = posY + 10;
posYMin = posY - 10;
}
void Update()
{
if(isUp)
posY += 1;
else
posY -= 1;
if(posY >= posYMax)
isUp = false;
else if(posY <= posYMin)
isUp = true;
trans.localPosition = new Vector3(trans.localPosition.x, posY, 0);
}
}