# Selector Manager

## Overview

Is the global Manager, handles the Data, the Open and Close the selector, instantiate the Item. All other scripts must be childs gameobjects of the Selector Manager.

![](/files/-Lzx_aZxgkEBv2ZuLlu4)

## **Parameters**

### **Input**

Key or Input from the Unity Input manager to Open and Close the Selector.

### **Open on Awake/Close on Awake**

Start Open or Close when hit play.

### **Instantiate Item**

Instantiate the Original GameObject of the Selected **Item** , if the Item does not have an Original GameObject it will instantiate the **Item** object itself.

### **Spawn Point**

Transform reference the position to instantiate the Item. If this parameter is empty, it will instantiate using the Selector Manager Transform as position reference.

### **Remove Last Spawn**

Remove the Last spawned item and It will add the new one.

### **Animate Open/Close**

It will use Animation Transforms to animate the Target in an out when opening and closing the Selector.

### **Target to Animate**

Which transform the Animations will be applied to.

### **Open**

Animation Transform Asset to use as Open Animation.

### **Close**

Animation Transform Asset to use as Close Animation.

### **Data**

This is an Scriptable Object to save all the important values of the Selector.

You can enable 'Use [PlayerPref](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html)' and save the data there, but is recommended to use a better and secure 'Saving System'

![](/files/-Lzx_aZy-SJNcv9DIiv3)

### **Coins**

Total of coins for the selector.

### **Use PlayerPref to Save Data**

Enable it to persistent save the Data using [**PlayerPref**](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html) Class, but is recommended to use a better and secure 'Saving System' and connect it to the Data Asset.

### **Save Default Data**

Store all the Coins Items amount , Lock status, [**MaterialChanger** ](/animal-controller/utilities/material-changer.md)and [**ActiveMeshes**](/animal-controller/utilities/active-meshes.md), as the Restore/Default Data.

### **Restore Data**

Restore all the values from to the Default Data.

## **Events**

### **OnSelected(GameObject):**

Invoked when a item is selected. For dynamic methods, uses the Original GameObject as parameter.

