Lean Touch


DOCUMENTATION

How do I get started?

First you need to add the LeanTouch component to your scene:

METHOD 1 From your menu bar, select GameObject > Lean > Touch.
METHOD 2 Right click inside the Hierarchy window, and go to Lean > Touch.
METHOD 3 Create a new GameObject, and add the component Lean > Touch.

You should now see a new GameObject called 'LeanTouch' with the LeanTouch component selected.

When you enter play mode, this component will automatically convert all mouse and touch input into an easy to use format.

Remember that scripts using Lean Touch only work when there is a LeanTouch component active in your scene, so make sure to add one to every scene (or carry it over with DontDestroyOnLoad).

NOTE  If you want to simulate multi finger gestures on desktop then click the Add Simulator button.


How do I use Lean Touch without code?

Lean Touch comes with many example components to do common tasks.

For example, if you want to spawn a prefab when a finger touches the screen, you can begin by making a new GameObject, and adding the LeanSpawn component.

Inside this component, you'll see it has the Prefab setting. You can browse or drag and drop your desired prefab here.

Next, you can add the LeanFingerTap component. Inside this component, you'll see it has the OnFinger event.

To link this event to the prefab spawning, you need to click the plus + button below where it says List is Empty, and in the bottom left box that says None (Object), you need to drag and drop the LeanSpawn component you added earlier.

Next, you need to click the No Function dropdown, and select the LeanSpawn > Dynamic LeanFinger > Spawn function. You can now hit play, and tapping a finger (or clicking) on the screen will spawn your prefab.

There are many other components that work in similar ways that can be connected together using only the editor. To find out how these work, I recommend you browse through the demo scenes and look at the GameObjects to see what's going on.



How do I use Lean Touch with C#?

You can access all finger data from the Lean.Touch.LeanTouch class.

The easiest way to begin is by hooking into the static events it exposes.

For example, if you want to perform an action when a finger touches the screen, you can hook into the Lean.Touch.LeanTouch.OnFingerDown event. This event gets called every time a finger begins touching the screen, and gets passed a Lean.Touch.LeanFinger instance as a parameter. It's recommended you hook into these events from OnEnable, and unhook from OnDisable.

public class MyCoolScript : MonoBehaviour
{
void OnEnable()
{
Lean.Touch.LeanTouch.OnFingerTap += HandleFingerTap;
}

void OnDisable()
{
Lean.Touch.LeanTouch.OnFingerTap -= HandleFingerTap;
}

void HandleFingerTap(Lean.Touch.LeanFinger finger)
{
Debug.Log("You just tapped the screen with finger " + finger.Index + " at " + finger.ScreenPosition);
}
}

To see what other events are available, I recommend you read the LeanTouch.cs, script and its comments.

Another way to access finger data is to poll it directly from the Lean.Touch.LeanTouch.Fingers static list. This list stores all fingers that are currently touching the screen, and you can use this data at any time (e.g. Update) to quickly handle input.

public class MyCoolScript : MonoBehaviour
{
void Update()
{
var fingers = Lean.Touch.LeanTouch.Fingers;

Debug.Log("There are currently " + fingers.Count + " fingers touching the screen.");
}
}

If you need to modify or exclude certain fingers then I highly recommend you use the Lean.Touch.LeanTouch.GetFingers(...) method, which has common filter options, and will return a temporary list that you can further filter without breaking LeanTouch.



How do I handle multi-finger gestures (e.g. Pinch, Twist) from C#?

The Lean.Touch.LeanGesture class makes this very easy.

For example, if you want to find how many degrees the fingers were twisted in the last frame, you can call:

Lean.Touch.LeanGesture.GetTwistDegrees()

This method will automatically calculate it from all fingers. This method also has an overload that allows you to pass a specific list of fingers if you don't want to use them all.

To see what other gestures are available, I recommend you read the LeanGesture.cs script and its comments.



Why are my inputs delayed by one frame?

The main LeanTouch component and other Lean components run from inside the Update method. If you're using components that also use Update, then there can be scenarios where your components are using old input data, and everything will be delayed by one frame.

To fix this, you must manually adjust the Script Execution Order of these components, so that the Lean components execute before yours, or to make yours execute after.

Step 1 Go to Edit > Project Settings > Script Execution Order.
Step 2 Below the Default Time box, click the + button, and select a component like Lean.Touch.LeanTouch.
Step 3 Change the execution order value. To make it execute before most components then set it below the Default Time (e.g. -100), or above (e.g. 100) to make it execute after.
Step 4 Click Apply, and enjoy!


How do I stop my touch controls from going through my UI from C#?

If you hook into any of the Lean.Touch.LeanTouch.OnFinger___ events, you will get a Lean.Touch.LeanFinger instance. This class has the IsOverGui and StartedOverGui values you can check.

public class MyCoolScript : MonoBehaviour
{
void OnEnable()
{
Lean.Touch.LeanTouch.OnFingerTap += HandleFingerTap;
}

void OnDisable()
{
Lean.Touch.LeanTouch.OnFingerTap -= HandleFingerTap;
}

void HandleFingerTap(Lean.Touch.LeanFinger finger)
{
if (finger.IsOverGui)
{
Debug.Log("You just tapped the screen on top of the GUI!");
}
}
}

If you're polling from Lean.Touch.LeanTouch.Fingers and want to quickly remove fingers that are touching the GUI, you can instead get the fingers from the Lean.Touch.LeanTouch.GetFingers method, which has a setting to quickly exclude these, as well as restrict it to a certain amount of fingers.



Why do I have to keep typing Lean.Touch. before everything?

To improve organization, all Lean Touch classes are inside the Lean.Touch namespace.

If you don't like typing Lean.Touch. each time, then you can add the following code to the top of your source file:

using Lean.Touch;

If you're polling from Lean.Touch.LeanTouch.Fingers and want to quickly remove fingers that are touching the GUI, you can instead get the fingers from the Lean.Touch.LeanTouch.GetFingers method, which has a setting to quickly exclude these, as well as restrict it to a certain amount of fingers.

You can now just call LeanTouch.PointOverGui(...) etc.

using UnityEngine;
using Lean.Touch;

public class MyCoolScript : MonoBehaviour
{
void OnEnable()
{
LeanTouch.OnFingerTap += HandleFingerTap;
}

void OnDisable()
{
LeanTouch.OnFingerTap -= HandleFingerTap;
}

void HandleFingerTap(LeanFinger finger)
{
if (finger.IsOverGui)
{
Debug.Log("You just tapped the screen on top of the GUI!");
}
}
}


What is Lean Touch+?

Lean Touch+ is a huge collection of new example scenes and components, mostly requested by users. Although the core code is the same, these examples show you in detail how to implement features found in many modern games and applications, saving you lots of time.

Lean Touch+



Can I request a new demo scene?

Yes, if you have an idea for a demo scene that doesn't come with LeanTouch or LeanTouch+ then please request it via e-mail above.

Just make sure your demo scene idea doesn't require another asset or library, because I can't include those in this package!

If I like your demo scene idea then I'll even send you a free copy of Lean Touch+



How does the Screen Depth inspector setting work?

Fingers touching the screen only have a 2D XY position, but many touch interactions require calculating a 3D XYZ position from the 2D position (e.g. LeanCameraDrag). To handle this 2D to 3D conversion, most components have the ScreenDepth setting, which has many options to support 2D games, 3D games, perspective 2D games, and much more.

