@@ -49,6 +49,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
4949 var value = property . vector2IntValue ;
5050 var minValue = ( float ) value . x ;
5151 var maxValue = ( float ) value . y ;
52+ ( minValue , maxValue ) = ClampValues ( minValue , maxValue , minLimit , maxLimit ) ;
5253 DrawSlider ( position , property , minLimit , maxLimit , ref minValue , ref maxValue , BuildIntLabel ) ;
5354 value . x = ( int ) minValue ;
5455 value . y = ( int ) maxValue ;
@@ -59,12 +60,22 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
5960 var value = property . vector2Value ;
6061 var minValue = value . x ;
6162 var maxValue = value . y ;
63+ ( minValue , maxValue ) = ClampValues ( minValue , maxValue , minLimit , maxLimit ) ;
6264 DrawSlider ( position , property , minLimit , maxLimit , ref minValue , ref maxValue , BuildFloatLabel ) ;
6365 value . x = minValue ;
6466 value . y = maxValue ;
6567 property . vector2Value = value ;
6668 }
6769
70+ static ( float , float ) ClampValues ( float minValue , float maxValue , float minLimit , float maxLimit )
71+ {
72+ minValue = Math . Max ( minLimit , minValue ) ;
73+ minValue = Math . Min ( maxLimit , minValue ) ;
74+ maxValue = Math . Min ( maxLimit , maxValue ) ;
75+ maxValue = Math . Max ( maxValue , minValue ) ;
76+ return ( minValue , maxValue ) ;
77+ }
78+
6879 static void DrawSlider ( Rect position , SerializedProperty property , float min , float max , ref float x ,
6980 ref float y , Func < float , GUIContent > buildLabel )
7081 {
0 commit comments