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.

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' and save the data there, but is recommended to use a better and secure 'Saving System'

Coins

Total of coins for the selector.

Use PlayerPref to Save Data

Enable it to persistent save the Data using PlayerPref 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 and ActiveMeshes, 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() 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 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 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 Event. so when the item is selected also reduce by one the item.

void SaveDefaultData()

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()

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

...or by the OnClick/Touch an Item Event from the Selector Controller. (See Demo: BoxRadialScreen)

void _ChangeCurrentItemMaterial(bool Next)

If the Current Item has an Material Changer 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 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 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 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 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 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 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 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 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 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.

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 component on it it will add it

void _RemoveItem(MItem item)

Removes an Item at Runtime.

Save data won’t work with runtime adding items

void _RemoveItem(string Name)

Removes an Item at Runtime Using the Items “Name”

Save data won’t work with runtime adding items

void _RemoveItem(int Index)

Removes an Item at Runtime Using the Items “Index”

Save data won’t work with runtime adding items