collection ui elements
Tools utilities

Collection UI Elements

A quick and easy way to collect your user interface elements into one collection and then get objects by their name or by index. Add your own element types.

Documentation

Getting Started

To use a collection, you need to add the “Collection UI Elements” script to the object.

 

 

It is recommended to add UI elements to the parent object. In this case, the “Menu” object.

Collection of UI elements
Collection of UI elements
Collection of UI elements

This component is the main link in working with the asset. 

  • The “Menu” button will open a window with additional functions of the asset (Also can be called through the tool menu Window -> NMe8 -> Menu Collection UI). 
  • Show warning info – whether messages will be shown to the console when a failure occurs during the operation of this component (Other components have their own switch).
  • Generate enum – a class that describes the TagName fields. After the class has been generated, it will be possible to regenerate it.
  • When the collection is empty, two buttons with search for objects will be offered.
    • All – searches for all objects within itself
    • Smart – will search for all objects, but if the type of an object does not allow searching within itself, then it will skip its children and move on (Skipping children is configured in the Menu Collection UI).
  • Add Element – will add an empty slot where you can change TagName, Type and GameObject.
  • Remove slots with Null Object – it is clear from the name that it will remove the slot in which the object will not be specified.
  • Remove ALL – clears the collection.

A slot in a collection has three fields.

  • TagName – the name of the slot, the name can be repeated and have different objects, but keep this in mind if you need it.
  • Type – standard types for UI, but you can change them and add your own to the “Menu UI Element”
  • GameObject – an object in the form of a Transform. It can be selected from the list of children by clicking on the “Choose” button and selecting the one you need from the drop-down list, then click on “Select” to confirm the choice.
Collection of UI elements

Menu Collection UI

Collection of UI elements

To generate a class with an enumeration of slot names, select a collection for which the list will be created and a name by which it will be possible to refer to the slot name (The enumeration itself stores the name of the slot, but not the object). Then click generate.

 

Working with an enum is to remove it (may change in the future).

 

Type Support – types by which objects will be searched and maybe something else later.

  • The index shows in which queue the object will be checked for type.
  • The name will be shown in the drop down list.
  • Type is the full name of the class (for Text it is UnityEngine.UI.Text).
  • Skip children indicates whether smart search will add children of this type to the collection.

For example Let’s add CollectionUIElements to types. To do this, click on the add custom type button. He appeared at the very top of the list. Let’s give it a name and type: We specify the name in Latin letters, since I used the namespace, I also indicated it “NMe8.CollectionUIElements” and after the “CollectionUIElements” class itself. I will not ignore children, since this class hangs on the first object when searching. Now you can save (Unity will generate the file and check all the files, it takes 5 seconds). If you remove the type, the slots in the collection that have that type will take on the standard GameObject type.

Collection of UI elements

First you need to add using NMe8.CollectionUIElements. then we declare a CollectionUIElements variable to refer to a particular collection of elements.
And now, through our new variable, we can access methods.

Collection UI Elements