# Blend Shapes

## Overview

The Blend Shapes Component  controls the blend shapes of a skinned mesh..just like the [SkinnedMeshRenderer ](https://docs.unity3d.com/Manual/class-SkinnedMeshRenderer.html)component does. but you don't have to search for the mesh deep in the hierarchy.

![Sample of the BlendShapes component](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M7O01hn7wLaRUhzJ6DP%2F-M7TqpgaC2rje9sfCroj%2Fimage.png?alt=media\&token=86f8c16d-5260-4dc4-bc5f-e514c213830b)

![Blend Shapes inside the SkinnedMeshRenderer Component.](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M7O01hn7wLaRUhzJ6DP%2F-M7TrxIbSqUhotx5UPs9%2Fimage.png?alt=media\&token=7c0c8b05-f74e-4dfa-b1ee-9af27d0e43bc)

![Blend Shapes inside the SkinnedMeshRenderer Component.](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M7O01hn7wLaRUhzJ6DP%2F-M7TrxIbSqUhotx5UPs9%2Fimage.png?alt=media\&token=7c0c8b05-f74e-4dfa-b1ee-9af27d0e43bc)

Also you can load/save[ **Blend Shape Presets**](https://malbersanimations.gitbook.io/animal-controller/utilities/blend-shapes/blend-shape-preset) to have different variations.

## Parameters

### Mesh

Reference to the skinned mesh renderer.

### LODs

Extra meshes that share the same Blendshapes, like LODs meshes or the Magic Tattoos on the Poly Art Animals:

![The "magic" mesh also changes with the mesh of the wolf](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M7Tw9H4QnzO3oUu0i48%2F-M7TwgqirotM2Ieo3njL%2Fr0Dl4IpIWA.gif?alt=media\&token=6d111246-9594-4a19-9e2b-d011ed613e54)

### Pin Blend Shape&#x20;

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M7U4b74xSQh7f9eiSUL%2F-M7U55u4CMmzILbyjk-5%2FUnity_IChdNThaWS.png?alt=media\&token=a422987c-c4bf-4e65-89a6-d8a9d502c9f2)

The Pin blendshape is the value stored to be used with Unity Events, since this unity Events cannot have more than one value on its listeners.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M7Tw9H4QnzO3oUu0i48%2F-M7TzOkRJFVQG5Vnv-Wr%2Fimage.png?alt=media\&token=17162622-5959-432f-a59b-c09fa13dd2fb)

E.g. : In the first Listener we Store/Pin Blend Shape (the first one, with index=0) and on the second Listener we change the value of tha stored/pinned blend shape with the Slider value of the UI component.

***You can check how to use the Pin Shape on the Callback Sample scenes of each Animal.***

### Blend Shape Weight List

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M7U4b74xSQh7f9eiSUL%2F-M7U5WntkNn4FmI1Ruke%2Fimage.png?alt=media\&token=60d8d6e0-d288-4ab0-8212-c3a673268e18)

List of all the Blend shapes weights of the skinned mesh renderer. Each Blendshape have a label for its Index. E.g.: (00) is the **Index** for the Blend Shape Big Eyes on the Wolf.

### Preset

The[ **Blend Shape Preset**](https://malbersanimations.gitbook.io/animal-controller/utilities/blend-shapes/blend-shape-preset) is simply an array of float values to save/load the Blend shapes you have modified.

### Load Preset

If the **Preset** parameter has a preset set, then At start the component this preset will be loaded.

### Random

At Start this component will generate random blend shape weights.&#x20;

## Editor Buttons

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M7U4b74xSQh7f9eiSUL%2F-M7U6C414Aet-8Ym9X3r%2Fimage.png?alt=media\&token=16b06475-01fd-4045-8e35-ce8375ca7573)

### Reset

Reset all the weights of the blendshapes to zero.

### Randomize

Randomize all the weights of the blendshapes&#x20;

### Save

Save the current blend shapes to a preset.

### Load

Load a blend preset.

## Public Methods

### `float[] GetBlendShapeValues()`

> Gets an array of all the blendshape weights on the skinned mesh renderer.

### `void LoadSmoothPreset(BlendShapePreset preset)`

> Blends from the current blend shapes weights to the weights of the preset.

### `void LoadPreset()`

> Load the weights from the preset stored on the [**Preset** ](#preset)parameter.

### `LoadPreset(BlendShapePreset preset)`

> Load the weights from the preset.

### `void SavePreset()`

> Save the current blendshape weights to the preset on the [**Preset** ](#preset)parameter.

### `void Randomize()`

> Randomize the weights on the skinned mesh and its LODs

### `void SetWeight(string name, float value)`

> Set a new weight on a blendshape using its name

### `void SetWeight(int index, float value)`

> Set a new weight on a blendshape using its index

### `void _PinShape(string name)`

> Store/Pin a blend shape by its name

### `void _PinShape(int index)`

> Store/Pin a blend shape by its Index

### `_PinnedShapeSetValue(float value)`

> Set a new weight on the Stored/Pinned blend shape

### `void UpdateBlendShapes()`

> Updates all the weights of the component to the Skinned mesh renderer
