Lean Common+


DOCUMENTATION

What is Lean Common+?

Lean Common+ is a lightweight collection of scripts and media used by all Lean+ assets.







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

1.0.0

Initial version.







Components

LeanChase

This component causes the current Transform to chase the specified position.


Transform
Destination

The transform that will be chased.



Vector3
DestinationOffset

If Target is set, then this allows you to set the offset in local space.



Vector3
Position

The world space position that will be followed.

NOTE  If Destination is set, then this value will be overridden.


Vector3
Offset

The world space offset that will be followed.



float
Damping

This allows you to control how quickly this Transform moves to the target position.

-1 = Instantly change.

0 = No change.

1 = Slowly change.

10 = Quickly change.



float
Linear

This allows you to control how quickly this Transform linearly moves to the target position.

0 = No linear movement.

1 = One linear position per second.



bool
IgnoreZ

Ignore Z for 2D?



bool
Continuous

Should the chase keep updating, even if you haven't called the SetPosition method this frame?



bool
SetPositionOnStart

Automatically set the Position value to the transform.position in Start?



void
SetPosition
Vector3 newPosition

This method will override the Position value based on the specified value.



void
SnapToPosition

This method will immediately move this Transform to the target position.




LeanChaseRigidbody

This component causes the current Rigidbody to chase the specified position.


void
SetPosition
Vector3 newPosition

This method will override the Position value based on the specified value.




LeanChaseRigidbody2D

This script allows you to drag this Rigidbody2D in a way that causes it to chase the specified position.


AxisType
Axis

This allows you to control which axes the velocity can apply to.



void
SetPosition
Vector3 newPosition

This method will override the Position value based on the specified value.




LeanConstrainLocalPosition

This component allows you to constrain the current transform.localPosition or transform.anchoredPosition3D to the specified min/max values.



LeanConstrainScale

This component will constrain the current transform.localScale to the specified range.


bool
Minimum

Should there be a minimum transform.localScale?



Vector3
MinimumScale

The minimum transform.localScale value.



bool
Maximum

Should there be a maximum transform.localScale?



Vector3
MaximumScale

The maximum transform.localScale value.




LeanConstrainToAxis

This component will constrain the current transform.position to the specified axis shape.

NOTE  Unlike LeanConstrainToCollider, this component doesn't use the physics system, so it can avoid certain issues if your constrain shape moves.

Transform
RelativeTo

The transform the constraint will be applied relative to.

None/null = World space.



AxisType
Axis

The axis that will be constrained.



float
Minimum

The minimum position value relative to the current space.



float
Maximum

The maximum position value relative to the current space.




LeanConstrainToBox

This component will constrain the current transform.position to the specified box shape.

NOTE  Unlike LeanConstrainToCollider, this component doesn't use the physics system, so it can avoid certain issues if your constrain shape moves.

Transform
RelativeTo

The transform the constraint will be applied relative to.

None/null = World space.



Vector3
Size

The size of the box relative to the current space.



Vector3
Center

The center of the box relative to the current space.




LeanConstrainToCollider

This component will constrain the current transform.position to the specified collider.

NOTE  If you're using a MeshCollider then it must be marked as convex.

Collider
Collider

The collider this transform will be constrained to.




LeanConstrainToColliders

This script will constrain the current transform.position to the specified colliders.

NOTE  If you're using a MeshCollider then it must be marked as convex.

List<Collider>
Colliders

The colliders this transform will be constrained to.




LeanConstrainToDirection

This component will constrain the current Transform.rotation values so that its facing direction doesn't deviate too far from the target direction.


Vector3
Forward

This allows you to specify which local direction is considered forward on this GameObject.

Leave this as the default (0,0,1) if you're not sure.



Vector3
Direction

This allows you to specify the target direction you want to constrain to. For example, (0,1,0) is up.



Transform
RelativeTo

If you want to constrain the direction relative to a Transform, you can specify it here.



float
MinAngle

This allows you to specify the minimum angle delta between the Forward and Direction vectors in degrees.



float
MaxAngle

