Unity控制图片填充进度

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class Imagescript : MonoBehaviour {
Image image;
float hp=10;
// Use this for initialization
void Start () {
image = GetComponent ();
}

// 鼠标点击控制填充进度
void Update () {
if (Input.GetMouseButtonDown (0)) {
hp--;
if (hp <0)
hp = 0;
}
image.fillAmount = hp / 10;
}
}

你可能感兴趣的:(Unity)