Lean GUI


DOCUMENTATION

What is Lean GUI?

Lean GUI is an extension to Unity's UI system, adding many useful components.

The new components are also designed to be very flexible, so you can combine them in any way you like.



How do I get started?

Simply go through all the demo scenes in the Lean/GUI/Examples folder!

Most of the demo scenes introduce one new feature at a time, allowing you to clearly understand what is being done.

The description at the bottom also tells you in detail which components or settings were added/changed to achieve the effects seen.

To understand what a specific component setting does, just hover your mouse over it to see the tooltip. You can also click the documentation button at the top right of the component.







Assets

Here's a list of all my other assets, please check them out!

You can also view this list on my Asset Store page.

Lean Touch

Lean Touch

Rapidly develop your game with consistent input across desktop & mobile using Lean Touch. This lightweight asset comes with many modular components, allowing you to customize them to your exact project needs!


Lean Touch+

Lean Touch+

Lean Touch+ is an extension to the popular Lean Touch asset, adding many more example scenes.


Lean Localization

Lean Localization

Lean Localization is a localization library that's designed to be as simple to use as possible for both designers, and programmers.


Lean Pool

Lean Pool

Quickly optimize the performance of your games using Lean Pool. Within minutes you can use this lightweight asset to preload, recycle, and limit the spawning of your prefabs.


Lean Transition

Lean Transition

Quickly polish your games using Lean Transition. This asset allows you to easily tween or animate almost anything in your game, making it transition smoothly.


Lean GUI

Lean GUI

Lean GUI is a colllection of components that extend Unity's GUI system, allowing you to rapidly enhance the user experience (UX) of your game's UI.


Lean GUI Shapes

Lean GUI Shapes

Lean GUI Shapes allows you to quickly add lines, rounded boxes, polygons, and much more to your GUI!


Lean Texture

Lean Texture

Lean Texture allows you quickly modify textures in your project with a range of filters, pack them together into channels, and much more!


Lean Texture+

Lean Texture+

Lean Texture+ is an extension to Lean Texture, adding many new types of texture modification tools!


CW Spaceships - Build & Destroy

CW Spaceships

Build your dream spaceship, and then have fun destroying it!


CW Orbit - Modular Backgrounds

CW Orbit

Take your space game to the next level with this collection of 8K background planets. Just drag and drop them in, and enjoy orbiting around them.


CW Nebula - Modular Backgrounds

CW Nebula

Add stunning nebula backgrounds to your 3D space games with ease.


CW Gas Giant - Modular Backgrounds

CW Gas Giant

Add stunning gas giant backgrounds to your 3D space games with ease.


CW Galaxy - Modular Backgrounds

CW Galaxy

Add stunning galaxy backgrounds to your 3D space games with ease.


CW Silhouette - Modular Backgrounds

CW Silhouette

Add stunning silhouette backgrounds to your 3D space games with ease.


CW Cosmos - Modular Backgrounds

CW Cosmos

Add stunning nebula and galaxy backgrounds to your 3D space games with ease.


Paint in 3D

Paint in 3D

Paint all your objects using Paint in 3D - both in game, and in editor. All features are optimized with GPU accelerated texture painting, so you can enjoy consistent performance, even if you paint your objects one million times!


FLOW

FLOW

FLOW allows you to add large scale interactive fluids to your scene - all highly optimized using GPU acceleration.


Destructible 2D

Destructible 2D

Unlock the full potential of your 2D games using Destructible 2D, this asset allows you to quickly convert all your boring solid sprites into fully destructible ones!


Space Graphics Toolkit

Space Graphics Toolkit

Quickly make the space scene of your dreams using Space Graphics Toolkit. This huge collection of space effects can be customized and combined in any way you like, allowing you to quickly make realistic or fantasy worlds. Each feature has been heavily optimized to run on almost any device and platform.


Space Graphics Planets

Space Graphics Planets

Enhance your space scenes using this large pack of high detail volumetric planets. These planets are finished using the powerful planet features from Space Graphics Toolkit (not required).


Volumetric Audio

Volumetric Audio

Unity sounds only emanate from a single point source. This is great for explosions and footsteps, but quite often you need something more advanced. Volumetric Audio is an easy to use package that allows you to define boxes, spheres, capsules, paths, or meshes that sounds can emanate from.






Versions

2.0.3

Fixed mouse hover events in some demo scenes.



2.0.2