This allows you to specify the maximum angle delta between the Forward and Direction vectors in degrees.




LeanConstrainToOrthographic

This component will constrain the current transform.position to the specified LeanPlane shape.



LeanDelayedValue

This component allows you to delay when a value is sent to a component. This is done by first passing the value to this component using one of the SetX/Y/Z methods, and then sending it out after a delay using the OnValueX/Y/Z events.


float
Delay

The set values will be output after this many seconds.



bool
AutoClear

If no position has been set this frame, clear all pending values?



FloatEvent
OnValueX

This event will send any previously set values after the specified delay.



FloatEvent
OnValueY

This event will send any previously set values after the specified delay.



FloatEvent
OnValueZ

This event will send any previously set values after the specified delay.



Vector2Event
OnValueXY

This event will send any previously set values after the specified delay.



Vector3Event
OnValueXYZ

This event will send any previously set values after the specified delay.



void
SetX
float value

This method allows you to set the X axis.



void
SetY
float value

This method allows you to set the Y axis.



void
SetZ
float value

This method allows you to set the Z axis.



void
SetXY
Vector2 value

This method allows you to set the XY axis.



void
SetXYZ
Vector3 value

This method allows you to set the XYZ axis.



void
Clear

This method will reset the currently pending value and remove all pending delayed values.




LeanFollow

This component causes the current Transform to follow the specified trail of positions.


void
ClearPositions

This method will remove all follow positions, and stop movement.



void
AddPosition
Vector3 newPosition

This method adds a new position to the follow path.




LeanMaintainDistance

This component keeps the current GameObject the specified distance away from its parent.


Vector3
Direction

The direction of the distance separation.

0,0,0 = Use current direction.



Space
DirectionSpace

The coordinate space for the Direction values.



float
Distance

The distance we want to be from the parent in world space.



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.



bool
Clamp

Should the distance value be clamped?



float
ClampMin

The minimum distance.



float
ClampMax

The maximum distance.



LayerMask
CollisionLayers

The layers we should collide against.



float
CollisionRadius

The radius of the collision.



void
AddDistance
float value

This method allows you to increment the Distance value by the specified value.



void
MultiplyDistance
float value

This method allows you to multiply the Distance value by the specified value.




LeanManualRotate

This component allows you to rotate the current GameObject using events.


GameObject
Target

If you want this component to work on a different GameObject, then specify it here. This can be used to improve organization if your GameObject already has many components.



Space
Space

This allows you to set the coordinate space the rotation will use.



Vector3
AxisA

The first rotation axis, used when calling RotateA or RotateAB.



Vector3
AxisB

The second rotation axis, used when calling RotateB or RotateAB.



float
Multiplier

The rotation angle is multiplied by this.

1 = Normal rotation.

2 = Double rotation.



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.



bool
ScaleByTime

If you enable this then the rotation will be multiplied by Time.deltaTime. This allows you to maintain framerate independent rotation.



Vector3
DefaultRotation

If you call the ResetRotation method, the rotation will be set to this Euler rotation.



void
ResetRotation

This method will reset the rotation to the specified DefaultRotation value.



void
SnapToTarget

This method will cause the rotation to immediately snap to its final value.



void
StopRotation

This method will clear the target rotation value, causing the rotation to stop.



void
RotateA
float delta

This method allows you to rotate around AxisA, with the specified angle in degrees.



void
RotateB
float delta

This method allows you to rotate around AxisB, with the specified angle in degrees.



void
RotateAB
Vector2 delta

This method allows you to rotate around AxisA and AxisB, with the specified angles in degrees.




LeanManualTranslate

This component allows you to translate the specified GameObject when you call methods like TranslateA, which can be done from events.


GameObject
Target

If you want this component to work on a different GameObject, then specify it here. This can be used to improve organization if your GameObject already has many components.



Space
Space

This allows you to set the coordinate space the translation will use.



Vector3
DirectionA

The first translation direction, used when calling TranslateA or TranslateAB.



Vector3
DirectionB

