Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

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

Handles.ScaleValueHandle

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

public static function ScaleValueHandle(value: float, position: Vector3, rotation: Quaternion, size: float, capFunc: DrawCapFunction, snap: float): float;
public static float ScaleValueHandle(float value, Vector3 position, Quaternion rotation, float size, DrawCapFunction capFunc, float snap);
public static def ScaleValueHandle(value as float, position as Vector3, rotation as Quaternion, size as float, capFunc as DrawCapFunction, snap as float) as float

Parameters

value The value the user can modify.
position The position of the handle.
rotation The rotation of the handle.
size The size of the handle.
capFunc The function to use for drawing the handle e.g. Handles.RectangleCap.
snap The 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 single-float draggable handle.

This is used to make the center scale handle. The user can click and drag to scale a single float up and down.


Scale Value handle in the scene view with an arrow cap as the handle.

	// Increase/decrease a value just by moving an Arrow Handle
	
	@CustomEditor (ScaleValueModifier)
	class ScaleValue extends Editor {
		function OnSceneGUI () {
	        target.floatVal = 
	        	Handles.ScaleValueHandle(target.floatVal,
	 					target.transform.position,
	 					Quaternion.identity,
	 					30,
	 					Handles.ArrowCap,
	 					1);      							
	        if (GUI.changed)
	            EditorUtility.SetDirty (target);
	    }
	}

And the script attached to this Handle:

	// ScaleValueModifier.js
	// Usage: Place this script on the Game Object 
	// you want to modify "floatVal" by dragging the Arrow Handle
	
	@script ExecuteInEditMode()
	
	var floatVal : float = 1;
	
	function Update() {
		Debug.Log("Value Modified: " + floatVal);
	}