Moved main build to Unity 2021.3.0f1.
Updated shaders to latest version.



2.0.1

Moved main build to Unity 2020.3.0f1.



2.0.0

NOTE  This is a massive update. To update you must first back up your project, delete the root Lean folder, then install the new version.

Changed folder structure to be inside Plugins/CW/LeanGUI.
Updated inspector code to support third party assets that implement nested inspectors.
Added LeanJoystickKey component.
Added Joystick / Key demo scene.



1.2.3

Fixed transform gizmos not appearing in Unity 2021.2.



1.2.2

Fixed LeanButton on touch devices.



1.2.1

Updated common library code.
Added LeanButton.Required setting.
Added LeanJoystick.CenterOnRelease setting.
Fixed LeanChaseRigidbody.Linear setting.
Fixed LeanTooltip.Boundary = Pivot setting when the tooltip exceeds the screen size when flipped.
Renamed LeanTooltip.Boundary = Position to ShiftPosition.
Renamed LeanTooltip.Boundary = Pivot to FlipPivot.



1.2.0

Moved main build to Unity 2019.4.12f1.
Added Non/Interactable events and transitions to LeanButton.
Added Non/Interactable events and transitions to LeanDrag.
Added Non/Interactable events and transitions to LeanResize.
Added Non/Interactable events and transitions to LeanJoystick.



1.1.9

Fixed LeanJoystick inspector error.
Fixed LeanShake inspector error.



1.1.8

Added LeanSnap.Position value.
Added LeanSnap.OnPositionChanged event.
Added LeanSnapEvent component.
Added LeanTooltip.Move setting.
Improved Tooltip demo scenes.



1.1.7

Added Swipe Screens demo scene.
Added LeanSnap.HorizontalIntervalRect setting.
Added LeanSnap.VerticalIntervalRect setting.
Added LeanSnap.HorizontalIntervalParent setting.
Added LeanSnap.VerticalIntervalParent setting.
Added LeanConstrainAnchoredPosition.HorizontalRectMin/Max settings.
Added LeanConstrainAnchoredPosition.HorizontalParentMin/Max settings.
Added all legacy transition options back to LeanButton.
Added all legacy transition options back to LeanJoystick.
Added all legacy transition options back to LeanResize.
Added all legacy transition options back to LeanDrag.



1.1.6

Moved main build to Unity 2018.4.13f1.
Added LeanMoveToTop.Move setting.
Added LeanConstrainToParent.Horizontal setting.
Added LeanConstrainToParent.Vertical setting.
Added LeanConstrainAnchoredPosition component.



1.1.5

Moved main build to Unity 2018.4.0f1.
Updated documentation.
Added asmdef.
Fixed LeanJoystick bug with screen space camera UI.



1.1.4

Fixed LeanDrag bug.



1.1.3

Updated common library code.



1.1.2

Added LeanConstrainToParent component.
Added Constrain demo scene.
Fixed LeanDrag when using rotated elements.
Fixed inspector expand buttons in UI Elements.



1.1.1

Fixed bug in LeanHelper.cs that prevents making builds.



1.1.0

Updated Common library code.



1.0.9

Fixed LeanSwipe.SwipeTransitions not being called.
Fixed LeanTooltip.OnHide not being called.
Updated Common library code.
Updated demo scene design.



1.0.8

Fixed LeanJoystick.OnDown event.
Fixed LeanJoystick.OnUp event.
Improved all component tooltips and comments.



1.0.7

Added LeanButton.DragThreshold setting.



1.0.6

Updated Common library code.



1.0.5

Updated documentation.



1.0.4

Fixed tooltip rendering.



1.0.3

Added "Interactable" to LeanJoystick.



1.0.2

Included LeanTransition again.
Added Horizontal + Vertical joysticks to "14 Joystick" demo scene.



1.0.1

Fixed LeanSelectionManager error in 2019.1.5f1~.
Added "Safe Area" demo scene.



1.0.0

Initial release.







Components

LeanButton

This component provides an alternative to Unity's UI button, allowing you to easily add custom transitions, as well as add an OnDown event.


ButtonTypes
RequiredButtons

Which buttons should this component react to?



bool
MultiDown

If you enable this then OnDown + DownTransition be invoked once for each finger that begins touching the button.

If you disable this then OnDown + DownTransition will only be invoked for the first finger that begins touching the button.



float
DragThreshold

If your finger presses down on the button and drags more than this many pixels, then selection will be canceled.

