Legacy Documentation: Version 5.0
Language: English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Handles.ScaleSlider

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public static function ScaleSlider(scale: float, position: Vector3, direction: Vector3, rotation: Quaternion, size: float, snap: float): float;
public static float ScaleSlider(float scale, Vector3 position, Vector3 direction, Quaternion rotation, float size, float snap);

Parameters

scaleThe value the user can modify.
positionThe position of the handle.
directionThe direction of the handle.
rotationThe rotation of whole object.
sizeThe size of the handle.
snapThe new value after the user has modified it.

Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.

Description

Make a directional scale slider.


Scale slider handle in the Scene View.

	// Increase/decrease a value just by moving the Scale slider Handle
	
	
	@CustomEditor (FreeScale)
	class FreeScaleHandleJS extends Editor {
		function OnSceneGUI () {
	        target.val = Handles.ScaleSlider(target.val, 
	        				target.transform.position, 
	        				Vector3.up, 
	        				Quaternion.identity, 
	        				5, 
	        				HandleUtility.GetHandleSize(target.transform.position));
	        if (GUI.changed)
	            EditorUtility.SetDirty (target);
	    }
	}

And the script attached to this handle:

	// FreeScale.js
	@script ExecuteInEditMode()
	
	var val : float = 1;
	
	function Update () {
		Debug.Log("Value tied to the slider: " + val);
	}