As an Example you can check the Demo: **Boxes Radial Screen** so see this Event on action working together with the [\_ReduceAmountSelected()](/animal-controller/ultimate-selector/selector-manager.md#void-_reduceamountselected) method.

### **OnOpen(GameObject)**

Invoked when the Selector is Open. For dynamic methods, uses the Original GameObject as parameter.

As an Example you can check the Demo: **Cards Linear Screen** so see this Event on action.

### **OnClosed(GameObject)**

Invoked when the Selector is Closed. For dynamic methods, uses the Original GameObject as parameter.

As an Example you can check the Demo: **Cards Linear Screen** so see this Event on action.

## Methods & Properties

### `bool EnableSelector`

> Open/Close the selector.
>
> Example: Use it on the [**OnSelected** ](/animal-controller/ultimate-selector/selector-manager.md#onselected-gameobject)event and set it to false. so every time you select an item the selector will close.

### `void ToggleSelector()`

> Toggle On and Off the Selector (if it is open, close it, and vice versa)

### `void Purchase(MItem item)`

> Purchase the item, this method is usually called by the [SelectorUI](broken://pages/-Lzx_aZos4BnwG0_815B#_qh6nkd1k9wr) class on the Purchase button, which also will update the UI.

### `void _ReduceAmountSelected()`

> Reduce the Amount of the selected item. Usually used on the [**OnSelected** ](/animal-controller/ultimate-selector/selector-manager.md#onselected-gameobject)Event. so when the item is selected also reduce by one the item.

### `void SaveDefaultData()`

> &#x20;Save to the Data the Default Data. it will use this as Starting point for the selector, and be used all those values as Restore Point. This is also used on the Save Default Data Button on the Selector Manager Inspector.

### `void RestoreToDefaultData()`

> &#x20;Restore Data using the Default Data setted before on the **SaveDefaultData()** method

### `void SelectItem()`

> Select the Focused Item if is not locked and the amount is greater than zero, also instantiate it if Instantiate Item is enabled.
>
> This is usually used by the Select Button on the UI..

![](/files/-Lzx_aZz6Ni9HjUe_5j5)

> ...or by the **OnClick/Touch an Item Event** from the [Selector Controller](/animal-controller/ultimate-selector/selector-controller.md). (See Demo: **BoxRadialScreen**)

![](/files/-Lzx_a_-Gs-U9FFJ-YgM)

### `void _ChangeCurrentItemMaterial(bool Next)`

> If the Current Item has an [Material Changer](/animal-controller/utilities/material-changer.md) component, it change **ALL** the Material-Item on the list to the Next(true) or Before(false). If the Selector is using a Data file, it will update the SaveData.
>
> **If the Item is using only one Material-Item, use this method instead of the ones listed below.**

(GIF Example)

### `void _ChangeCurrentItemMaterial(string Name)`

> If the Current Item has an [Material Changer](/animal-controller/utilities/material-changer.md) component, it change an Active Material on the list to the Next Material using the Material-Item “Name”.
>
> If the Selector is using a Data file, it will update the SaveData.

(GIF Example)

### `void _ChangeCurrentItemMaterial(string Name, bool Next)`

> If the Current Item has an [Material Changer](/animal-controller/utilities/material-changer.md) component, it change an Active Material on the list to the Next(**true**) Before(**false**) Material using the Material-Item “Name”.
>
> If the Selector is using a Data file, it will update the SaveData.

(GIF Example)

### `void _ChangeCurrentItemMaterial(int Index)`

> If the Current Item has an [Material Changer](/animal-controller/utilities/material-changer.md) component, it change an Active Material on the list to the Next Material using the Material Item “Index”.
>
> If the Selector is using a Data file, it will update the SaveData.

(GIF Example)

### `void _ChangeCurrentItemMaterial(int Index, bool Next)`

> If the Current Item has an [Material Changer](/animal-controller/utilities/material-changer.md) component, it change an Active Material on the list to the Next(true) Before(false) Material using the Material Item “Index”.
>
> If the Selector is using a Data file, it will update the SaveData.

(GIF Example)

### `void _ChangeCurrentItemMaterial(bool Next)`

> If the Current Item has an [ActiveMeshes](/animal-controller/utilities/active-meshes.md) component, it change **ALL** the Active Mesh items on the list to the Next(true) or Before(false).
>
> If the Selector is using a Data file, it will update the SaveData.
>
> **If the Item is using only one Active-Mesh, use this method instead of the ones listed below.**

(GIF Example)

### `void _ChangeCurrentItemMesh(int Index)`

> If the Current Item has an [ActiveMeshes](/animal-controller/utilities/active-meshes.md) component, it change an Active Mesh on the list to the Next Mesh using their “Index”.
>
> If the Selector is using a Data file, it will update the SaveData.

### `void _ChangeCurrentItemMesh(int Index, bool Next)`

> If the Current Item has an [ActiveMeshes](/animal-controller/utilities/active-meshes.md) component, it change an Active Mesh on the list to the Next Mesh using their “Index”.
>
> If the Selector is using a Data file, it will update the SaveData.

### `void _ChangeCurrentItemMesh(string Name)`

> If the Current Item has an [ActiveMeshes](/animal-controller/utilities/active-meshes.md) component, it change an Active Mesh on the list to the Next Mesh using the Active-Mesh “Name”.
>
> If the Selector is using a Data file, it will update the SaveData.

### `void _ChangeCurrentItemMesh(string Name, bool Next)`

> If the Current Item has an [ActiveMeshes](/animal-controller/utilities/active-meshes.md) component, it change an Active Mesh on the list to the Next(true) Before(false) Mesh using the Active-Mesh “Name”.
>
> If the Selector is using a Data file, it will update the SaveData.

### `void _ChangeToScene(string SceneName)`

> Change to the next scene using the scene name

### `void _ChangeToScene(string SceneIndex)`

> Change to the next scene using the scene index

### `void AddItem(MItem item)`

> Adds an Item at Runtime.
>
> :warning: Save data won’t work with runtime adding items

### **`void AddItem(GameObject item)`**

> Adds an Item at Runtime, if the Item does not have an [MItem](/animal-controller/ultimate-selector/selector-item.md) component on it it will add it

### `void _RemoveItem(MItem item)`

> Removes an Item at Runtime.
>
> :warning: Save data won’t work with runtime adding items

### `void _RemoveItem(string Name)`

> Removes an Item at Runtime Using the Items “Name”
>
> :warning: Save data won’t work with runtime adding items

### `void _RemoveItem(int Index)`

> Removes an Item at Runtime Using the Items “Index”
>
> :warning: Save data won’t work with runtime adding items


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://malbersanimations.gitbook.io/animal-controller/ultimate-selector/selector-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