Understanding exactly how this works and how it can be used in your games is difficult, so I recommend you examine the demo scenes to see how they are set up.

The way it can work with all these different scene types is via the dropdown box, and associated settings.

Fixed Distance - This setting calculates a position in front of the current camera at the finger position, where the Distance setting is the distance from the camera in world space the point is pushed away. This setting is suitable for scenarios where your foreground objects should always appear the same distance to the camera, even if your camera can move or rotate.

Depth Intercept - This setting calculates a ray in front of the current camera at the finger position, and finds the point where this ray intercepts a plane lying on the XY axes with the specified Z position. This setting is suitable for normal 2D games. If you're using standard 2D settings then a Z value of 0 should be used, but this can be adjusted for specific situations, because 2D sprites in Unity can be placed at any Z position and still work.

Physics Raycast - This setting calculates a ray in front of the current camera at the finger position, and finds the point where this ray hits the physics scene. This setting is suitable for 3D games where you need to spawn something on an object or similar.

Plane Intercept - This setting works similar to Depth Intercept, but allows you to specify a custom LeanPlane that can point in any direction, and optionally allows you to constrain or snap the final values.

Path Closest - This setting works similar to Depth Intercept, but it will find the closest point along the specified LeanPath to the screen point.

Auto Distance - This setting works similar to Fixed Distance, but the distance will be automatically calculated based on the depth of the current GameObject. This setting is suitable for scenarios where objects in your scene can appear at arbitrary dstances to the camera.

Height Intercept - This setting works similar to Depth Intercept, but the ray will intercept against a flat plane lying on the XZ axes. This setting is suitable for 3D games in a top-down scenario, where the playing field is flat.



Why do I have to link up so many components?

There are two main types of components in LeanTouch: self-contained components, and separated components.

An example of a self-contained component is LeanTranslate. This component has code to detect which fingers you want to use for the translation, and also has code to process the finger data and convert them it into a translation movement.

An example of separated components are LeanFingerTap and LeanSpawn. These components must be linked together to work. Where LeanFingerTap detects when a finger taps the screen, and in the editor you must connect its OnWorldTo event to the LeanSpawn.Spawn method.

In earlier versions of LeanTouch, most components were self-contained like LeanTranslate. This allowed users to quickly add touch controls to their games, but this made it difficult to customize the controls. Users would have to ask me to make changes, or they would have to modify the code themselves, this wasted a lot of time.

To save time and make Lean Touch more flexible, almost all new features use this separated component system. To make this new system easy to learn I've made lots of demo scenes showing you how to combine each component in different ways.



Why do all my objects move at the same time?

Most LeanTouch components are designed to work on their own, or with selection. If you have many objects set to work on their own then touching the screen will cause them all to move at the same time.

To fix this, you need to make your objects work using selection. To do this, just add the LeanSelectable component to each of your objects. You'll then notice each LeanTouch component comes with the RequiredSelectable setting, this setting can be used to turn off the current component if the specified selectable isn't selected. You can drag and drop the LeanSelectable component you added earlier into these fields.

Once done, you need to tell LeanTouch how you want to select your objects. The simplest way to do this is by adding the LeanFingerTap and LeanSelect components to your scene. You can then connect the LeanFingerTap.OnFinger event to the LeanSelect.SelectScreenPosition function. By default the LeanSelect component is designed to select 2D objects, if you want to select 3D objects then change the Select Using setting to Raycast 3D.

This can be a little difficult to understand, so I recommend you look at the Select 3D & Select 2D & Select UI demo scenes. These scenes are already correctly setup with selection, and the description text at the bottom describes how it's set up.

You can also have press selection as seen in the Press 2D & Press3D & PressUI demo scenes, or isolation selection as seen in the Press 2D / Isolate & Press 3D / Isolate & Press UI / Isolate demo scenes.







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 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 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.


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!


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.


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.


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 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 GUI Shapes

Lean GUI Shapes

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


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!


Planet Pack - Space Graphics Toolkit

Planet Pack - Space Graphics Toolkit

This pack contains 26 high detail PBR planets, all finished using the powerful planet features of Space Graphics Toolkit (SGT). This is a standalone package, so SGT is not required. You can even use the included features to turn your own planets into beautiful worlds!


Lean Touch+

Lean Touch+

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


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.2.0

NOTE  This is a huge update. Back up your project files before installing.

Fixed LeanFingerFilter ignoring manually added fingers that went up.
Simplified organization of all demo scenes.
Added LeanSelect.Limit setting.
The LeanSelect component now stores what it selected.
Allowed multiple LeanSelect components to operate at once.
Added mouse hover simulated finger.
Moved multi finger simulation to new LeanTouchSimulator component.
Moved LeanSelect.SearchType to ScreenQuery setting.
Moved LeanSelectable.DeselectOnUp to LeanSelect.DeselectWithNothing setting.
Renamed LeanSelectable.IsSelected to SelfSelected.
Renamed LeanSelectable.OnSelect to OnSelectedFinger.
Renamed LeanSelectable.OnDeselect to OnDeselected.
Renamed LeanSelect.AutoDeselect to DeselectWithNothing.
Added LeanTouch.UseTouch setting.
Added LeanTouch.UseHover setting.
Added LeanTouch.UseMouse setting.
Added LeanTouch.UseSimulator setting.
Added LeanSelectable.OnSelected event.
Added LeanSelectable.OnFirstSelected event.
Added LeanSelectable.OnLastDeselected event.
Added LeanSelect.OnNothing event.
Renamed LeanSelectable to LeanSelectableByFinger.
Renamed LeanSelect to LeanSelectByFinger.
Combined 3D, 2D, and UI demo scenes.



2.1.8

Added LeanFingerTap.OnScreen event.
Renamed LeanFingerUp.OnPosition event to OnWorld.
Added LeanFingerDown.OnScreen event.
Added LeanFingerUp.OnScreen event.
Added LeanFingerOld.OnScreen event.
Renamed LeanFingerOld.OnPosition event to OnWorld.
Fixed MainCamera tag error appearing in certain circumstances.
Added LeanRoll.Clamp setting.
Added LeanRoll.ClampMin setting.
Added LeanRoll.ClampMax setting.



2.1.7

Made Use/RequiredMouseButtons work separately from RequiredFingerCount.



2.1.6

Minor code improvements.



2.1.5

Added LeanSelect.RequiredTag setting.
Fixed LeanTouch component error in rare scenario.



2.1.4

Fixed rare scenario where fingers could remain pressed after release.



2.1.3

Fixed bug with LeanSelectable inspector.



2.1.2

Moved main build to Unity 2018.4.13f1.
Added support for new input system.
Added Intersect2D selection mode to LeanSelect component.
Reverted LeanSelect component's Overlap2D selection implementation.
Extended LeanTouch.OnFingerSet to also invoke on the last frame a finger touches the screen.
Renamed LeanTouch.OnFingerSet to LeanTouch.OnFingerUpdate.
Renamed LeanFingerSet to LeanFingerUpdate.
Moved many components to Extras folder.



2.1.1