The first second direction, used when calling TranslateB or TranslateAB.



float
Multiplier

The translation distance is multiplied by this.

1 = Normal distance.

2 = Double distance.



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.



bool
ScaleByTime

If you enable this then the translation will be multiplied by Time.deltaTime. This allows you to maintain frame rate independent movement.



Vector3
DefaultPosition

If you call the ResetPosition method, the position will be set to this.



void
ResetPosition

This method will reset the position to the specified DefaultPosition value.



void
SnapToTarget

This method will cause the position to immediately snap to its final value.



void
TranslateA
float magnitude

This method allows you to translate along DirectionA, with the specified multiplier.



void
TranslateB
float magnitude

This method allows you to translate along DirectionB, with the specified multiplier.



void
TranslateAB
Vector2 magnitude

This method allows you to translate along DirectionA and DirectionB, with the specified multipliers.



void
Translate
Vector3 vector

This method allows you to translate along the specified vector in local space.



void
TranslateWorld
Vector3 vector

This method allows you to translate along the specified vector in world space.




LeanManualTranslateRigidbody

This component allows you to translate the specified Rigidbody when you call methods like TranslateA, which can be done from events.


GameObject
Target

If you want this component to work on a different GameObject, then specify it here. This can be used to improve organization if your GameObject already has many components.



Space
Space

This allows you to set the coordinate space the translation will use.



Vector3
DirectionA

The first translation direction, used when calling TranslateA or TranslateAB.



Vector3
DirectionB

The first second direction, used when calling TranslateB or TranslateAB.



float
Multiplier

The translation distance is multiplied by this.

1 = Normal distance.

2 = Double distance.



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 momenum is retained when the dragging fingers are all released.

NOTE  This requires Dampening to be above 0.


bool
ScaleByTime

If you enable this then the translation will be multiplied by Time.deltaTime. This allows you to maintain framerate independent movement.



void
TranslateA
float magnitude

This method allows you to translate along DirectionA, with the specified multiplier.



void
TranslateB
float magnitude

This method allows you to translate along DirectionB, with the specified multiplier.



void
TranslateAB
Vector2 magnitude

This method allows you to translate along DirectionA and DirectionB, with the specified multipliers.



void
Translate
Vector3 vector

This method allows you to translate along the specified vector in local space.



void
TranslateWorld
Vector3 vector

This method allows you to translate along the specified vector in world space.




LeanManualTranslateRigidbody2D

This component allows you to translate the specified Rigidbody2D when you call methods like TranslateA, which can be done from events.


GameObject
Target

If you want this component to work on a different GameObject, then specify it here. This can be used to improve organization if your GameObject already has many components.



Space
Space

This allows you to set the coordinate space the translation will use.



Vector2
DirectionA

The first translation direction, used when calling TranslateA or TranslateAB.



Vector2
DirectionB

The first second direction, used when calling TranslateB or TranslateAB.



float
Multiplier

The translation distance is multiplied by this.

1 = Normal distance.

2 = Double distance.



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.



bool
ScaleByTime

If you enable this then the translation will be multiplied by Time.deltaTime. This allows you to maintain framerate independent movement.



void
TranslateA
float magnitude

This method allows you to translate along DirectionA, with the specified multiplier.



void
TranslateB
float magnitude

This method allows you to translate along DirectionB, with the specified multiplier.



void
TranslateAB
Vector2 magnitude

This method allows you to translate along DirectionA and DirectionB, with the specified multipliers.



void
Translate
Vector3 vector

This method allows you to translate along the specified vector in local space.



void
TranslateWorld
Vector3 vector

This method allows you to translate along the specified vector in world space.




LeanOrbit

This component controls the current GameObject's rotation, based on the specified Pitch and Yaw values.


Camera
Camera

If you want the rotation to be scaled by the camera FOV, then set the camera here.



Transform
Pivot

The camera will orbit around this point.



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
Pitch

Pitch of the rotation in degrees.



float
PitchSensitivity

The strength of the pitch changes with vertical finger movement.



float
Yaw

Yaw of the rotation in degrees.