-1 = Unlimited drag distance.

0 = Until the finger exits the button graphic.



LeanPlayer
NormalTransitions

This allows you to perform a transition when there are no longer any fingers touching the button.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color back to normal.



LeanPlayer
DownTransitions

This allows you to perform a transition when a finger begins touching the button.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Normal Transitions setting using a matching transition component.


LeanPlayer
ClickTransitions

This allows you to perform a transition when you click or tap on this button.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Play Sound Transition (LeanPlaySound) component can be used to play a click sound.



UnityEvent
OnDown

This allows you to perform an action when a finger begins touching the button.



UnityEvent
OnClick

This allows you to perform an action when you click or tap on this button.




LeanConstrainAnchoredPosition

This component will automatically constrain the current RectTransform.anchoredPosition to the specified range.


bool
Horizontal

Constrain horizontally?



float
HorizontalPixelMin

The minimum value in pixels.



float
HorizontalPixelMax

The maximum value in pixels.



float
HorizontalRectMin

The minimum value in 0..1 percent of the current RectTransform size.



float
HorizontalRectMax

The maximum value in 0..1 percent of the current RectTransform size.



float
HorizontalParentMin

The minimum value in 0..1 percent of the parent RectTransform size.



float
HorizontalParentMax

The maximum value in 0..1 percent of the parent RectTransform size.



bool
Vertical

Constrain vertically?



float
VerticalPixelMin

The minimum value in pixels.



float
VerticalPixelMax

The maximum value in pixels.



float
VerticalRectMin

The minimum value in 0..1 percent of the current RectTransform size.



float
VerticalRectMax

The maximum value in 0..1 percent of the current RectTransform size.



float
VerticalParentMin

The minimum value in 0..1 percent of the parent RectTransform size.



float
VerticalParentMax

The maximum value in 0..1 percent of the parent RectTransform size.



Vector2
HorizontalRange

This tells you the minimum and maximum values of the current RectTransform based on this component's horizontal anchor settings.



Vector2
VerticalRange

This tells you the minimum and maximum values of the current RectTransform based on this component's vertical anchor settings.




LeanConstrainToParent

This component will automatically constrain the current RectTransform to its parent.


bool
Horizontal

Constrain horizontally?



bool
Vertical

Constrain vertically?




LeanDrag

This component allows you to drag the specified RectTransform when you drag on this UI element.


RectTransform
Target

If you want a different RectTransform to be moved while dragging on this UI element, then specify it here. This allows you to turn the current UI element into a drag handle.



bool
Horizontal

Should you be able to drag horizontally?



bool
Vertical

Should you be able to drag vertically?



LeanPlayer
BeginTransitions

This allows you to perform a transition when this element begins being dragged.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Normal Transitions setting using a matching transition component.


LeanPlayer
EndTransitions

This allows you to perform a transition when this element ends being dragged.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.



UnityEvent
OnBegin

This allows you to perform an actions when this element begins being dragged.



UnityEvent
OnEnd

This allows you to perform an actions when this element ends being dragged.



bool
Dragging

This will return true if the mouse/finger is currently dragging this UI element.




LeanGui

This class contains useful data specific to Lean GUI.


static List<RaycastResult>
RaycastGui
Vector2 screenPosition, LayerMask layerMask

This will return all the RaycastResults under the specified screen point using the specified layerMask.

NOTE  The first result (0) will be the top UI element that was first hit.



LeanHitbox

This component allows you to change a UI element's hitbox to use its graphic Image opacity/alpha.


float
Threshold

The alpha threshold specifies the minimum alpha a pixel must have for the event to be considered a "hit" on the Image.




LeanHover

This component allows you to perform an action as long as the mouse is hovering over the current UI element, or a finger is on top.


bool
MultiEnter

Enable this if you want EnterTransitions + OnEnter to be invoked once for each mouse/finger that enters this element.



bool
MultiExit

Enable this if you want ExitTransitions + OnExit to be invoked once for each mouse/finger that exits this element.



LeanPlayer
EnterTransitions

This allows you to perform a transition when the mouse/finger enters this UI element.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Exit Transitions setting using a matching transition component.


LeanPlayer
ExitTransitions

This allows you to perform a transition when the mouse/finger exits this UI element.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.



UnityEvent
OnEnter

This allows you to perform an action when the mouse/finger enters this UI element.



UnityEvent
OnExit

This allows you to perform an action when the mouse/finger exits this UI element.