Restructured all demo scenes to be easier to use.
Renamed LeanFingerDown.OnPosition to OnWorld.
Renamed LeanFingerTap.OnPosition to OnWorld.
Changed LeanTouch default execution order to -100.
Changed default LeanTouch.GuiLayers to UI only.



2.1.0

Moved main build to Unity 2018.4.0f1.
Updated documentation.
Added asmdef.



2.0.9

Improved LeanDragCamera.Inertia implementation.
Added LeanDragTranslate.Inertia setting.
Fixed LeanSelect Raycast order.



2.0.8

Modified LeanSpawn to spawn at the current Transform.position by default.
Fixed LeanSelect when using a perspective camera and selecting 2D objects.
Added LeanDragCamera.Inertia setting.
Updated common library code.



2.0.7

Fixed inspector expand buttons in UI Elements.
Fixed LeanDragTranslate being slow in some scenarios.
Fixed LeanTwistRotate being slow in some scenarios.
Fixed LeanPinchScale being slow in some scenarios.



2.0.6

Fixed bug in LeanHelper.cs that prevents making builds.



2.0.5

Updated Common library code.



2.0.4

Fixed LeanTouch.OnFingerUp not being called in some scenarios.
Renamed TapSpawnCount demo scene to TapSpawnDouble.



2.0.3

Fixed LeanDragTranslate when using screen space UI.
Fixed LeanPinchScale when using screen space UI.
Fixed LeanTwistRotate when using screen space UI.



2.0.2

Fixed LeanSelectable.IsolateSelectingFingers when using RequiredFingerCount.
Fixed Added LeanSelectableBehaviour error when missing LeanSelectable.
Added LeanSelectable.Register for manual registration.
Added LeanSelectable.Unregister for manual unregistration.
Added LeanTouch.OnFingerInactive event.



2.0.1

Added LeanFinger.OnFingerOld event.
Added LeanFingerOld component.
Added FingerOld demo scene.
Moved LeanFingerHeld to LeanTouch+.



2.0.0

NOTE  This is a MAJOR update to LeanTouch. I recommend you only use this in new projects.

Redesigned all demo scenes.
Added smoothing/dampening to all components.
Renamed LeanCameraMove to LeanDragCamera.
Renamed LeanCameraZoom to LeanPinchCamera.
Moved LeanPinchCamera to LeanTouch+
Renamed LeanRotate to LeanTwistRotate.
Renamed LeanTranslate to LeanDragRotate.
Renamed LeanScale to LeanPinchScale.
Renamed LeanCanvasArrow to LeanRoll.
Added LeanInfoText component.
Rewrote LeanFingerDown component events.
Rewrote LeanFingerHeld component events.
Rewrote LeanFingerSet component events.
Rewrote LeanFingerSwipe component events.
Rewrote LeanFingerTap component events.
Rewrote LeanFingerUp component events.
Added LeanFingerFilter class for common filtering.







Components

LeanFinger

This class stores information about a single touch (or simulated touch).


int
Index

This is the hardware ID of the finger.

NOTE  Simulated fingers will use hardware ID -1 and -2.


float
Age

This tells you how long this finger has been active (or inactive) in seconds.



bool
Set

Is this finger currently touching the screen?



bool
LastSet

This tells you the 'Set' value of the last frame.



bool
Tap

Did this finger just tap the screen?



int
TapCount

This tells you how many times this finger has been tapped.



bool
Swipe

Did this finger just swipe the screen?



bool
Old

If this finger has been touching the screen for more than TapThreshold, this will be true.



bool
Expired

If this finger has been inactive for more than TapThreshold, this will be true.



float
LastPressure

This tells you the Pressure value last frame.



float
Pressure

This tells you the current pressure of this finger (NOTE: only some devices support this).



Vector2
StartScreenPosition

This tells you the 'ScreenPosition' value of this finger when it began touching the screen.



Vector2
LastScreenPosition

This tells you the last screen position of the finger.



Vector2
ScreenPosition

This tells you the current screen position of the finger in pixels, where 0,0 = bottom left.



bool
StartedOverGui

This tells you if the current finger had 'IsOverGui' set to true when it began touching the screen.



List<LeanSnapshot>
Snapshots

Used to store position snapshots, enable RecordFingers in LeanTouch to use this.



bool
IsActive

This will return true if this finger is currently touching the screen.



float
SnapshotDuration

This will tell you how many seconds of snapshot footage is stored for this finger.



bool
IsOverGui

This will return true if the current finger is over any Unity GUI elements.



bool
Down

Did this finger begin touching the screen this frame?



bool
Up

Did the finger stop touching the screen this frame?



Vector2
LastSnapshotScreenDelta

This will return how far in pixels the finger has moved since the last recorded snapshot.



Vector2
LastSnapshotScaledDelta

This returns a resolution-independent 'LastSnapshotScreenDelta' value.



Vector2
ScreenDelta

This will return how far in pixels the finger has moved since the last frame.



Vector2
ScaledDelta

This returns a resolution-independent 'ScreenDelta' value.



Vector2
SwipeScreenDelta

This tells you how far this finger has moved since it began touching the screen.



Vector2
SwipeScaledDelta

This returns a resolution-independent 'SwipeScreenDelta' value.



float
SmoothScreenPositionDelta

This returns the screen space distance between the 0 and 1 smooth screen positions.



Vector2
GetSmoothScreenPosition
float t

This returns a smooth point between the previous and current screen position based on a 0..1 progress value.



Ray
GetRay
Camera camera = null

This will return the ray of the finger's current position relative to the specified camera (none/null = Main Camera).



Ray
GetStartRay
Camera camera = null

This will return the ray of the finger's start position relative to the specified camera (none/null = Main Camera).



Vector2
GetSnapshotScreenDelta
float deltaTime

This will tell you how far the finger has moved in the past 'deltaTime' seconds.



Vector2
GetSnapshotScaledDelta
float deltaTime

This returns a resolution-independent 'GetSnapshotScreenDelta' value.



Vector2
GetSnapshotScreenPosition
float targetAge

This will return the recorded position of the current finger when it was at 'targetAge'.



Vector3
GetSnapshotWorldPosition
float targetAge, float distance, Camera camera = null

This will return the recorded world of the current finger when it was at 'targetAge'.



float
GetRadians
Vector2 referencePoint

This will return the angle between the finger and the reference point, relative to the screen.



float
GetDegrees
Vector2 referencePoint

This will return the angle between the finger and the reference point, relative to the screen.



float
GetLastRadians
Vector2 referencePoint

This will return the angle between the last finger position and the reference point, relative to the screen.



float
GetLastDegrees
Vector2 referencePoint

This will return the angle between the last finger position and the reference point, relative to the screen.



float
GetDeltaRadians
Vector2 referencePoint

This will return the delta angle between the last and current finger position relative to the reference point.



float
GetDeltaRadians
Vector2 referencePoint, Vector2 lastReferencePoint

This will return the delta angle between the last and current finger position relative to the reference point and the last reference point.



float
GetDeltaDegrees
Vector2 referencePoint

This will return the delta angle between the last and current finger position relative to the reference point.



float
GetDeltaDegrees
Vector2 referencePoint, Vector2 lastReferencePoint

This will return the delta angle between the last and current finger position relative to the reference point and the last reference point.



float
GetScreenDistance
Vector2 point

This will return the distance between the finger and the reference point.



