# Slider

In order for a Slider from Figma to be imported to Unity automatically, certain rules apply when designing a slider in Figma.

<figure><img src="https://1621352894-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbxGkHH9nbw4PqGFuLmzb%2Fuploads%2F53gKybqi0pENkuUjrOXu%2FEkran%20Resmi%202024-05-22%2009.09.06.png?alt=media&#x26;token=7ebb7f0f-6817-45ec-9ab2-e8f9bca9b6d3" alt="" width="375"><figcaption><p>A slider component set in Figma</p></figcaption></figure>

### Unity Importer Plugin

In order for Figma Importer to understand which component it is trying to convert a figma node to a Unity UI element, Component Type from Unity Importer plugin must be selected as desired component type. "Slider" component type should be selected when designing a slider.&#x20;

Direction of a slider can be selected through the plugin, there are 4 direction options: Left to right, right to left, top to bottom, bottom to top.

### "State" variant

Sliders have 4 states: Default, Hover, Press, Disabled. These states must be designed as variants of a slider component set in Figma. The variant name in Figma must be "State" otherwise the importer won't be able to identify it.&#x20;

{% hint style="info" %}
The hierarchy of child nodes of a component set's variant must be the same for each and every one of them.&#x20;
{% endhint %}

### The hierarchy of Slider component variant

In order for importer to convert a slider component from Figma to Unity's built in Slider component, a predefined hiearchy should be applied to have expected behavior.

<figure><img src="https://1621352894-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbxGkHH9nbw4PqGFuLmzb%2Fuploads%2FQwR0Wj8fZsa9GzQ6LxG9%2FEkran%20Resmi%202024-05-22%2009.21.10.png?alt=media&#x26;token=d4b34b97-671c-480e-8445-a318a6096b52" alt="" width="206"><figcaption><p>Unity built in Slider component hierarchy</p></figcaption></figure>

Keeping in mind the built in Unity slider hierarchy, design of a slider variant in Figma should look like:&#x20;

<figure><img src="https://1621352894-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbxGkHH9nbw4PqGFuLmzb%2Fuploads%2FHxNHuEQRoIaur8qtWyTn%2FEkran%20Resmi%202024-05-22%2009.25.46.png?alt=media&#x26;token=37d33d8a-fc5f-4d7a-8dc8-d7f5345edd97" alt="" width="218"><figcaption><p>Figma slider component set variant's hierarchy</p></figcaption></figure>

### Binding keys of "Fill Rect" and "Handle Rect"

Unity's slider component needs to have "Fill Rect" and "Handle Rect" set to behave as expected.

<figure><img src="https://1621352894-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbxGkHH9nbw4PqGFuLmzb%2Fuploads%2FDxLVDnqUmlHlqMxdeOqK%2FEkran%20Resmi%202024-05-22%2009.30.22.png?alt=media&#x26;token=84849977-930b-4a2b-a579-898a26b22873" alt="" width="375"><figcaption><p>Fill Rect and Handle Rect of a Slider component in Unity</p></figcaption></figure>

In order for importer to set these, binding keys should be set using Unity Importer plugin in Figma.

<div><figure><img src="https://1621352894-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbxGkHH9nbw4PqGFuLmzb%2Fuploads%2FQmBa6xA2f0zxsiQwcAKe%2FEkran%20Resmi%202024-05-22%2009.13.11.png?alt=media&#x26;token=64d7252d-131e-4c76-839c-cff7ab41f6dc" alt="" width="375"><figcaption><p>"@Handle" binding key is set for Handle</p></figcaption></figure> <figure><img src="https://1621352894-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbxGkHH9nbw4PqGFuLmzb%2Fuploads%2FhLkmpu2OmLfByV2XYhI8%2FEkran%20Resmi%202024-05-22%2009.13.21.png?alt=media&#x26;token=4faf8266-c6cc-4452-b84b-44bb81e0432e" alt="" width="375"><figcaption><p>"@Fill" binding key is set for Fill</p></figcaption></figure></div>

The binding keys for Handle Rect and Fill Rect must be "@Handle" and "@Fill" respectively.&#x20;

{% hint style="info" %}
Keep in mind that components & component sets are never imported to Unity, only instances of them are imported.
{% endhint %}