LeanJoystick

This component turns the current UI element into a joystick.


ShapeType
Shape

This allows you to control the shape of the joystick movement.

Box = -Size to +Size on x and y axes.

Circle = Within Radius on x and y axes.



Vector2
Size

This allows you to control the size of the joystick handle movement across the x and y axes.



float
Radius

The allows you to control the maximum distance the joystick handle can move across the x and y axes.



RectTransform
Handle

If you want to see where the joystick handle is, then make a child UI element, and set its RectTransform here.



float
Damping

This allows you to control how quickly the joystick handle position updates

-1 = instant.

NOTE  This is for visual purposes only, the actual joystick ScaledValue will instantly update.


bool
SnapWhileHeld

If you only want the smooth Dampening to apply when the joystick is returning to the center, then you can enable this.



bool
RelativeToOrigin

By default, the joystick will be placed relative to the center of this UI element.

If you enable this, then the joystick will be placed relative to the place you first touch this UI element.



bool
CenterOnRelease

When the mouse/finger releases from the joystick, should the joystick value reset to the center, or stay where it is?



RectTransform
RelativeRect

If you want to show the boundary of the joystick relative to the origin, then you can make a new child GameObject graphic, and set its RectTransform here.



Vector2
ScaledValue

The -1..1 x/y position of the joystick relative to the Size or Radius.

NOTE  When using a circle joystick, these values are normalized, and thus will never reach 1,1 on both axes. This prevents faster diagonal movement.


LeanPlayer
DownTransitions

This allows you to perform a transition when a finger begins touching the joystick.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Up Transitions setting using a matching transition component.


LeanPlayer
UpTransitions

This allows you to perform a transition when a finger stops touching the joystick.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.



UnityEvent
OnDown

This allows you to perform an action when a finger begins touching the joystick.



Vector2Event
OnSet

This event is invoked each frame with the ScaledValue.



UnityEvent
OnUp

This allows you to perform an action when a finger stops touching the joystick.




LeanJoystickKey

This component moves the sibling joystick in the specified direction while you hold the specified key down.


KeyCode
Key

The key that you must press for this component to add its delta to the joystick.



Vector2
Delta

The joystick handle will be moved by this many units.

X = Right.

Y = Up.



bool
ScaleByTime

Multiply the delta by Time.deltaTime before use?




LeanMoveToTop

This component will automatically move the specified transform to be the first sibling when you press down on this UI element.


MoveType
Move

This allows you to choose which component to perform the action on.

ThisTransform = transform.SetAsLastSibling().

TargetTransform = Target.SetAsLastSibling().

ParentComponents = Invoke all LeanMoveToTop ancestor components.



Transform
Target

If you want a different transform to be moved when pressing down on this UI element, then specify it here.

None = The current GameObject's transform.




LeanOrientation

This component allows you make a UI element based on the current device orientation.


bool
AnchoredPosition

Should the RectTransform.anchoredPosition setting change based on device orientation?



Vector2
AnchoredPositionL

The RectTransform.anchoredPosition value when in landscape mode.



Vector2
AnchoredPositionP

The RectTransform.anchoredPosition value when in portrait mode.



bool
SizeDelta

Should the RectTransform.sizeDelta setting change based on device orientation?



Vector2
SizeDeltaL

The RectTransform.sizeDelta value when in landscape mode.



Vector2
SizeDeltaP

The RectTransform.sizeDelta value when in portrait mode.



bool
AnchorMin

Should the RectTransform.anchorMin setting change based on device orientation?



Vector2
AnchorMinL

The RectTransform.anchorMin value when in landscape mode.



Vector2
AnchorMinP

The RectTransform.anchorMin value when in portrait mode.



bool
AnchorMax

Should the RectTransform.anchorMax setting change based on device orientation?



Vector2
AnchorMaxL

The RectTransform.anchorMax value when in landscape mode.



Vector2
AnchorMaxP

The RectTransform.anchorMax value when in portrait mode.



bool
OffsetMin

Should the RectTransform.offsetMin setting change based on device orientation?



Vector2
OffsetMinL

The RectTransform.offsetMin value when in landscape mode.



Vector2
OffsetMinP

The RectTransform.offsetMin value when in portrait mode.



bool
OffsetMax

Should the RectTransform.offsetMax setting change based on device orientation?



Vector2
OffsetMaxL

The RectTransform.offsetMax value when in landscape mode.



