using UnityEngine.UI; using UnityEngine; public class NativeUpdateUI : MonoBehaviour { Text _message; Slider _slider; // Start is called before the first frame update public void Awake() { _message = transform.Find("BG/Message").GetComponent(); _slider = transform.Find("BG/Slider").GetComponent(); } // 每次显示都执行, 可定义参数 public void Show(params object[] _params) { //base.Show(_params); if (_params == null) return; if (_params.Length == 2) { SetProValue((float)_params[0]); SetMessage((string)_params[1]); } else if (_params.Length == 1) { SetMessage((string)_params[0]); } } /// /// 范围 0-1 /// /// private void SetProValue(float pValue) { _slider.value = pValue; } private void SetMessage(string pValue) { _message.text = pValue; } public void RefreshPregress(string message, float v) { _message.text = message; _slider.value = v; } }