float
GetScaledDistance
Vector2 point

This returns a resolution-independent 'GetScreenDistance' value.



float
GetLastScreenDistance
Vector2 point

This will return the distance between the last finger and the reference point.



float
GetLastScaledDistance
Vector2 point

This returns a resolution-independent 'GetLastScreenDistance' value.



float
GetStartScreenDistance
Vector2 point

This will return the distance between the start finger and the reference point.



float
GetStartScaledDistance
Vector2 point

This returns a resolution-independent 'GetStartScreenDistance' value.



Vector3
GetStartWorldPosition
float distance, Camera camera = null

This will return the start world position of this finger based on the distance from the camera.



Vector3
GetLastWorldPosition
float distance, Camera camera = null

This will return the last world position of this finger based on the distance from the camera.



Vector3
GetWorldPosition
float distance, Camera camera = null

This will return the world position of this finger based on the distance from the camera.



Vector3
GetWorldDelta
float distance, Camera camera = null

This will return the change in world position of this finger based on the distance from the camera.



Vector3
GetWorldDelta
float lastDistance, float distance, Camera camera = null

This will return the change in world position of this finger based on the last and current distance from the camera.



void
ClearSnapshots
int count = -1

This will clear all snapshots for this finger and pool them, count = -1 for all.



void
RecordSnapshot

Calling this will instantly store a snapshot of the current finger position.




LeanGesture

This class calculates gesture information (e.g. pinch) based on all fingers touching the screen, or a specified list of fingers.

NOTE  This isn't a component, so it can only be used directly from C#. Many example components make use of this class so you don't have to use code though.

static Vector2
GetScreenCenter

Gets the average ScreenPosition of all.



static Vector2
GetScreenCenter
List<LeanFinger> fingers

Gets the average ScreenPosition of the specified fingers.



static bool
TryGetScreenCenter
List<LeanFinger> fingers, ref Vector2 center

Gets the average ScreenPosition of the specified fingers, if at least one exists.



static Vector2
GetLastScreenCenter

Gets the last average ScreenPosition of all fingers.



static Vector2
GetLastScreenCenter
List<LeanFinger> fingers

Gets the last average ScreenPosition of the specified fingers.



static bool
TryGetLastScreenCenter
List<LeanFinger> fingers, ref Vector2 center

Gets the last average ScreenPosition of the specified fingers, if at least one exists.



static Vector2
GetStartScreenCenter

Gets the start average ScreenPosition of all fingers.



static Vector2
GetStartScreenCenter
List<LeanFinger> fingers

Gets the start average ScreenPosition of the specified fingers.



static bool
TryGetStartScreenCenter
List<LeanFinger> fingers, ref Vector2 center

Gets the start average ScreenPosition of the specified fingers, if at least one exists.



static Vector2
GetScreenDelta

Gets the average ScreenDelta of all fingers.



static Vector2
GetScreenDelta
List<LeanFinger> fingers

Gets the average ScreenDelta of the specified fingers.



static bool
TryGetScreenDelta
List<LeanFinger> fingers, ref Vector2 delta

Gets the average ScreenDelta of the specified fingers, if at least one exists.



static Vector2
GetScaledDelta

This returns a resolution-independent 'GetScreenDelta' value.



static Vector2
GetScaledDelta
List<LeanFinger> fingers

This returns a resolution-independent 'GetScreenDelta' value.



static bool
TryGetScaledDelta
List<LeanFinger> fingers, ref Vector2 delta

This returns a resolution-independent 'TryGetScreenDelta' value.



static Vector3
GetWorldDelta
float distance, Camera camera = null

Gets the average WorldDelta of all fingers.



static Vector3
GetWorldDelta
List<LeanFinger> fingers, float distance, Camera camera = null

Gets the average WorldDelta of the specified fingers.



static bool
TryGetWorldDelta
List<LeanFinger> fingers, float distance, ref Vector3 delta, Camera camera = null

Gets the average WorldDelta of the specified fingers, if at least one exists.



static float
GetScreenDistance

Gets the average ScreenPosition distance between the fingers.



static float
GetScreenDistance
List<LeanFinger> fingers

Gets the average ScreenPosition distance between the fingers.



static float
GetScreenDistance
List<LeanFinger> fingers, Vector2 center

Gets the average ScreenPosition distance between the fingers.



static bool
TryGetScreenDistance
List<LeanFinger> fingers, Vector2 center, ref float distance

Gets the average ScreenPosition distance between the fingers.



static float
GetScaledDistance

Gets the average ScreenPosition distance * LeanTouch.ScalingFactor between the fingers.



static float
GetScaledDistance
List<LeanFinger> fingers

Gets the average ScreenPosition distance * LeanTouch.ScalingFactor between the fingers.



static float
GetScaledDistance
List<LeanFinger> fingers, Vector2 center

Gets the average ScreenPosition distance * LeanTouch.ScalingFactor between the fingers.



static bool
TryGetScaledDistance
List<LeanFinger> fingers, Vector2 center, ref float distance

Gets the average ScreenPosition distance * LeanTouch.ScalingFactor between the fingers.



static float
GetLastScreenDistance

Gets the last average ScreenPosition distance between all fingers.



static float
GetLastScreenDistance
List<LeanFinger> fingers

Gets the last average ScreenPosition distance between all fingers.



static float
GetLastScreenDistance
List<LeanFinger> fingers, Vector2 center

Gets the last average ScreenPosition distance between all fingers.



static bool
TryGetLastScreenDistance
List<LeanFinger> fingers, Vector2 center, ref float distance

Gets the last average ScreenPosition distance between all fingers.



static float
GetLastScaledDistance

Gets the last average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.



static float
GetLastScaledDistance
List<LeanFinger> fingers

Gets the last average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.



static float
GetLastScaledDistance
List<LeanFinger> fingers, Vector2 center

Gets the last average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.



static bool
TryGetLastScaledDistance
List<LeanFinger> fingers, Vector2 center, ref float distance

Gets the last average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.



static float
GetStartScreenDistance

Gets the start average ScreenPosition distance between all fingers.



static float
GetStartScreenDistance
List<LeanFinger> fingers

Gets the start average ScreenPosition distance between all fingers.



static float
GetStartScreenDistance
List<LeanFinger> fingers, Vector2 center

Gets the start average ScreenPosition distance between all fingers.



static bool
TryGetStartScreenDistance
List<LeanFinger> fingers, Vector2 center, ref float distance

Gets the start average ScreenPosition distance between all fingers.



static float
GetStartScaledDistance

Gets the start average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.



static float
GetStartScaledDistance
List<LeanFinger> fingers

Gets the start average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.



static float
GetStartScaledDistance
List<LeanFinger> fingers, Vector2 center

Gets the start average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.



static bool
TryGetStartScaledDistance
List<LeanFinger> fingers, Vector2 center, ref float distance

Gets the start average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.



static float
GetPinchScale
float wheelSensitivity = 0.0f

Gets the pinch scale of the fingers.



static float
GetPinchScale
List<LeanFinger> fingers, float wheelSensitivity = 0.0f

Gets the pinch scale of the fingers.



static bool
TryGetPinchScale
List<LeanFinger> fingers, Vector2 center, Vector2 lastCenter, ref float scale, float wheelSensitivity = 0.0f