Vector2
OffsetMaxP

The RectTransform.offsetMax value when in portrait mode.



bool
Pivot

Should the RectTransform.pivot setting change based on device orientation?



Vector2
PivotL

The RectTransform.pivot value when in landscape mode.



Vector2
PivotP

The RectTransform.pivot value when in portrait mode.



bool
LocalRotation

Should the RectTransform.localRotation setting change based on device orientation?



Quaternion
LocalRotationL

The RectTransform.localRotation value when in landscape mode.



Quaternion
LocalRotationP

The RectTransform.localRotation value when in portrait mode.



bool
LocalScale

Should the RectTransform.localScale setting change based on device orientation?



Vector3
LocalScaleL

The RectTransform.localScale value when in landscape mode.



Vector3
LocalScaleP

The RectTransform.localScale value when in portrait mode.



LeanPlayer
LandscapeTransitions

This allows you to perform a transition when the orientation changes to landscape.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Portrait Transitions setting using a matching transition component.


LeanPlayer
PortraitTransitions

This allows you to perform a transition when the orientation changes to portrait.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Landscape Transitions setting using a matching transition component.


UnityEvent
OnLandscape

This event will be invoked when the orientation changes to landscape.



UnityEvent
OnPortrait

This event will be invoked when the orientation changes to portrait.



void
CopyToLandscape

This will copy the current RectTransform settings to the Landscape settings.



void
CopyToPortrait

This will copy the current RectTransform settings to the Portrait settings.



void
UpdateOrientation

This forces the orientation to update now.

NOTE  This will call OnLandscape/OnPortrait again.



LeanPulse

This component allows you to trigger a transition and/or event at regular intervals.


static LinkedList<LeanPulse>
Instances

This stores all active and enabled LeanPulse instances, so you can manually pulse them by name from anywhere.



int
RemainingPulses

This tells you how many pulses remain until this component stops.

-1 = unlimited



float
RemainingTime

When this reaches 0, and RemainingPulses is not 0, this component will pulse.



float
TimeInterval

This allows you to control the amount of seconds between each pulse.

-1 = Manual Pulses Only



LeanTiming
Timing

This allows you to choose where in the game loop this pulse will update.



LeanPlayer
PulseTransitions

This allows you to perform an animation when this UI element pulses.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the LeanPlaySound (Play Sound Transition) component can be used to play a pulse sound.



IntEvent
OnPulse

This allows you to perform an action when this UI element pulses.

int = RemainingPulses



void
TryPulse

This will pulse, as long as you have remaining pulses.



void
Pulse

This allows you to manually force this component to pulse right now.



static void
TryPulseAll
string name

This method calls TryPulse on all active and enabled LeanPulse instances with the specified GameObject name.



static void
PulseAll
string name

This method calls Pulse on all active and enabled LeanPulse instances with the specified GameObject name.




LeanResize

This component allows you to resize the specified RectTransform when you drag on this UI element.


RectTransform
Target

If you want this GameObject to act as a resize handle, and for a different object to actually be resized then specify the target object here.



bool
Horizontal

Should you be able to drag horizontally?



float
HorizontalScale

Horizontal resize strength.

0 = none

1 = normal

-1 = inverted

2 = centered



bool
HorizontalClamp

Should the horizontal size value be clamped?



float
HorizontalMin

The minimum size value.



float
HorizontalMax

The maximum size value.



bool
Vertical

Should you be able to drag vertically?



float
VerticalScale

Vertical resize strength.

0 = none

1 = normal

-1 = inverted

2 = centered



bool
VerticalClamp

Should the vertical size value be clamped?



float
VerticalMin

The minimum size value.



float
VerticalMax

The maximum size value.



LeanPlayer
BeginTransitions

This allows you to perform a transition when this element begins being resized.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Normal Transitions setting using a matching transition component.


LeanPlayer
EndTransitions

This allows you to perform a transition when this element ends being resized.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.



UnityEvent
OnBegin

This allows you to perform an actions when this element begins being resized.



UnityEvent
OnEnd

This allows you to perform an actions when this element ends being resized.




LeanSafeArea

This component adds a safe area to your UI. This is mainly used to prevent UI elements from going through notches on mobile devices.

This component should be added to a GameObject that is a child of your Canvas root.


bool
Horizontal

Should you be able to drag horizontally?



bool
Vertical

Should you be able to drag vertically?



void
UpdateSafeArea

