Unity3DUnity技术分享

超简单Unity UGUI血条设置

2017-09-22  本文已影响310人  superowner
timg.jpg bb.PNG

原创by superowner

测试代码:

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

public class Test_01 : MonoBehaviour {

    public UnityEngine.UI.Slider Slider;
    public RectTransform Rect;



    // Use this for initialization
    void Start () {
        Slider.onValueChanged.AddListener(Listener);

    }

    void Listener(float value)
    {
        Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, value*100);
    }
    

}

上一篇下一篇

猜你喜欢

热点阅读