Gets the pinch scale of the fingers.



static float
GetPinchRatio
float wheelSensitivity = 0.0f

Gets the pinch ratio of the fingers (reciprocal of pinch scale).



static float
GetPinchRatio
List<LeanFinger> fingers, float wheelSensitivity = 0.0f

Gets the pinch ratio of the fingers (reciprocal of pinch scale).



static bool
TryGetPinchRatio
List<LeanFinger> fingers, Vector2 center, Vector2 lastCenter, ref float ratio, float wheelSensitivity = 0.0f

Gets the pinch ratio of the fingers (reciprocal of pinch scale).



static float
GetTwistDegrees

Gets the average twist of the fingers in degrees.



static float
GetTwistDegrees
List<LeanFinger> fingers

Gets the average twist of the fingers in degrees.



static float
GetTwistDegrees
List<LeanFinger> fingers, Vector2 center, Vector2 lastCenter

Gets the average twist of the fingers in degrees.



static bool
TryGetTwistDegrees
List<LeanFinger> fingers, Vector2 center, Vector2 lastCenter, ref float degrees

Gets the average twist of the fingers in degrees.



static float
GetTwistRadians

Gets the average twist of the fingers in radians.



static float
GetTwistRadians
List<LeanFinger> fingers

Gets the average twist of the fingers in radians.



static float
GetTwistRadians
List<LeanFinger> fingers, Vector2 center, Vector2 lastCenter

Gets the average twist of the fingers in radians.



static bool
TryGetTwistRadians
List<LeanFinger> fingers, Vector2 center, Vector2 lastCenter, ref float radians

Gets the average twist of the fingers in radians.




LeanSnapshot

This class stores a snapshot of where a finger was at a specific point in time, and provides methods to look back in time to find a point based on a time.


float
Age

The age of the finger when this snapshot was created.



Vector2
ScreenPosition

The screen position of the finger when this snapshot was created.



Vector3
GetWorldPosition
float distance, Camera camera = null

This will return the world position of this snapshot based on the distance from the camera.



static LeanSnapshot
Pop

Return the last inactive snapshot, or allocate a new one.



static bool
TryGetScreenPosition
List<LeanSnapshot> snapshots, float targetAge, ref Vector2 screenPosition

This will return the recorded position of the current finger when it was at 'targetAge'.



static bool
TryGetSnapshot
List<LeanSnapshot> snapshots, int index, ref float age, ref Vector2 screenPosition

This will return snapshot information at the specified index, if it exists.

NOTE  This assumes snapshots does not contain any null elements.


static int
GetLowerIndex
List<LeanSnapshot> snapshots, float targetAge

This will get the index of the closest snapshot whose age is under targetAge

NOTE  This assumes snapshots does not contain any null elements.



LeanTouch

If you add this component to your scene, then it will convert all mouse and touch data into easy to use data.

You can access this data via Lean.Touch.LeanTouch.Instance.Fingers, or hook into the Lean.Touch.LeanTouch.On___ events.

NOTE  If you experience a one frame input delay you should edit your ScriptExecutionOrder to force this script to update before your other scripts.

static List<LeanTouch>
Instances

This contains all the active and enabled LeanTouch instances



static List<LeanFinger>
Fingers

This list contains all fingers currently touching the screen (or have just stopped touching the screen).

NOTE  This list includes simulated fingers, as well as the mouse hover finger.


static List<LeanFinger>
InactiveFingers

This list contains all fingers that were once touching the screen. This is used to manage finger tapping, as well as 'inactive' fingers that are so old they're no longer eligible for tapping.



static event System.Action<LeanFinger>
OnFingerDown

This gets fired when a finger begins touching the screen (LeanFinger = The current finger)



static event System.Action<LeanFinger>
OnFingerUpdate

This gets fired every frame a finger is touching the screen (LeanFinger = The current finger)



static event System.Action<LeanFinger>
OnFingerUp

This gets fired when a finger stops touching the screen (LeanFinger = The current finger)



static event System.Action<LeanFinger>
OnFingerOld

This gets fired when a finger has been touching the screen for longer than TapThreshold seconds, causing it to be ineligible for the tap and swipe events.



static event System.Action<LeanFinger>
OnFingerTap

This gets fired when a finger taps the screen (this is when a finger begins and stops touching the screen within the 'TapThreshold' time).



static event System.Action<LeanFinger>
OnFingerSwipe

This gets fired when a finger swipes the screen (this is when a finger begins and stops touching the screen within the 'TapThreshold' time, and also moves more than the 'SwipeThreshold' distance) (LeanFinger = The current finger)



static event System.Action<List<LeanFinger>>
OnGesture

This gets fired every frame at least one finger is touching the screen (List = Fingers).



static event System.Action<LeanFinger>
OnFingerExpired

This gets fired after a finger has been touching the screen for longer than TapThreshold seconds, making it ineligible for a swipe.



static event System.Action<LeanFinger>
OnFingerInactive

This gets fired the frame after a finger went up,



event System.Action
OnSimulateFingers

This will be invoked when it's time to simulate fingers. You can call the AddFinger method to simulate them.



float
TapThreshold

This allows you to set how many seconds are required between a finger down/up for a tap to be registered.



float
SwipeThreshold

This allows you to set how many pixels of movement (relative to the ReferenceDpi) are required within the TapThreshold for a swipe to be triggered.



float
ReclaimThreshold

This allows you to set how many pixels (relative to the ReferenceDpi) away from a previous finger the new touching finger must be for it to be reclaimed. This is useful on platforms that give incorrect finger ID data.



int
ReferenceDpi

This allows you to set the default DPI you want the input scaling to be based on.



LayerMask
GuiLayers

This allows you to set which layers your GUI is on, so it can be ignored by each finger.



bool
UseTouch

If you disable this then lean touch will act as if you stopped touching the screen.



bool
UseHover

Should the mouse hover position be stored as a finger?

NOTE  It will be given a finger Index of HOVER_FINGER_INDEX = -42.


bool
UseMouse

Should any mouse button press be stored as a finger?

NOTE  It will be given a finger Index of MOUSE_FINGER_INDEX = -1.


bool
UseSimulator

Should components hooked into the OnSimulateFingers event be used? (e.g. LeanTouchSimulator)



bool
RecordFingers

Should each finger record snapshots of their screen positions?



float
RecordThreshold

This allows you to set the amount of pixels a finger must move for another snapshot to be stored.



float
RecordLimit

This allows you to set the maximum amount of seconds that can be recorded, 0 = unlimited.



static LeanTouch
Instance

The first active and enabled LeanTouch instance.



static float
ScalingFactor

If you multiply this value with any other pixel delta (e.g. ScreenDelta), then it will become device resolution independent relative to the device DPI.



static float
ScreenFactor

If you multiply this value with any other pixel delta (e.g. ScreenDelta), then it will become device resolution independent relative to the screen pixel size.



static bool
GuiInUse

This will return true if the mouse or any finger is currently using the GUI.



static bool
PointOverGui
Vector2 screenPosition

This will return true if the specified screen point is over any GUI elements.



static List<RaycastResult>
RaycastGui
Vector2 screenPosition

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

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


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.


static List<LeanFinger>
GetFingers
bool ignoreIfStartedOverGui, bool ignoreIfOverGui, int requiredFingerCount = 0, bool ignoreHoverFinger = true