float
YawSensitivity

The strength of the yaw changes with horizontal finger movement.




LeanPitchYaw

This component controls the current GameObject's rotation, based on the specified Pitch and Yaw values.


Camera
Camera

If you want the rotation to be scaled by the camera FOV, then set the camera here.



Vector2
DefaultRotation

This allows you to set the Pitch andYaw rotation value when calling the ResetRotation method.



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
Pitch

Pitch of the rotation in degrees.



float
PitchSensitivity

The strength of the pitch changes with vertical finger movement.



bool
PitchClamp

Limit the pitch to min/max?



float
PitchMin

The minimum pitch angle in degrees.



float
PitchMax

The maximum pitch angle in degrees.



float
Yaw

Yaw of the rotation in degrees.



float
YawSensitivity

The strength of the yaw changes with horizontal finger movement.



bool
YawClamp

Limit the yaw to min/max?



float
YawMin

The minimum yaw angle in degrees.



float
YawMax

The maximum yaw angle in degrees.



void
ResetRotation

This method resets the Pitch and Yaw values to the DefaultRotation value.



void
RotateToPosition
Vector3 point

This method will automatically update the Pitch and Yaw values based on the specified position in world space.



void
RotateToDirection
Vector3 xyz

This method will automatically update the Pitch and Yaw values based on the specified direction in world space.



void
RotateToScreenPosition
Vector2 screenPosition

This method will automatically update the Pitch and Yaw values based on the specified position in screen space.




LeanPitchYawAutoRotate

This component adds auto Yaw rotation to the attached LeanPitchYaw component.


float
Delay

The amount of seconds until auto rotation begins after no touches.



float
Speed

The speed of the yaw changes.



float
Acceleration

The speed the auto rotation goes from 0% to 100%.




LeanRevertTransform

This script will record the state of the current transform, and revert it on command.


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.




LeanRotateToPosition

This component automatically rotates the current GameObject based on movement.


Transform
Target

The Transform that will be rotated.

None/Null = This GameObject's Transform.



PositionType
Position

This allows you choose the method used to calculate the position we will rotate toward.

PreviousPosition = This component will automatically calculate positions based on the Transform.position.

ManuallySetPosition = You must manually call the SetPosition method to update the rotation.



float
Threshold

This allows you to set the minimum amount of movement required to trigger the rotation to update. This is useful to prevent tiny movements from causing the rotation to change unexpectedly.



bool
Invert

If you enable this the rotation will be reversed.



RotateType
RotateTo

This allows you choose the method used to find the target rotation.



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
SetPosition
Vector3 position

If Position is set to ManuallySetPosition, then this method allows you to set the position we will rotate to.



void
SetDelta
Vector3 delta

This method allows you to override the position delta used to calculate the rotation.

NOTE  This should be non-zero.


void
ResetPosition

If your Transform has teleported, then call this to reset the cached position.




LeanRotateToRigidbody2D

This component automatically rotates the current Rigidbody2D based on movement.


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.




LeanSmoothedValue

This component allows you to smooth a value that is sent to a component. This is done by first passing the value to this component using one of the SetX/Y/Z methods, and then sending it out after smoothing using the OnValueX/Y/Z events.


float
Damping

This allows you to control how quickly the target value is reached.



float
Threshold

Damping alone won't reach the target value. This setting allows you to force the value to move toward the target with linear interpolation.



bool
AutoStop

If the target value has been reached, stop sending events?



FloatEvent
OnValueX

This event will send any previously set values after the specified delay.



FloatEvent
OnValueY

This event will send any previously set values after the specified delay.



FloatEvent
OnValueZ

This event will send any previously set values after the specified delay.



Vector2Event
OnValueXY

This event will send any previously set values after the specified delay.



Vector3Event
OnValueXYZ

This event will send any previously set values after the specified delay.



void
SetX
float value

This method allows you to set the X axis.



void
SetY
float value

This method allows you to set the Y axis.



void
SetZ
float value

This method allows you to set the Z axis.



void
SetXY
Vector2 value

