Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

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

Handles.Slider2D

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 Slider2D(id: int, handlePos: Vector3, offset: Vector3, handleDir: Vector3, slideDir1: Vector3, slideDir2: Vector3, handleSize: float, drawFunc: Handles.DrawCapFunction, snap: Vector2, drawHelper: bool = false): Vector3;
public static Vector3 Slider2D(int id, Vector3 handlePos, Vector3 offset, Vector3 handleDir, Vector3 slideDir1, Vector3 slideDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap, bool drawHelper = false);
public static function Slider2D(handlePos: Vector3, handleDir: Vector3, slideDir1: Vector3, slideDir2: Vector3, handleSize: float, drawFunc: Handles.DrawCapFunction, snap: Vector2, drawHelper: bool = false): Vector3;
public static Vector3 Slider2D(Vector3 handlePos, Vector3 handleDir, Vector3 slideDir1, Vector3 slideDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap, bool drawHelper = false);
public static function Slider2D(id: int, handlePos: Vector3, handleDir: Vector3, slideDir1: Vector3, slideDir2: Vector3, handleSize: float, drawFunc: Handles.DrawCapFunction, snap: Vector2, drawHelper: bool = false): Vector3;
public static Vector3 Slider2D(int id, Vector3 handlePos, Vector3 handleDir, Vector3 slideDir1, Vector3 slideDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap, bool drawHelper = false);
public static function Slider2D(handlePos: Vector3, handleDir: Vector3, slideDir1: Vector3, slideDir2: Vector3, handleSize: float, drawFunc: Handles.DrawCapFunction, snap: float, drawHelper: bool = false): Vector3;
public static Vector3 Slider2D(Vector3 handlePos, Vector3 handleDir, Vector3 slideDir1, Vector3 slideDir2, float handleSize, Handles.DrawCapFunction drawFunc, float snap, bool drawHelper = false);
public static function Slider2D(id: int, handlePos: Vector3, handleDir: Vector3, slideDir1: Vector3, slideDir2: Vector3, handleSize: float, drawFunc: Handles.DrawCapFunction, snap: Vector2, drawHelper: bool = false): Vector3;
public static Vector3 Slider2D(int id, Vector3 handlePos, Vector3 handleDir, Vector3 slideDir1, Vector3 slideDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap, bool drawHelper = false);
public static function Slider2D(handlePos: Vector3, handleDir: Vector3, slideDir1: Vector3, slideDir2: Vector3, handleSize: float, drawFunc: Handles.DrawCapFunction, snap: Vector2, drawHelper: bool = false): Vector3;
public static Vector3 Slider2D(Vector3 handlePos, Vector3 handleDir, Vector3 slideDir1, Vector3 slideDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap, bool drawHelper = false);
public static function Slider2D(id: int, handlePos: Vector3, offset: Vector3, handleDir: Vector3, slideDir1: Vector3, slideDir2: Vector3, handleSize: float, drawFunc: Handles.DrawCapFunction, snap: Vector2, drawHelper: bool = false): Vector3;
public static Vector3 Slider2D(int id, Vector3 handlePos, Vector3 offset, Vector3 handleDir, Vector3 slideDir1, Vector3 slideDir2, float handleSize, Handles.DrawCapFunction drawFunc, Vector2 snap, bool drawHelper = false);
public static function Slider2D(handlePos: Vector3, handleDir: Vector3, slideDir1: Vector3, slideDir2: Vector3, handleSize: float, drawFunc: Handles.DrawCapFunction, snap: float, drawHelper: bool = false): Vector3;
public static Vector3 Slider2D(Vector3 handlePos, Vector3 handleDir, Vector3 slideDir1, Vector3 slideDir2, float handleSize, Handles.DrawCapFunction drawFunc, float snap, bool drawHelper = false);

Parameters

id (optional) override the default ControlID for this Slider2D instance.
handlePos The position of the current point.
offset (optional) renders the Slider2D at handlePos, but treats the Slider2D's origin as handlePos + offset. Useful for Slider2D instances that are placed/rendered relative to another object or handle.
handleDir The direction of the handle, only used for rendering of the handle.
slideDir1 The first direction of the sliding.
slideDir2 The second direction of the sliding.
handleSize The size of the handle.
drawFunc The function to call for doing the actual drawing - by default, it's Handles.ArrowCap, but any function that has the same signature can be used.
snap (float or Vector2) set the snap increment (Pass a Vector2 to use separate snap increments in each dimension).
drawHelper (default: false) render a rectangle around the handle when dragging.

Returns

Vector3 The new handle position

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

Description

Slide a handle in a 2D plane.

This will draw a draggable handle on the screen. The handle is constrained to sliding on a plane.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961