This allows you to filter all the fingers based on the specified requirements.

NOTE  If ignoreGuiFingers is set, Fingers will be filtered to remove any with StartedOverGui.
NOTE  If requiredFingerCount is greater than 0, this method will return null if the finger count doesn't match.
NOTE  If requiredSelectable is set, and its SelectingFinger isn't null, it will return just that finger.


static void
SimulateTap
Vector2 screenPosition, float pressure = 1.0f, int tapCount = 1

This allows you to simulate a tap on the screen at the specified location.



void
Clear

You can call this method if you want to stop all finger events. You can then disable this component to prevent new ones from updating.




LeanDragCamera

This component allows you to move the current GameObject (e.g. Camera) based on finger drags and the specified ScreenDepth.


LeanFingerFilter
Use

The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.



LeanScreenDepth
ScreenDepth

The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.



float
Sensitivity

The movement speed will be multiplied by this.

-1 = Inverted Controls.



float
Damping

If you want this component to change smoothly over time, then this allows you to control how quick the changes reach their target value.

-1 = Instantly change.

1 = Slowly change.

10 = Quickly change.



float
Inertia

This allows you to control how much momentum is retained when the dragging fingers are all released.

NOTE  This requires Damping to be above 0.


void
MoveToSelection

This method moves the current GameObject to the center point of all selected objects.



void
AddFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.



void
RemoveFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.



void
RemoveAllFingers

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.




LeanDragTrail

This component draws trails behind fingers.

NOTE  This requires you to enable the LeanTouch.RecordFingers setting.

LeanFingerFilter
Use

The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.



LeanScreenDepth
ScreenDepth

The method used to convert between screen coordinates, and world coordinates.



LineRenderer
Prefab

The line prefab that will be used to render the trails.



int
MaxTrails

The maximum amount of active trails.

-1 = Unlimited.



float
FadeTime

How many seconds it takes for each trail to disappear after a finger is released.



Color
StartColor

The color of the trail start.



Color
EndColor

The color of the trail end.



void
AddFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.



void
RemoveFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.



void
RemoveAllFingers

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.




LeanDragTranslate

This component allows you to translate the current GameObject relative to the camera using the finger drag gesture.


LeanFingerFilter
Use

The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.



Camera
Camera

The camera the translation will be calculated using.

None/null = MainCamera.



float
Sensitivity

The movement speed will be multiplied by this.

-1 = Inverted Controls.



float
Damping

If you want this component to change smoothly over time, then this allows you to control how quick the changes reach their target value.

-1 = Instantly change.

1 = Slowly change.

10 = Quickly change.



float
Inertia

This allows you to control how much momentum is retained when the dragging fingers are all released.

NOTE  This requires Dampening to be above 0.


void
AddFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.



void
RemoveFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.



void
RemoveAllFingers

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.




LeanFingerData

This base class can be used to associate extra data with the specified LeanFinger instance.



LeanFingerDown

This component invokes events when a finger touches the screen that satisfies the specified conditions.


bool
IgnoreStartedOverGui

Ignore fingers with StartedOverGui?



LeanSelectable
RequiredSelectable

If the specified object is set and isn't selected, then this component will do nothing.



LeanFingerEvent
OnFinger

This event will be called if the above conditions are met when your finger begins touching the screen.



LeanScreenDepth
ScreenDepth

The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.



Vector3Event
OnWorld

This event will be called if the above conditions are met when your finger begins touching the screen.

Vector3 = Start point based on the ScreenDepth settings.



Vector2Event
OnScreen

This event will be called if the above conditions are met when your finger begins touching the screen.

Vector2 = Finger position in screen space.




LeanFingerFilter

This class manages a list of fingers, and can return a filtered version of them based on the criteria you specify. This allows you to quickly implement complex controls involving multiple fingers.

By default, all fingers seen by LeanTouch are used by this class, but you can set Filter to ManuallyAddedFingers, and you can manually call the AddFinger method to add them yourself.

NOTE  If you use this class then you must call the UpdateAndGetFingers method every frame/Update to update the class state. This is required because this update method will remove fingers that went up. If you don't call this then they will remain, and this may lead to unexpected behavior.

FilterType
Filter

The method used to find fingers to use with this component.

ManuallyAddedFingers = You must manually call the AddFinger function (e.g. from a UI button).



bool
IgnoreStartedOverGui

Ignore fingers that began touching the screen on top of a GUI element?



int
RequiredFingerCount

If the amount of fingers doesn't match this number, ignore all fingers?

0 = Any amount.



int
RequiredMouseButtons

When using simulated fingers, should a specific combination of mouse buttons be held?

0 = Any.

1 = Left.

2 = Right.

3 = Left + Right.

4 = Middle.

5 = Left + Middle.

6 = Right + Middle.

7 = Left + Right + Middle.



LeanSelectable
RequiredSelectable

If the specified RequiredSelectable component's IsSelected setting is false, ignore all fingers?



void
UpdateRequiredSelectable
GameObject gameObject

If the current RequiredSelectable is null, this method allows you to try and set it based on the specified GameObject.



void
AddFinger
LeanFinger finger

If you've set Filter to ManuallyAddedFingers, then you can call this method to manually add a finger.



void
RemoveFinger
LeanFinger finger

If you've set Filter to ManuallyAddedFingers, then you can call this method to manually remove a finger.



void
RemoveAllFingers

If you've set Filter to ManuallyAddedFingers, then you can call this method to manually remove all fingers.



List<LeanFinger>
UpdateAndGetFingers
bool ignoreUpFingers = false

This method returns a list of all fingers based on the current settings.

NOTE  This method must be called every frame/Update.



LeanFingerOld

This component fires events on the first frame where a finger has been touching the screen for more than TapThreshold seconds, and is therefore no longer eligible for tap or swipe events.


bool
IgnoreStartedOverGui

Ignore fingers with StartedOverGui?



bool
IgnoreIsOverGui

Ignore fingers with OverGui?



LeanSelectable
RequiredSelectable

If the specified object is set and isn't selected, then this component will do nothing.



LeanFingerEvent
OnFinger

This event will be called if the above conditions are met when your finger becomes old.



LeanScreenDepth
ScreenDepth

The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.



Vector3Event
OnWorld

This event will be called if the above conditions are met when your finger becomes old.

Vector3 = Finger position in world space.



Vector2Event
OnScreen

This event will be called if the above conditions are met when your finger becomes old.

Vector2 = Finger position in screen space.




LeanFingerSwipe

This component fires events if a finger has swiped across the screen.

A swipe is defined as a touch that began and ended within the LeanTouch.TapThreshold time, and moved more than the LeanTouch.SwipeThreshold distance.


bool
IgnoreStartedOverGui

Ignore fingers with StartedOverGui?



bool
IgnoreIsOverGui

Ignore fingers with OverGui?



LeanSelectable
RequiredSelectable

If the specified object is set and isn't selected, then this component will do nothing.




LeanFingerTap

This component calls the OnFingerTap event when a finger taps the screen.


bool
IgnoreStartedOverGui

Ignore fingers with StartedOverGui?



bool
IgnoreIsOverGui

Ignore fingers with OverGui?



LeanSelectable
RequiredSelectable

