> For the complete documentation index, see [llms.txt](/llms.txt)

# Sample of Dictionary(GS2 UIKit for Unity)

sample implementation of GS2-Dictionary functionality using GS2 UIKit for Unity



Implement the Pictorial Book function.

## Repository

https://github.com/gs2io/gs2-uikit-for-unity-sample/tree/main/Dictionary

## GS2-Deploy template

https://github.com/gs2io/gs2-uikit-for-unity-sample/blob/main/Dictionary/initialize_dictionary_template.yaml

## Project Description

![img.png](img.png)

Open the project and you will see the above.

![img_1.png](img_1.png)

Run it and you will see the availability of the 5 characters from A to E.
Since none of the characters have been obtained now, they are all grayed out.

![img_2.png](img_2.png)

The buttons to obtain each character are placed at the bottom of the screen.
First, let's press the "A" button.

![img_3.png](img_3.png)

Having obtained the "A" character, it will be displayed in color and the time of obtaining it will be displayed.
Let's press the "C" button as well.

![img_4.png](img_4.png)

The "C" character will also be displayed in color.

## Project Description

![img_5.png](img_5.png)

Note the hierarchy of the scene.

### Canvas/DictionaryWindow

![img_6.png](img_6.png)

**Gs2DictionaryNamespaceContext**

Specifies the namespace to be handled by the node under this GameObject.

![img_7.png](img_7.png)

This time, dictionary-0001 is specified.

### Canvas/DictionaryWindow/Dictionary/.../Content

![img_8.png](img_8.png)

**Gs2DictionaryEntryModelListFetcher**

Gets the entry model list for the namespace specified by NamespaceContext.

**Gs2DictionaryEntryModelList**

Generates the entry models obtained by Gs2DictionaryEntryModelListFetcher by assigning them to the specified prefab.
Specify the maximum number of prefabs to generate for Maximum Items.

![img_9.png](img_9.png)

This time, the Entry in the child node is specified as the prefab.
If the GameObject specified as a prefab is in the scene, that GameObject will be disabled and the number of GameObjects specified in Maximum Items will be created in addition to the GameObjects specified as prefabs.

### Canvas/DictionaryWindow/Dictionary/.../Content/Entry

![img_10.png](img_10.png)

**Gs2DictionaryEntryModelContext**

Specifies the entry to be handled by the node under this GameObject.
The content of the context is assigned by Gs2DictionaryEntryModelList.

**Gs2DictionaryEntryModelFetcher**

Gets the model for the entry specified by Gs2DictionaryEntryModelContext.

**Gs2DictionaryOwnEntryFetcher**

Gets the own entry of the entry model specified in Gs2DictionaryEntryModelContext.

**Gs2DictionaryEntryEnabler**

Enables a GameObject to display the date and time it was obtained, depending on the Entry's loading status.
If the Entry is not obtained, it will not be Loaded and will only be enabled if it is obtained.

**Gs2DictionaryEntryModelEnabler**.

Enables a GameObject that displays the name of the entry depending on the EntryModel loading status.

### Canvas/DictionaryWindow/Dictionary/.../Content/Entry/Icon

Displays the icon image of the character.
However, the type of image displayed must vary depending on the entry to be listed.

![img_11.png](img_11.png)

**Gs2DictionaryEntryModelNameEnabler**

Enables or disables GameObjects according to the name of the entry model obtained by Gs2DictionaryEntryModelFetcher.
In the sample, five entry models are placed, and only the entry node corresponding to "A" to "E" is set to be enabled.

### Canvas/DictionaryWindow/Dictionary/.../Content/Entry/Icon/A

GameObjects "A" to "E" are set, but in principle they have the same structure.

![img_12.png](img_12.png)

It branches in the same way as the part that displays the date and time of acquisition, enabling Active if it has been acquired and Disabled if it has not been acquired.

#### Canvas/DictionaryWindow/Dictionary/.../Content/Entry/Icon/A/Active

![img_13.png](img_13.png)

#### Canvas/DictionaryWindow/Dictionary/.../Content/Entry/Icon/A/Disabled

![img_14.png](img_14.png)

In Disabled, GrayScaleMaterial is specified for Material, which uses shaders to gray out the image.

### Canvas/DictionaryWindow/Dictionary/.../Content/Entry/Name

Displays the name of the entry model.

![img_15.png](img_15.png)

**Gs2DictionaryEntryModelLabel**.

Formats the contents of the entry model in the format specified by Format.
The formatted text is called back to OnUpdate(String), from which the value is reflected in the Text component.

### Canvas/DictionaryWindow/Dictionary/.../Content/Entry/AcquiredAt

Displays the date and time the entry was obtained.

**Gs2DictionaryOwnEntryLabel**.

Formats the entry content in the format specified by Format.
The formatted text is called back to OnUpdate(String), from which the value is reflected in the Text component.

![img_16.png](img_16.png)

### Canvas/DictionaryWindow/Input/Acquire A

![img_17.png](img_17.png)

**Gs2ExchangeRateModelContext**

Sets the GS2-Exchange exchange rate at which the entry will be made available.

![img_19.png](img_19.png)
![img_18.png](img_18.png)

Here, the A-rate model in the exchange-0004 namespace of GS2-Exchange is set to exchange.

### Canvas/DictionaryWindow/Input/Acquire A/Gs2ExchangeExchangeAction

![img_20.png](img_20.png)

You can add a prefab from this context menu.

![img_21.png](img_21.png)

By specifying the exchange quantity in Count and activating the prefab, the exchange rate specified in Gs2ExchangeRateModelContext will be executed.

**OnExchangeComplete(String)**

can be set to a callback when the exchange process is successfully completed, and disables itself.

### Process/Gs2AutoLogin

A prefab is set up to perform the login process.

[sample of Account](), please refer to the explanation there.