This method will instantly update the safe area RectTransform.




LeanSelectable

This component provides an alternative to Unity's UI button, allowing you to easily add custom transitions, as well as add an OnDown event.


LeanPlayer
InteractableTransitions

This allows you to perform a transition when this element becomes interactable.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Landscape Transitions setting using a matching transition component.


LeanPlayer
NonInteractableTransitions

This allows you to perform a transition when this element becomes non-interactable.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Landscape Transitions setting using a matching transition component.



LeanSelection

This component allows you to perform a transition when this UI element is selected.


LeanPlayer
SelectTransitions

This allows you to perform a transition when this UI element is selected.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Deselect Transitions setting using a matching transition component.


LeanPlayer
DeselectTransitions

This allows you to perform a transition when this UI element is deselected.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Select Transitions setting using a matching transition component.



LeanSelectionHighlight

This component will place the current RectTransform above the currently selected object.


Camera
WorldCamera

The camera rendering the target transform/position.

None = MainCamera.



LeanPlayer
ShowTransitions

This allows you to perform a transition when the highlight begins.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Hide Transitions setting using a matching transition component.


LeanPlayer
HideTransitions

This allows you to perform a transition when the highlight ends.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here must be reverted in the Show Transitions setting using a matching transition component.


UnityEvent
OnShow

This allows you to perform an action when the highlight starts.



UnityEvent
OnHide

This allows you to perform an action when the highlight ends.




LeanSelectionManager

This component allows you to force selection of a selectable, or select a previously selected object.


bool
ForceSelection

If the scene contains at least one selectable, and there is currently no selected object, should it be selected?

NOTE  If there are multiple selectables in the scene, then one will be chosen based on the LeanSelectionPriority component setting.


List<Selectable>
SelectionHistory

This stores a list of all selectables in the order they were selected. This allows selection to revert to a previous one if the current selectable becomes unselectable.




LeanSelectionPriority

This component marks the current GameObject as being high priority for selection.

This setting is used by the LeanSelectionManager when decided what to select.


float
Priority

This allows you to set the priority of this GameObject among others when being automatically selected.




LeanShake

This component allows you to shake the specified Transform, with various controls for shake axes, strength, dampening, etc.

NOTE  This component works with normal Transforms as well as UI RectTranforms.

float
Speed

This allows you to set the speed of the shake animation.



float
Strength

This allows you to set the current strength of the shake. This value can automatically decay based on the Dampening and Reduction settings.



float
Multiplier

This allows you to set the final shake strength multiplier. This remains constant.



float
Damping

This allows you to set the dampening of the Strength value. This decay slows down as it approaches 0.



float
Reduction

This allows you to set the reduction of the Strength value. This decay slows down at a constant rate per second.



Vector3
ShakePosition

This allows you to set the position axes you want to shake in local units.



Vector3
ShakeRotation

This allows you to set the rotation axes you want to shake in degrees.




LeanSizer

This component allows you to change the size of the Target RectTransform based on the size of this one.

This is very useful for text that needs to be inside a parent container, but you don't know how big that container should be.


RectTransform
Target

The RectTransform whose size we want to modify.



bool
Scale

Factor in scale when reading the size of the target?



bool
Horizontal

Match the scale horizontally?



bool
Vertical

Match the scale vertically?




LeanSnap

This component will automatically snap RectTransform.anchoredPosition to the specified interval.


bool
Horizontal

Snap horizontally?



float
HorizontalOffset

The snap points will be offset by this many pixels.



float
HorizontalIntervalPixel

The spacing between each snap point in pixels.



float
HorizontalIntervalRect

The spacing between each snap point in 0..1 percent of the current RectTransform size.



float
HorizontalIntervalParent

The spacing between each snap point in 0..1 percent of the parent.



float
HorizontalSpeed

The snap speed.

-1 = Instant.

1 = Slow.

10 = Fast.



bool
Vertical

Snap vertically?



float
VerticalOffset

The snap points will be offset by this many pixels.



float
VerticalIntervalPixel

The spacing between each snap point in pixels.



float
VerticalIntervalRect

The spacing between each snap point in 0..1 percent of the current RectTransform size.



float
VerticalIntervalParent

The spacing between each snap point in 0..1 percent of the parent.



float
VerticalSpeed

The snap speed.

-1 = Instant.

1 = Slow.

10 = Fast.



LeanDrag
DisableWith

To prevent UI element dragging from conflicting with snapping, you can specify the drag component here.



