/// <summary> /// 更改属性值 /// </summary> /// <param name="value"></param> public void SetChangingValue(float value) { if (handleRect == null) { Debug.LogError("未指定当前滚动对象:handleRect属性为Null"); return; } if (minValue == null || maxValue == null) { SetRectData(); } Vector3 position = Vector3.zero; float moveValue = 0; switch (KguiAxis) { case Axis.X: //if (horizontal == Horizontal.RightToLeft) // value = 1 - value; moveValue = minValue.Value + value * sumValue; //在将屏幕坐标转化为世界坐标 Vector3 handleScreenX = MUtility.UIWorldToScreenPoint(handleRect.position); position = MUtility.UIScreenToWorldPoint(new Vector3(moveValue, handleScreenX.y, handleScreenX.z)); position.y = handleRect.position.y; position.z = handleRect.position.z; break; case Axis.Y: //if (vertical == Vertical.TopToBottom) // value = 1 - value; moveValue = maxValue.Value - value * sumValue; Vector3 handleScreenY = MUtility.UIWorldToScreenPoint(handleRect.position); position = MUtility.UIScreenToWorldPoint(new Vector3(handleScreenY.x, moveValue, handleScreenY.z)); position.x = handleRect.position.x; position.z = handleRect.position.z; break; default: break; } handleRect.position = position; }