This method allows you to set the XY axis.



void
SetXYZ
Vector3 value

This method allows you to set the XYZ axis.



void
SnapToTarget

This method will immediately snap the current value to the target value.



void
Stop

This method will reset the target value and stop sending any events.




LeanSpawnBetween

This component allows you to spawn a prefab at a point, and have it thrown toward the target.


Transform
Prefab

The prefab that gets spawned.



float
VelocityMultiplier

When calling Spawn, this allows you to specify the spawned velocity.




LeanSwap

This component will swap the target GameObject with one of the specified prefabs when swiping.


int
Index

The current index within the Prefabs list.



List<Transform>
Prefabs

The alternative prefabs that can be swapped to.



void
UpdateSwap

This method forces the swap to update if it's been modified.



void
SwapTo
int newIndex

This method allows you to swap to the specified index.



void
SwapToPrevious

This method allows you to swap to the previous index.



void
SwapToNext

This method allows you to swap to the next index.




LeanThresholdDelta

This component allows you to accumilate delta changes until they reach a threshold delta, and then output them.

This is useful for making more precise movements when using inaccurate touch inputs.


Vector3
Current

The current accumilated delta.



float
Threshold

When any dimension of Current exceeds this, OnDelta___ will be called, and Current will be rolled back.



bool
Step

If you enable this then the delta will step in increments based on the Threshold value. If you disable this then the position will immediately be set to the Current value.



void
AddXY
Vector2 delta

This method allows you to increment Current.



void
AddXYZ
Vector3 delta

This method allows you to increment Current.



void
AddX
float delta

This method allows you to increment Current.x.



void
AddY
float delta

This method allows you to increment Current.y.



void
AddZ
float delta

This method allows you to increment Current.z.




LeanThresholdPosition

This component allows you to store the Current position. Once this differs from the Previous position by more than the Threshold, the Previous value will change to match Current, and the OnPosition events will fire with the current position.

This is useful for making more precise movements when using inaccurate touch inputs.


Vector3
Current

The current position.



Vector3
Previous

The previously sent position.



float
Threshold

When any dimension of Current exceeds this, OnPosition___ will be called, and Current will be rolled back.



bool
Step

If you enable this then the position will step toward the Current value in increments based on the Threshold value. If you disable this then the position will immediately be set to the Current value.



void
AddXY
Vector2 delta

This method allows you to increment Current.



void
AddXYZ
Vector3 delta

This method allows you to increment Current.



void
AddX
float delta

This method allows you to increment Current.x.



void
AddY
float delta

This method allows you to increment Current.y.



void
AddZ
float delta

This method allows you to increment Current.z.



void
SetXY
Vector2 position

This method allows you to set the Current position.



void
SetXYZ
Vector3 position

This method allows you to set the Current position.




LeanLoadScene

This component allows you to load the specified scene when you manually call the Load method.


string
SceneName

The name of the scene you want to load.



bool
ASync

Load the scene asynchronously?



bool
Additive

Keep the existing scene(s) loaded?




LeanPongBall

This script moves the ball left or right and resets it if it goes out of bounds.



Index

What is Lean Common+?



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

1.0.0



Components

LeanChase

LeanChaseRigidbody

LeanChaseRigidbody2D

LeanConstrainLocalPosition

LeanConstrainScale

LeanConstrainToAxis

LeanConstrainToBox

LeanConstrainToCollider

LeanConstrainToColliders

LeanConstrainToDirection

LeanConstrainToOrthographic

LeanDelayedValue

LeanFollow

LeanMaintainDistance

LeanManualRotate

LeanManualTranslate

LeanManualTranslateRigidbody

LeanManualTranslateRigidbody2D

LeanOrbit

LeanPitchYaw

LeanPitchYawAutoRotate

LeanRevertTransform

LeanRotateToPosition

LeanRotateToRigidbody2D

LeanSmoothedValue

LeanSpawnBetween

LeanSwap

LeanThresholdDelta

LeanThresholdPosition

LeanLoadScene

LeanPongBall