Vector2Int
Position

This tells you the snap position as integers.



Vector2IntEvent
OnPositionChanged

This event will be invoked when the snap position changes.




LeanSnapEvent

This component allows you to fire an events when the LeanSnap component's Position is at specific values.


Vector2Int
Position

The LeanSnap.Position you want to listen for.



UnityEvent
OnAction

The action that will be invoked.




LeanSwipe

This component allows you to detect when a finger swipes over the current RectTransform.


float
MinimumDistance

The swiping finger must move at least this many pixels.



float
MaximumTime

The swiping finger must move MinimumDistance within this amount of seconds.



bool
CheckAngle

If you need the swipe to be in a specific direction, then enable this.



float
DesiredAngle

0 = up

90 = right

180 = down

270 = left



float
MaximumRange

360 = full circle

180 = half circle

90 = quarter circle



LeanPlayer
SwipeTransitions

This allows you to perform a transition when you swipe this UI element.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the LeanPlaySound (Play Sound Transition) component can be used to play a click sound.



UnityEvent
OnSwipe

This allows you to perform an action when you swipe this UI element.




LeanSwitch

This component allows you to make an UI element that can switch between any number of states.


static LinkedList<LeanSwitch>
Instances

This stores all active and enabled LeanSwitch instances.



int
State

This is the currently active state of the switch.

For example, if this is 0 then the switch is currently in the first transition state.



List<LeanPlayer>
States

This stores a list of all switch transition states. This controls how many states can be switched between.

For example, if you want to be able to switch between 4 states, then make sure the size of this list = 4.



LeanPlayer
ChangedStateTransitions

This allows you to perform a transition when this switch changes to a different state.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the LeanPlaySound (Play Sound Transition) component can be used to play a switch sound.



IntUnityEvent
OnChangedState

This allows you to perform an action when this switch changes to a different state.



void
Switch
int newState

This allows you to switch to a different state, where 0 is the first state. The amount of states is defined by the size of the Transitions list.



static void
SwitchAll
string name, int state

This allows you to switch all active and enabled states with the specified name to the specified state.




LeanToggle

This component allows you to make a UI element that can switch between two states.

For example, you could create a panel that shows and hides using this component.

NOTE  If you want to create windows that toggle open and closed, then I recommend you instead use the Lean Window component. This works identically, but it also registers with the Lean Window Closer component, allowing you to close them in sequence.

static LinkedList<LeanToggle>
Instances

This stores all active and enabled LeanToggle instances.



bool
On

This lets you change the current toggle state of this UI element.



bool
TurnOffSiblings

If you enable this, then any sibling GameObjects (i.e. same parent GameObject) will automatically be turned off.

This allows you to make radio boxes, or force only one panel to show at a time, etc.



LeanPlayer
OnTransitions

This allows you to perform a transition when this toggle turns on.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here should be reverted in the Off Transitions setting using a matching transition component.


LeanPlayer
OffTransitions

This allows you to perform a transition when this toggle turns off.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.



UnityEvent
OnOn

This allows you to perform an action when this toggle turns on.



UnityEvent
OnOff

This allows you to perform an action when this toggle turns off.



void
Set
bool value

This allows you to set the toggle on or off.



void
Toggle

