public void Update(float newValue) { float percent = Math.Min(newValue / _max, 1); if (_titleObject != null) { switch (_titleType) { case ProgressTitleType.Percent: _titleObject.text = Mathf.RoundToInt(percent * 100) + "%"; break; case ProgressTitleType.ValueAndMax: _titleObject.text = Mathf.RoundToInt(newValue) + "/" + Mathf.RoundToInt(max); break; case ProgressTitleType.Value: _titleObject.text = "" + Mathf.RoundToInt(newValue); break; case ProgressTitleType.Max: _titleObject.text = "" + Mathf.RoundToInt(_max); break; } } float fullWidth = this.width - _barMaxWidthDelta; float fullHeight = this.height - _barMaxHeightDelta; if (!_reverse) { if (_barObjectH != null) { if ((_barObjectH is GImage) && ((GImage)_barObjectH).fillMethod != FillMethod.None) ((GImage)_barObjectH).fillAmount = percent; else if ((_barObjectH is GLoader) && ((GLoader)_barObjectH).fillMethod != FillMethod.None) ((GLoader)_barObjectH).fillAmount = percent; else _barObjectH.width = Mathf.RoundToInt(fullWidth * percent); } if (_barObjectV != null) { if ((_barObjectV is GImage) && ((GImage)_barObjectV).fillMethod != FillMethod.None) ((GImage)_barObjectV).fillAmount = percent; else if ((_barObjectV is GLoader) && ((GLoader)_barObjectV).fillMethod != FillMethod.None) ((GLoader)_barObjectV).fillAmount = percent; else _barObjectV.height = Mathf.RoundToInt(fullHeight * percent); } } else { if (_barObjectH != null) { if ((_barObjectH is GImage) && ((GImage)_barObjectH).fillMethod != FillMethod.None) ((GImage)_barObjectH).fillAmount = 1 - percent; else if ((_barObjectH is GLoader) && ((GLoader)_barObjectH).fillMethod != FillMethod.None) ((GLoader)_barObjectH).fillAmount = 1 - percent; else { _barObjectH.width = Mathf.RoundToInt(fullWidth * percent); _barObjectH.x = _barStartX + (fullWidth - _barObjectH.width); } } if (_barObjectV != null) { if ((_barObjectV is GImage) && ((GImage)_barObjectV).fillMethod != FillMethod.None) ((GImage)_barObjectV).fillAmount = 1 - percent; else if ((_barObjectV is GLoader) && ((GLoader)_barObjectV).fillMethod != FillMethod.None) ((GLoader)_barObjectV).fillAmount = 1 - percent; else { _barObjectV.height = Mathf.RoundToInt(fullHeight * percent); _barObjectV.y = _barStartY + (fullHeight - _barObjectV.height); } } } if (_aniObject != null) _aniObject.frame = Mathf.RoundToInt(percent * 100); this.InvalidateBatchingState(); }
static public int Update(IntPtr l) { try { FairyGUI.GProgressBar self = (FairyGUI.GProgressBar)checkSelf(l); System.Single a1; checkType(l, 2, out a1); self.Update(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }