## 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 Touch

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

## Lean Touch+

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

## Lean Localization

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

## Lean Pool

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

## Lean Transition

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

## Lean GUI

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

## Lean GUI Shapes

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

## Lean Texture

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

## Lean Texture+

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

## Spaceships - Build & Destroy

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

## Modular Backgrounds

Unlock a universe of visual possibilities with Modular Backgrounds. Simply drag and drop these graphics into the background of your scenes.

## 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!

## Paint in 2D

Paint all your sprites with Paint in 2D. With incredible performance on mobile, WebGL, and much more!

## Paint in Editor

Paint in Editor unlocks the ability to paint objects in your scene - great for making small tweaks, or even creating entirely new texture sets!

## FLOW

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

## Destructible 2D

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

## Space Graphics Toolkit

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

## Space Graphics Planets

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

## Volumetric Audio

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

Updated CW/Common code to latest version.

## 2.0.1

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

## 2.0.0

Changed folder structure to be inside Plugins/CW/LeanCommon.
Updated inspector code to support third party assets that implement nested inspectors.

## 1.0.2

Fixed transform gizmos not appearing in Unity 2021.2.

## 1.0.1

Updated LeanEditor to support inspectors based on SerializedProperty.

## 1.0.0

Initial version.

# Components

## LeanCommon

This class contains some useful methods used by this asset.

## static T
GetObjectFromSerializedProperty<T>
object target, SerializedProperty property

This method gives you the actual object behind a SerializedProperty given to you by a property drawer.

## LeanDestroy

This component allows you to destroy a GameObject.

## ExecuteType
Execute

This allows you to control when the Target GameObject will be destroyed.

OnFirstFrame = As soon as Update runs (this component must be enabled).

AfterDelay = After the specified amount of Seconds has elapsed.

AfterDelayUnscaled = The same as AfterDelay, but using unscaledDeltaTime.

Manually = You must manually call the DestroyNow method.

## GameObject
Target

The GameObject that will be destroyed.

None/null = This GameObject.

## float
Seconds

The amount of seconds remaining until the GameObject is destroyed.

## void
DestroyNow

You can manually call this method to destroy the specified GameObject immediately.

## LeanFormatString

This component allows you to convert values like ints and floats into formatted text that can be shown in the UI. To use this component, simply call one of the SetString methods, and it will output the formatted string to the OnString event, which can be connected to UI text, etc.

## string
Format

The final text will use this string formatting, where {0} is the first value, {1} is the second, etc. Formatting uses standard string.Format style.

## StringEvent
OnString

Based on the Send setting, this event will be invoked.

String = The .

## void
SetString
string a

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
string a, string b

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
int a

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
int a, int b

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
float a

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
float a, float b

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
Vector2 a

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
Vector2 a, Vector2 b

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
Vector3 a

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
Vector3 a, Vector3 b

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
Vector4 a

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
Vector4 a, Vector4 b

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
float a, int b

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## void
SetString
int a, float b

This method will convert the input arguments into a formatted string, and output it to the OnString event.

## LeanPath

This component stores a list of points that form a path.

## List<Vector3>
Points

The points along the path.

## bool
Loop

Do these points loop back to the start?

## Space
Space

The coordinate system for the points.

## int
Smoothing

The amount of lines between each path point when read from LeanScreenDepth.

## LineRenderer
Visual

This allows you to draw a visual of the path using a LineRenderer.

## LeanPlane

This component stores information about a 3D plane. By default this plane lays on the XY axis, or faces the Z axis.

## bool
ClampX

Should the plane be clamped on the x axis?

## bool
ClampY

Should the plane be clamped on the y axis?

## float
SnapX

The distance between each position snap on the x axis.

## float
SnapY

The distance between each position snap on the x axis.

## LeanRoll

This component rotates the current GameObject based on the current Angle value.

NOTEThis component overrides and takes over the rotation of this GameObject, so you can no longer externally influence it.

## float
Angle

The current angle in degrees.

## bool
Clamp

Should the Angle value be clamped?

## float
ClampMin

The minimum Angle value.

## float
ClampMax

The maximum Angle value.

## 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
IncrementAngle
float delta

The Angle value will be incremented by the specified angle in degrees.

## void
DecrementAngle
float delta

The Angle value will be decremented by the specified angle in degrees.

## void
RotateToDelta
Vector2 delta

This method will update the Angle value based on the specified vector.

## void
SnapToTarget

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

## LeanSelect

This is the base class for all object selectors.

## bool
DeselectWithNothing

If you attempt to select a point that has no objects underneath, should all currently selected objects be deselected?

## LimitType
Limit

If you have selected the maximum number of objects, what should happen?

Unlimited = Always allow selection.

StopAtMax = Allow selection up to the MaxSelectables count, then do nothing.

DeselectFirst = Always allow selection, but deselect the first object when the MaxSelectables count is reached.

## int
MaxSelectables

The maximum number of selectables that can be selected at the same time.

0 = Unlimited.

## ReselectType
Reselect

If you select an already selected selectable, what should happen?

## List<LeanSelectable>
Selectables

This stores all objects selected by this component.

## LeanSelectableEvent
OnSelected

This is invoked when an object is selected.

## LeanSelectableEvent
OnDeselected

This is invoked when an object is deselected.

## UnityEvent
OnNothing

This is invoked when you try to select, but nothing is found.

## void
Select
LeanSelectable selectable

This will select the specified object and add it to this component's Selectables list, if it isn't already there.

## void
Deselect
LeanSelectable selectable

This remove the specified object from this component's Selectables list if present, and deselect it.

## void
DeselectAll

This will deselect all objects that were selected by this component.

## void
Cull
int maxCount

This will deselect objects in chronological order until the selected object count reaches the specified amount.

## LeanSelectable

This component allows you make the current GameObject selectable.

## LeanSelectEvent
OnSelected

This is invoked every time this object is selected.

LeanSelect = The component that caused the selection (null = self selection).

NOTEThis may occur multiple times.

## LeanSelectEvent
OnDeselected

This is invoked every time this object is deselected.

LeanSelect = The component that caused the deselection (null = self deselection).

NOTEThis may occur multiple times.

## int
SelectedCount

This will tell you how many LeanSelect components in the scene currently have this object selected.

## bool
IsSelected

This will tell you if this object is self selected, or selected by any LeanSelect components in the scene.

## static void
DeselectAll

This deselects all objects in the scene.

## LeanSelectableBehaviour

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.

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

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

## LeanSelectableGraphicColor LeanSelectableBehaviour

This component allows you to change the color of the Graphic (e.g. Image) attached to the current GameObject when selected.

## Color
DefaultColor

The default color given to the SpriteRenderer.

## Color
SelectedColor

The color given to the SpriteRenderer when selected.

## LeanSelectableRendererColor LeanSelectableBehaviour

This component allows you to change the color of the Renderer (e.g. MeshRenderer) attached to the current GameObject when selected.

## Color
DefaultColor

The default color given to the SpriteRenderer.

## Color
SelectedColor

The color given to the SpriteRenderer when selected.

## LeanSelectableSpriteRendererColor LeanSelectableBehaviour

This component allows you to change the color of the SpriteRenderer attached to the current GameObject when selected.

## Color
DefaultColor

The default color given to the SpriteRenderer.

## Color
SelectedColor

The color given to the SpriteRenderer when selected.

## LeanSpawn

This component allows you to spawn a prefab at the specified world point.

NOTEFor this component to work you must manually call the Spawn method from somewhere.

## Transform
Prefab

The prefab that this component can spawn.

## SourceType
DefaultPosition

If you call Spawn(), where should the position come from?

## SourceType
DefaultRotation

If you call Spawn(), where should the rotation come from?

## void
Spawn

This will spawn Prefab at the current Transform.position.

## void
Spawn
Vector3 position

This will spawn Prefab at the specified position in world space.

## Index

What is Lean Common?

## Assets

Lean Touch

Lean Touch+

Lean Localization

Lean Pool

Lean Transition

Lean GUI

Lean GUI Shapes

Lean Texture

Lean Texture+

Spaceships - Build & Destroy

Modular Backgrounds

Paint in 3D

Paint in 2D

Paint in Editor

FLOW

Destructible 2D

Space Graphics Toolkit

Space Graphics Planets

Volumetric Audio

## Versions

2.1.0

2.0.1

2.0.0

1.0.2

1.0.1

1.0.0

## Components

LeanCommon

LeanDestroy

LeanFormatString

LeanPath

LeanPlane

LeanRoll

LeanSelect

LeanSelectable

LeanSelectableBehaviour

LeanSelectableGraphicColor

LeanSelectableRendererColor

LeanSelectableSpriteRendererColor

LeanSpawn