First you need to add the LeanTouch component to your scene:
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).
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.
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.
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.
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.
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.
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!");
}
}
}
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.
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+
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.
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.
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.
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 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.
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 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!
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.
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.
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 is a localization library that's designed to be as simple to use as possible for both designers, and programmers.
Lean GUI Shapes allows you to quickly add lines, rounded boxes, polygons, and much more to your GUI!
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!
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+ is an extension to the popular Lean Touch asset, adding many more example scenes.
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.
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.
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.
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.
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.
Improved LeanDragCamera.Inertia implementation.
Added LeanDragTranslate.Inertia setting.
Fixed LeanSelect Raycast order.
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.
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.
Fixed LeanTouch.OnFingerUp not being called in some scenarios.
Renamed TapSpawnCount demo scene to TapSpawnDouble.
Fixed LeanDragTranslate when using screen space UI.
Fixed LeanPinchScale when using screen space UI.
Fixed LeanTwistRotate when using screen space UI.
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.
Added LeanFinger.OnFingerOld event.
Added LeanFingerOld component.
Added FingerOld demo scene.
Moved LeanFingerHeld to LeanTouch+.
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.
This class stores information about a single touch (or simulated touch).
This is the hardware ID of the finger.
This tells you how long this finger has been active (or inactive) in seconds.
Is this finger currently touching the screen?
This tells you the 'Set' value of the last frame.
Did this finger just tap the screen?
This tells you how many times this finger has been tapped.
Did this finger just swipe the screen?
If this finger has been touching the screen for more than TapThreshold, this will be true.
If this finger has been inactive for more than TapThreshold, this will be true.
This tells you the Pressure value last frame.
This tells you the current pressure of this finger (NOTE: only some devices support this).
This tells you the 'ScreenPosition' value of this finger when it began touching the screen.
This tells you the last screen position of the finger.
This tells you the current screen position of the finger in pixels, where 0,0 = bottom left.
This tells you if the current finger had 'IsOverGui' set to true when it began touching the screen.
Used to store position snapshots, enable RecordFingers in LeanTouch to use this.
This will return true if this finger is currently touching the screen.
This will tell you how many seconds of snapshot footage is stored for this finger.
This will return true if the current finger is over any Unity GUI elements.
Did this finger begin touching the screen this frame?
Did the finger stop touching the screen this frame?
This will return how far in pixels the finger has moved since the last recorded snapshot.
This returns a resolution-independent 'LastSnapshotScreenDelta' value.
This will return how far in pixels the finger has moved since the last frame.
This returns a resolution-independent 'ScreenDelta' value.
This tells you how far this finger has moved since it began touching the screen.
This returns a resolution-independent 'SwipeScreenDelta' value.
This returns the screen space distance between the 0 and 1 smooth screen positions.
This returns a smooth point between the previous and current screen position based on a 0..1 progress value.
This will return the ray of the finger's current position relative to the specified camera (none/null = Main Camera).
This will return the ray of the finger's start position relative to the specified camera (none/null = Main Camera).
This will tell you how far the finger has moved in the past 'deltaTime' seconds.
This returns a resolution-independent 'GetSnapshotScreenDelta' value.
This will return the recorded position of the current finger when it was at 'targetAge'.
This will return the recorded world of the current finger when it was at 'targetAge'.
This will return the angle between the finger and the reference point, relative to the screen.
This will return the angle between the finger and the reference point, relative to the screen.
This will return the angle between the last finger position and the reference point, relative to the screen.
This will return the angle between the last finger position and the reference point, relative to the screen.
This will return the delta angle between the last and current finger position relative to the reference point.
This will return the delta angle between the last and current finger position relative to the reference point and the last reference point.
This will return the delta angle between the last and current finger position relative to the reference point.
This will return the delta angle between the last and current finger position relative to the reference point and the last reference point.
This will return the distance between the finger and the reference point.
This returns a resolution-independent 'GetScreenDistance' value.
This will return the distance between the last finger and the reference point.
This returns a resolution-independent 'GetLastScreenDistance' value.
This will return the distance between the start finger and the reference point.
This returns a resolution-independent 'GetStartScreenDistance' value.
This will return the start world position of this finger based on the distance from the camera.
This will return the last world position of this finger based on the distance from the camera.
This will return the world position of this finger based on the distance from the camera.
This will return the change in world position of this finger based on the distance from the camera.
This will return the change in world position of this finger based on the last and current distance from the camera.
This will clear all snapshots for this finger and pool them, count = -1 for all.
Calling this will instantly store a snapshot of the current finger position.
This class calculates gesture information (e.g. pinch) based on all fingers touching the screen, or a specified list of fingers.
Gets the average ScreenPosition of all.
Gets the average ScreenPosition of the specified fingers.
Gets the average ScreenPosition of the specified fingers, if at least one exists.
Gets the last average ScreenPosition of all fingers.
Gets the last average ScreenPosition of the specified fingers.
Gets the last average ScreenPosition of the specified fingers, if at least one exists.
Gets the start average ScreenPosition of all fingers.
Gets the start average ScreenPosition of the specified fingers.
Gets the start average ScreenPosition of the specified fingers, if at least one exists.
Gets the average ScreenDelta of all fingers.
Gets the average ScreenDelta of the specified fingers.
Gets the average ScreenDelta of the specified fingers, if at least one exists.
This returns a resolution-independent 'GetScreenDelta' value.
This returns a resolution-independent 'GetScreenDelta' value.
This returns a resolution-independent 'TryGetScreenDelta' value.
Gets the average WorldDelta of all fingers.
Gets the average WorldDelta of the specified fingers.
Gets the average WorldDelta of the specified fingers, if at least one exists.
Gets the average ScreenPosition distance between the fingers.
Gets the average ScreenPosition distance between the fingers.
Gets the average ScreenPosition distance between the fingers.
Gets the average ScreenPosition distance between the fingers.
Gets the average ScreenPosition distance * LeanTouch.ScalingFactor between the fingers.
Gets the average ScreenPosition distance * LeanTouch.ScalingFactor between the fingers.
Gets the average ScreenPosition distance * LeanTouch.ScalingFactor between the fingers.
Gets the average ScreenPosition distance * LeanTouch.ScalingFactor between the fingers.
Gets the last average ScreenPosition distance between all fingers.
Gets the last average ScreenPosition distance between all fingers.
Gets the last average ScreenPosition distance between all fingers.
Gets the last average ScreenPosition distance between all fingers.
Gets the last average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.
Gets the last average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.
Gets the last average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.
Gets the last average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.
Gets the start average ScreenPosition distance between all fingers.
Gets the start average ScreenPosition distance between all fingers.
Gets the start average ScreenPosition distance between all fingers.
Gets the start average ScreenPosition distance between all fingers.
Gets the start average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.
Gets the start average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.
Gets the start average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.
Gets the start average ScreenPosition distance * LeanTouch.ScalingFactor between all fingers.
Gets the pinch scale of the fingers.
Gets the pinch scale of the fingers.
Gets the pinch scale of the fingers.
Gets the pinch ratio of the fingers (reciprocal of pinch scale).
Gets the pinch ratio of the fingers (reciprocal of pinch scale).
Gets the pinch ratio of the fingers (reciprocal of pinch scale).
Gets the average twist of the fingers in degrees.
Gets the average twist of the fingers in degrees.
Gets the average twist of the fingers in degrees.
Gets the average twist of the fingers in degrees.
Gets the average twist of the fingers in radians.
Gets the average twist of the fingers in radians.
Gets the average twist of the fingers in radians.
Gets the average twist of the fingers in radians.
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.
The age of the finger when this snapshot was created.
The screen position of the finger when this snapshot was created.
This will return the world position of this snapshot based on the distance from the camera.
Return the last inactive snapshot, or allocate a new one.
This will return the recorded position of the current finger when it was at 'targetAge'.
This will return snapshot information at the specified index, if it exists.
This will get the index of the closest snapshot whose age is under targetAge
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.
This contains all the active and enabled LeanTouch instances
This list contains all fingers currently touching the screen (or have just stopped touching the screen).
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.
This gets fired when a finger begins touching the screen (LeanFinger = The current finger)
This gets fired every frame a finger is touching the screen (LeanFinger = The current finger)
This gets fired when a finger stops touching the screen (LeanFinger = The current finger)
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.
This gets fired when a finger taps the screen (this is when a finger begins and stops touching the screen within the 'TapThreshold' time).
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)
This gets fired every frame at least one finger is touching the screen (List = Fingers).
This gets fired after a finger has been touching the screen for longer than TapThreshold seconds, making it ineligible for a swipe.
This gets fired the frame after a finger went up,
This will be invoked when it's time to simulate fingers. You can call the AddFinger method to simulate them.
This allows you to set how many seconds are required between a finger down/up for a tap to be registered.
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.
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.
This allows you to set the default DPI you want the input scaling to be based on.
This allows you to set which layers your GUI is on, so it can be ignored by each finger.
If you disable this then lean touch will act as if you stopped touching the screen.
Should the mouse hover position be stored as a finger?
Should any mouse button press be stored as a finger?
Should components hooked into the OnSimulateFingers event be used? (e.g. LeanTouchSimulator)
Should each finger record snapshots of their screen positions?
This allows you to set the amount of pixels a finger must move for another snapshot to be stored.
This allows you to set the maximum amount of seconds that can be recorded, 0 = unlimited.
The first active and enabled LeanTouch instance.
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.
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.
This will return true if the mouse or any finger is currently using the GUI.
This will return true if the specified screen point is over any GUI elements.
This will return all the RaycastResults under the specified screen point using the current layerMask.
This will return all the RaycastResults under the specified screen point using the specified layerMask.
This allows you to filter all the fingers based on the specified requirements.
This allows you to simulate a tap on the screen at the specified location.
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.
This component allows you to move the current GameObject (e.g. Camera) based on finger drags and the specified ScreenDepth.
The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.
The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.
The movement speed will be multiplied by this.
-1 = Inverted Controls.
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.
This allows you to control how much momentum is retained when the dragging fingers are all released.
This method moves the current GameObject to the center point of all selected objects.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.
This component draws trails behind fingers.
The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.
The method used to convert between screen coordinates, and world coordinates.
The line prefab that will be used to render the trails.
The maximum amount of active trails.
-1 = Unlimited.
How many seconds it takes for each trail to disappear after a finger is released.
The color of the trail start.
The color of the trail end.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.
This component allows you to translate the current GameObject relative to the camera using the finger drag gesture.
The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.
The camera the translation will be calculated using.
None/null = MainCamera.
The movement speed will be multiplied by this.
-1 = Inverted Controls.
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.
This allows you to control how much momentum is retained when the dragging fingers are all released.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.
This base class can be used to associate extra data with the specified LeanFinger instance.
This component invokes events when a finger touches the screen that satisfies the specified conditions.
Ignore fingers with StartedOverGui?
If the specified object is set and isn't selected, then this component will do nothing.
This event will be called if the above conditions are met when your finger begins touching the screen.
The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.
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.
This event will be called if the above conditions are met when your finger begins touching the screen.
Vector2 = Finger position in screen space.
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.
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).
Ignore fingers that began touching the screen on top of a GUI element?
If the amount of fingers doesn't match this number, ignore all fingers?
0 = Any amount.
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.
If the specified RequiredSelectable component's IsSelected setting is false, ignore all fingers?
If the current RequiredSelectable is null, this method allows you to try and set it based on the specified GameObject.
If you've set Filter to ManuallyAddedFingers, then you can call this method to manually add a finger.
If you've set Filter to ManuallyAddedFingers, then you can call this method to manually remove a finger.
If you've set Filter to ManuallyAddedFingers, then you can call this method to manually remove all fingers.
This method returns a list of all fingers based on the current settings.
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.
Ignore fingers with StartedOverGui?
Ignore fingers with OverGui?
If the specified object is set and isn't selected, then this component will do nothing.
This event will be called if the above conditions are met when your finger becomes old.
The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.
This event will be called if the above conditions are met when your finger becomes old.
Vector3 = Finger position in world space.
This event will be called if the above conditions are met when your finger becomes old.
Vector2 = Finger position in screen space.
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.
Ignore fingers with StartedOverGui?
Ignore fingers with OverGui?
If the specified object is set and isn't selected, then this component will do nothing.
This component calls the OnFingerTap event when a finger taps the screen.
Ignore fingers with StartedOverGui?
Ignore fingers with OverGui?
If the specified object is set and isn't selected, then this component will do nothing.
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).
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).
This event will be called if the above conditions are met when you tap the screen.
This event will be called if the above conditions are met when you tap the screen.
Int = The finger tap count.
The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.
This event will be called if the above conditions are met when you tap the screen.
Vector3 = Finger position in world space.
This event will be called if the above conditions are met when you tap the screen.
Vector2 = Finger position in screen space.
This component calls the OnUp event when a finger stops touching the screen.
Ignore fingers with StartedOverGui?
Ignore fingers with OverGui?
If the specified object is set and isn't selected, then this component will do nothing.
This event will be called if the above conditions are met when your finger stops touching the screen.
The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.
This event will be called if the above conditions are met when your finger stops touching the screen.
Vector3 = Finger position in world space.
This event will be called if the above conditions are met when your finger stops touching the screen.
Vector2 = Finger position in screen space.
This component allows you to detect when a finger is touching the screen.
Ignore fingers with StartedOverGui?
Ignore fingers with OverGui?
If the finger didn't move, ignore it?
If the finger just began touching the screen, ignore it?
If the finger just stopped touching the screen, ignore it?
If the finger is the mouse hover, ignore it?
If the specified object is set and isn't selected, then this component will do nothing.
Called on every frame the conditions are met.
The coordinate space of the OnDelta values.
The delta values will be multiplied by this when output.
This event is invoked when the requirements are met.
Vector2 = Position Delta based on your Coordinates setting.
Called on the first frame the conditions are met.
Float = The distance/magnitude/length of the swipe delta vector.
The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.
Called on the first frame the conditions are met.
Vector3 = Start point in world space.
Called on the first frame the conditions are met.
Vector3 = End point in world space.
Called on the first frame the conditions are met.
Vector3 = The vector between the start and end points in world space.
Called on the first frame the conditions are met.
Vector3 = Start point in world space.
Vector3 = End point in world space.
This component allows you to scale the current GameObject relative to the specified camera using the pinch gesture.
The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.
The camera that will be used to calculate the zoom.
None/null = MainCamera.
Should the scaling be performed relative to the finger center?
The sensitivity of the scaling.
1 = Default.
2 = Double.
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.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.
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.
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.
The camera the depth calculations will be done using.
None = MainCamera.
The plane/path/etc that will be intercepted.
The layers used in the raycast.
Tooltips are modified at runtime based on Conversion setting.
When performing a ScreenDepth conversion, the converted point can have a normal associated with it. This stores that.
This struct stores information about and allows you to search the scene for a specific object on screen space.
The method used to search the scene based on a screen position.
Raycast = 3D, 2D, and EventSystem raycast.
The scene will be queried (e.g. Raycast) against these layers.
When the query hits a GameObject, how should the desired component be searched for relative to it?
The component found from the search must have this tag.
The camera used to perform the search.
None = MainCamera.
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.
This allows you to control which fingers will be used by components that require this selectable.
This event is called when selection begins (finger = the finger that selected this).
This event is called when selection begins (finger = the finger that selected this).
This tells you the first or earliest still active finger that initiated selection of this object.
This tells you every currently active finger that selected this object.
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.
If the specified finger selected an object, this will return the first one.
This tells you if the current selectable was selected by the specified finger.
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.
This tells you which LeanSelectable is currently associated with this component.
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.
This method allows you to manually register the LeanSelectable this component is associated with.
This method allows you to manually register the LeanSelectable this component is associated with. This is useful if you're changing the associated LeanSelectable.
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).
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.
This is invoked when an object is selected.
This method allows you to initiate selection at the finger's StartScreenPosition.
This method allows you to initiate selection at the finger's current ScreenPosition.
This method allows you to initiate selection of a finger at a custom screen position.
This method allows you to manually select an object with the specified finger using this component's selection settings.
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.
This is the base class for all swiping actions.
The required angle of the swipe in degrees.
0 = Up.
90 = Right.
180 = Down.
270 = Left.
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).
Called on the first frame the conditions are met.
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.
The coordinate space of the OnDelta values.
The swipe delta will be multiplied by this value.
Called on the first frame the conditions are met.
Vector2 = The scaled swipe delta.
Called on the first frame the conditions are met.
Float = The distance/magnitude/length of the swipe delta vector.
The method used to find world coordinates from a finger. See LeanScreenDepth documentation for more information.
Called on the first frame the conditions are met.
Vector3 = Start point in world space.
Called on the first frame the conditions are met.
Vector3 = End point in world space.
Called on the first frame the conditions are met.
Vector3 = The vector between the start and end points in world space.
Called on the first frame the conditions are met.
Vector3 = Start point in world space.
Vector3 = End point in world space.
This component can be added alongside the LeanTouch component to add simulated multi touch controls using the mouse and keyboard.
This allows you to set which key is required to simulate multi key twisting.
This allows you to set which key is required to change the pivot point of the pinch twist gesture.
This allows you to set which key is required to simulate multi key dragging.
This allows you to set which texture will be used to show the simulated fingers.
This component allows you to transform the current GameObject relative to the specified camera using a twist gesture.
The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.
The camera we will be used to calculate relative rotations.
None/null = MainCamera.
Should the rotation be performed relative to the finger center?
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.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.
This component allows you to rotate the current GameObject around the specified axis using finger twists.
The method used to find fingers to use with this component. See LeanFingerFilter documentation for more information.
The axis of rotation.
Rotate locally or globally?
The sensitivity of the rotation.
1 = Default.
2 = Double.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.
If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove all fingers.
This component will pulse the transform.localScale value over time.
The default scale.
The current scale multiplier.
The interval between each pulse in seconds.
The amount Size will be incremented each pulse.
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.
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?
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?
Planet Pack - Space Graphics Toolkit
LeanSelectableByFingerBehaviour