This allows you to toggle the state of this toggle (i.e. if it's turned on, then this will turn it off).



void
TurnOn

If this toggle is turned off, then this will turn it on.



void
TurnOffSiblingsNow

This will search for any sibling toggles (i.e. they have the same parent GameObject), and turn them off.



void
TurnOffOthersNow

This will go through every toggle in the scene except this one, and turn them off.



static bool
AllOn
string name

This will return true if all the active and enabled toggle instances with the specified GameObject name are turned on.



static bool
AllOff
string name

This will return true if all the active and enabled toggle instances with the specified GameObject name are turned off.



static void
SetAll
string name, bool on

This allows you to set the On state of all the active and enabled toggle instances with the specified GameObject name.



static void
ToggleAll
string name

This allows you to toggle the state (i.e. if it's turned on, then this will turn it off) of all active and enabled toggle instances with the specified GameObject name.



static void
TurnOnAll
string name

This allows you to turn on every active and enabled toggle instance with the specified GameObject name.



static void
TurnOffAll
string name

This allows you to turn off each active and enabled LeanToggle instance with the specified GameObject name.




LeanTooltip

This component allows you to display a tooltip as long as the mouse is hovering over the current UI element, or a finger is on top.

Tooltips will display for any raycastable UI element that has the LeanTooltipData component.


ActivationType
Activation

This allows you to control when the tooltip will appear.

HoverOrPress = When the mouse is hovering, or when the mouse/finger is pressing.

Hover = Only when the mouse is hovering.

Press = Only when the mouse/finger is pressing.



float
ShowDelay

This allows you to delay how quickly the tooltip will appear or switch.



bool
Move

Move the attached Transform when the tooltip is open?



BoundaryType
Boundary

This allows you to control how the tooltip will behave when it goes outside the screen bounds.

FlipPivot = If the tooltip goes outside one of the screen boundaries, flip its pivot point on that axis so it goes the other way.

ShiftPosition = If the tooltip goes outside of the screen boundaries, shift its position until it's back inside.

NOTE  If FlipPivot is used and the tooltip is larger than the screen size, then it will revert to ShiftPosition.


LeanPlayer
ShowTransitions

This allows you to perform a transition when this tooltip appears.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.

NOTE  Any transitions you perform here should be reverted in the Hide Transitions setting using a matching transition component.


LeanPlayer
HideTransitions

This allows you to perform a transition when this tooltip hides.

You can create a new transition GameObject by right clicking the transition name, and selecting Create.

For example, the Graphic.color Transition (LeanGraphicColor) component can be used to change the color.



UnityEventString
OnShow

This allows you to perform an action when this tooltip appears.



UnityEvent
OnHide

This allows you to perform an action when this tooltip hides.




LeanTooltipData

This component allows you to associate text with this GameObject, allowing it to be displayed from a tooltip.

NOTE  If this component is enabled while a finger is hovered over this element, then it will not trigger the OnPointerEnter event.

UnityEngine.UI.Selectable
Selectable

If you want this tooltip to hide when a selectable (e.g. Button) is disabled or non-interactable, then specify it here.



string
Text

This allows you to set the tooltip text string that is associated with this object.




LeanWindow LeanToggle

This component works just like LeanToggle, but it registers itself with the LeanWindowCloser.

This allows the window to be automatically closed if you press the LeanWindowCloser.CloseKey.



LeanWindowCloser

This component allows you to automatically close the top-most LeanWindow when you press the specified key.


static List<LeanWindowCloser>
Instances

This stores all active and enabled LeanWindowCloser instances.



KeyCode
CloseKey

This allows you to set the key that must be pressed to close the window on top.



LeanWindow
EmptyWindow

If every window is closed and you press the close key, this window will be opened. This can be used to open an options menu.



List<LeanWindow>
WindowOrder

This stores a list of all opened windows, in order of opening, so they can be closed in reverse order.



void
CloseAll

This allows you to close all open LeanWindows.



void
CloseTopMost

This allows you to close the top most LeanWindow.




Index

What is Lean GUI?

How do I get started?



Assets

Lean Touch

Lean Touch+

Lean Localization

Lean Pool

Lean Transition

Lean GUI

Lean GUI Shapes

Lean Texture

Lean Texture+

CW Spaceships

CW Orbit

CW Nebula

CW Gas Giant

CW Galaxy

CW Silhouette

CW Cosmos

Paint in 3D

FLOW

Destructible 2D

Space Graphics Toolkit

Space Graphics Planets

Volumetric Audio



Versions

2.0.3

2.0.2

2.0.1

2.0.0

1.2.3

1.2.2

1.2.1

1.2.0

1.1.9

1.1.8

1.1.7

1.1.6

1.1.5

1.1.4

1.1.3

1.1.2

1.1.1

1.1.0

1.0.9

1.0.8

1.0.7

1.0.6

1.0.5

1.0.4

1.0.3

1.0.2

1.0.1

1.0.0



Components

LeanButton

LeanConstrainAnchoredPosition

LeanConstrainToParent

LeanDrag

LeanGui

LeanHitbox

LeanHover

LeanJoystick

LeanJoystickKey

LeanMoveToTop

LeanOrientation

LeanPulse

LeanResize

LeanSafeArea

LeanSelectable

LeanSelection

LeanSelectionHighlight

LeanSelectionManager

LeanSelectionPriority

LeanShake

LeanSizer

LeanSnap

LeanSnapEvent

LeanSwipe

LeanSwitch

LeanToggle

LeanTooltip

LeanTooltipData

LeanWindow

LeanWindowCloser