If the specified object is set and isn't selected, then this component will do nothing.



int
RequiredTapCount

How many times must this finger tap before OnTap gets called?

0 = Every time (keep in mind OnTap will only be called once if you use this).



int
RequiredTapInterval

How many times repeating must this finger tap before OnTap gets called?

0 = Every time (e.g. a setting of 2 means OnTap will get called when you tap 2 times, 4 times, 6, 8, 10, etc).



LeanFingerEvent
OnFinger

This event will be called if the above conditions are met when you tap the screen.



IntEvent
OnCount

This event will be called if the above conditions are met when you tap the screen.

Int = The finger tap count.



LeanScreenDepth
ScreenDepth

The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.



Vector3Event
OnWorld

This event will be called if the above conditions are met when you tap the screen.

Vector3 = Finger position in world space.



Vector2Event
OnScreen

This event will be called if the above conditions are met when you tap the screen.

Vector2 = Finger position in screen space.




LeanFingerUp

This component calls the OnUp event when a finger stops touching the screen.


bool
IgnoreStartedOverGui

Ignore fingers with StartedOverGui?



bool
IgnoreIsOverGui

Ignore fingers with OverGui?



LeanSelectable
RequiredSelectable

If the specified object is set and isn't selected, then this component will do nothing.



LeanFingerEvent
OnFinger

This event will be called if the above conditions are met when your finger stops touching the screen.



LeanScreenDepth
ScreenDepth

The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.



Vector3Event
OnWorld

This event will be called if the above conditions are met when your finger stops touching the screen.

Vector3 = Finger position in world space.



Vector2Event
OnScreen

This event will be called if the above conditions are met when your finger stops touching the screen.

Vector2 = Finger position in screen space.




LeanFingerUpdate

This component allows you to detect when a finger is touching the screen.


bool
IgnoreStartedOverGui

Ignore fingers with StartedOverGui?



bool
IgnoreIsOverGui

Ignore fingers with OverGui?



bool
IgnoreIfStatic

If the finger didn't move, ignore it?



bool
IgnoreIfDown

If the finger just began touching the screen, ignore it?



bool
IgnoreIfUp

If the finger just stopped touching the screen, ignore it?



bool
IgnoreIfHover

If the finger is the mouse hover, ignore it?



LeanSelectable
RequiredSelectable

If the specified object is set and isn't selected, then this component will do nothing.



LeanFingerEvent
OnFinger

Called on every frame the conditions are met.



CoordinateType
Coordinate

The coordinate space of the OnDelta values.



float
Multiplier

The delta values will be multiplied by this when output.



Vector2Event
OnDelta

This event is invoked when the requirements are met.

Vector2 = Position Delta based on your Coordinates setting.



FloatEvent
OnDistance

Called on the first frame the conditions are met.

Float = The distance/magnitude/length of the swipe delta vector.



LeanScreenDepth
ScreenDepth

The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.



Vector3Event
OnWorldFrom

Called on the first frame the conditions are met.

Vector3 = Start point in world space.



Vector3Event
OnWorldTo

Called on the first frame the conditions are met.

Vector3 = End point in world space.



Vector3Event
OnWorldDelta

Called on the first frame the conditions are met.

Vector3 = The vector between the start and end points in world space.



Vector3Vector3Event
OnWorldFromTo

Called on the first frame the conditions are met.

Vector3 = Start point in world space.

Vector3 = End point in world space.




LeanPinchScale

This component allows you to scale the current GameObject relative to the specified camera using the pinch gesture.


LeanFingerFilter
Use

The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.



Camera
Camera

The camera that will be used to calculate the zoom.

None/null = MainCamera.



bool
Relative

Should the scaling be performed relative to the finger center?



float
Sensitivity

The sensitivity of the scaling.

1 = Default.

2 = Double.



float
Damping

If you want this component to change smoothly over time, then this allows you to control how quick the changes reach their target value.

-1 = Instantly change.

1 = Slowly change.

10 = Quickly change.



void
AddFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.



void
RemoveFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.



void
RemoveAllFingers

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.




LeanScreenDepth

This struct handles the conversion between screen coordinates, and world coordinates.

This conversion is required for many touch interactions, and there are numerous ways it can be performed.


ConversionType
Conversion

The method used to convert between screen coordinates, and world coordinates.

FixedDistance = A point will be projected out from the camera.

DepthIntercept = A point will be intercepted out from the camera on a surface lying flat on the XY plane.

PhysicsRaycast = A ray will be cast from the camera.

PathClosest = A point will be intercepted out from the camera to the closest point on the specified path.

AutoDistance = A point will be projected out from the camera based on the current Transform depth.

HeightIntercept = A point will be intercepted out from the camera on a surface lying flat on the XZ plane.



Camera
Camera

The camera the depth calculations will be done using.

None = MainCamera.



Object
Object

The plane/path/etc that will be intercepted.



LayerMask
Layers

The layers used in the raycast.



float
Distance

Tooltips are modified at runtime based on Conversion setting.



static Vector3
LastWorldNormal

When performing a ScreenDepth conversion, the converted point can have a normal associated with it. This stores that.




LeanScreenQuery

This struct stores information about and allows you to search the scene for a specific object on screen space.


MethodType
Method

The method used to search the scene based on a screen position.

Raycast = 3D, 2D, and EventSystem raycast.



LayerMask
Layers

The scene will be queried (e.g. Raycast) against these layers.



SearchType
Search

When the query hits a GameObject, how should the desired component be searched for relative to it?



string
RequiredTag

The component found from the search must have this tag.



Camera
Camera

The camera used to perform the search.

None = MainCamera.




LeanSelectableByFinger

This component makes this GameObject selectable.

If your game is 3D then make sure this GameObject or a child has a Collider component.

If your game is 2D then make sure this GameObject or a child has a Collider2D component.

If your game is UI based then make sure this GameObject or a child has a graphic with "Raycast Target" enabled.

To then select it, you can add the LeanSelect and LeanFingerTap components to your scene. You can then link up the LeanFingerTap.OnTap event to LeanSelect.SelectScreenPosition.


UseType
Use

This allows you to control which fingers will be used by components that require this selectable.



LeanFingerEvent
OnSelectedFinger

This event is called when selection begins (finger = the finger that selected this).



LeanFingerEvent
OnSelectedFingerUp

This event is called when selection begins (finger = the finger that selected this).



LeanFinger
SelectingFinger

This tells you the first or earliest still active finger that initiated selection of this object.

NOTE  If the selecting finger went up then this may return null.


List<LeanFinger>
SelectingFingers

This tells you every currently active finger that selected this object.



static List<LeanFinger>
GetFingers
bool ignoreIfStartedOverGui, bool ignoreIfOverGui, int requiredFingerCount = 0, LeanSelectable requiredSelectable = null

If requiredSelectable is set and not selected, the fingers list will be empty. If selected then the fingers list will only contain the selecting finger.



static LeanSelectableByFinger
FindSelectable
LeanFinger finger

If the specified finger selected an object, this will return the first one.



bool
IsSelectedBy
LeanFinger finger

This tells you if the current selectable was selected by the specified finger.




LeanSelectableByFingerBehaviour

This is the base class for all components that need to implement some kind of special logic when selected. You can do this manually without this class, but this makes it much easier.

