scale | The value the user can modify. |
position | The position of the handle. |
direction | The direction of the handle. |
rotation | The rotation of whole object. |
size | The size of the handle. |
snap | The new value after the user has modified it. |
float The value modified by the user's interaction with the handle.
Make a directional scale slider.
Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.
Scale slider handle in the Scene View.
// Name this script "ScaleSliderEditor" using UnityEngine; using UnityEditor;
[CustomEditor(typeof(ScaleSlider))] [CanEditMultipleObjects] public class ScaleSliderEditor : Editor { public void OnSceneGUI() { ScaleSlider t = (target as ScaleSlider);
EditorGUI.BeginChangeCheck(); float scale = Handles.ScaleSlider(t.scale, Vector3.zero, Vector3.right, Quaternion.identity,3,0.5f); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Scale Slider"); t.scale = scale; t.Update(); } } }
And the script attached to this GameObject:
// Name this script "ScaleSlider" using UnityEngine; [ExecuteInEditMode] public class ScaleSlider : MonoBehaviour { public float scale = 1; public void Update() { transform.localScale = new Vector3(scale,1,1); } }