NOTE  This component will register and unregister the associated LeanSelectable in OnEnable and OnDisable.

LeanSelectableByFinger
Selectable

This tells you which LeanSelectable is currently associated with this component.



void
Register

This method allows you to manually register the LeanSelectable this component is associated with. This is useful if you're manually spawning and attaching children from code.



void
Register
LeanSelectableByFinger newSelectable

This method allows you to manually register the LeanSelectable this component is associated with.



void
Unregister

This method allows you to manually register the LeanSelectable this component is associated with. This is useful if you're changing the associated LeanSelectable.




LeanSelectByFinger

This component allows you to select LeanSelectable components.

To use it, you can call the SelectScreenPosition method from somewhere (e.g. the LeanFingerTap.OnTap event).


bool
DeselectWithFingers

If you enable this then any selected object will automatically be deselected if the finger used to select it is no longer touching the screen.



LeanSelectableLeanFingerEvent
OnSelectedFinger

This is invoked when an object is selected.



void
SelectStartScreenPosition
LeanFinger finger

This method allows you to initiate selection at the finger's StartScreenPosition.

NOTE  This method be called from somewhere for this component to work (e.g. LeanFingerTap).


void
SelectScreenPosition
LeanFinger finger

This method allows you to initiate selection at the finger's current ScreenPosition.

NOTE  This method be called from somewhere for this component to work (e.g. LeanFingerTap).


void
SelectScreenPosition
LeanFinger finger, Vector2 screenPosition

This method allows you to initiate selection of a finger at a custom screen position.

NOTE  This method be called from a custom script for this component to work.


void
Select
LeanSelectable selectable, LeanFinger finger

This method allows you to manually select an object with the specified finger using this component's selection settings.



void
ReplaceSelection
List<LeanSelectable> newSelectables, LeanFinger finger

This allows you to replace the currently selected objects with the ones in the specified list. This is useful if you're doing box selection or switching selection groups.




LeanSwipeBase

This is the base class for all swiping actions.


float
RequiredAngle

The required angle of the swipe in degrees.

0 = Up.

90 = Right.

180 = Down.

270 = Left.



float
RequiredArc

The angle of the arc in degrees that the swipe must be inside.

-1 = No requirement.

90 = Quarter circle (+- 45 degrees).

180 = Semicircle (+- 90 degrees).



LeanFingerEvent
OnFinger

Called on the first frame the conditions are met.



ModifyType
Modify

Should the swipe delta be modified before use?

Normalize = The swipe delta magnitude/length will be set to 1.

Normalize4 = The swipe delta will be + or - 1 on either the x or y axis.



CoordinateType
Coordinate

The coordinate space of the OnDelta values.



float
Multiplier

The swipe delta will be multiplied by this value.



Vector2Event
OnDelta

Called on the first frame the conditions are met.

Vector2 = The scaled swipe delta.



FloatEvent
OnDistance

Called on the first frame the conditions are met.

Float = The distance/magnitude/length of the swipe delta vector.



LeanScreenDepth
ScreenDepth

The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.



Vector3Event
OnWorldFrom

Called on the first frame the conditions are met.

Vector3 = Start point in world space.



Vector3Event
OnWorldTo

Called on the first frame the conditions are met.

Vector3 = End point in world space.



Vector3Event
OnWorldDelta

Called on the first frame the conditions are met.

Vector3 = The vector between the start and end points in world space.



Vector3Vector3Event
OnWorldFromTo

Called on the first frame the conditions are met.

Vector3 = Start point in world space.

Vector3 = End point in world space.




LeanTouchSimulator

This component can be added alongside the LeanTouch component to add simulated multi touch controls using the mouse and keyboard.


KeyCode
PinchTwistKey

This allows you to set which key is required to simulate multi key twisting.



KeyCode
MovePivotKey

This allows you to set which key is required to change the pivot point of the pinch twist gesture.



KeyCode
MultiDragKey

This allows you to set which key is required to simulate multi key dragging.



Texture2D
FingerTexture

This allows you to set which texture will be used to show the simulated fingers.




LeanTwistRotate

This component allows you to transform the current GameObject relative to the specified camera using a twist gesture.


LeanFingerFilter
Use

The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.



Camera
Camera

The camera we will be used to calculate relative rotations.

None/null = MainCamera.



bool
Relative

Should the rotation be performed relative to the finger center?



float
Damping

If you want this component to change smoothly over time, then this allows you to control how quick the changes reach their target value.

-1 = Instantly change.

1 = Slowly change.

10 = Quickly change.



void
AddFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.



void
RemoveFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.



void
RemoveAllFingers

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.




LeanTwistRotateAxis

This component allows you to rotate the current GameObject around the specified axis using finger twists.


LeanFingerFilter
Use

The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.



Vector3
Axis

The axis of rotation.



Space
Space

Rotate locally or globally?



float
Sensitivity

The sensitivity of the rotation.

1 = Default.

2 = Double.



void
AddFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.



void
RemoveFinger
LeanFinger finger

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.



void
RemoveAllFingers

If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.




LeanPulseScale

This component will pulse the transform.localScale value over time.


Vector3
BaseScale

The default scale.



float
Size

The current scale multiplier.



float
PulseInterval

The interval between each pulse in seconds.



float
PulseSize

The amount Size will be incremented each pulse.



float
Damping

If you want this component to change smoothly over time, then this allows you to control how quick the changes reach their target value.

-1 = Instantly change.

1 = Slowly change.

10 = Quickly change.




LeanTouchEvents

This component will hook into every LeanTouch event, and spam the console with the information.



Index

How do I get started?

How do I use Lean Touch without code?

How do I use Lean Touch with C#?

How do I handle multi-finger gestures (e.g. Pinch, Twist) from C#?

Why are my inputs delayed by one frame?

How do I stop my touch controls from going through my UI from C#?

Why do I have to keep typing Lean.Touch. before everything?

What is Lean Touch+?

Can I request a new demo scene?

How does the Screen Depth inspector setting work?

Why do I have to link up so many components?

Why do all my objects move at the same time?



Assets

Lean GUI

Lean Transition

Paint in 3D

Lean Pool

Space Graphics Toolkit

Lean Touch

Lean Localization

Lean GUI Shapes

Destructible 2D

Planet Pack - Space Graphics Toolkit

Lean Touch+

Volumetric Audio



Versions

2.2.0

2.1.8

2.1.7

2.1.6

2.1.5

2.1.4

2.1.3

2.1.2

2.1.1

2.1.0

2.0.9

2.0.8

2.0.7

2.0.6

2.0.5

2.0.4

2.0.3

2.0.2

2.0.1

2.0.0



Components

LeanFinger

LeanGesture

LeanSnapshot

LeanTouch

LeanDragCamera

LeanDragTrail

LeanDragTranslate

LeanFingerData

LeanFingerDown

LeanFingerFilter

LeanFingerOld

LeanFingerSwipe

LeanFingerTap

LeanFingerUp

LeanFingerUpdate

LeanPinchScale

LeanScreenDepth

LeanScreenQuery

LeanSelectableByFinger

LeanSelectableByFingerBehaviour

LeanSelectByFinger

LeanSwipeBase

LeanTouchSimulator

LeanTwistRotate

LeanTwistRotateAxis

LeanPulseScale

LeanTouchEvents