Sample of Dictionary(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
Project Description
Open the project and you will see the above.
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.
The buttons to obtain each character are placed at the bottom of the screen. First, let’s press the “A” button.
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.
The “C” character will also be displayed in color.
Project Description
Note the hierarchy of the scene.
Canvas/DictionaryWindow
Gs2DictionaryNamespaceContext
Specifies the namespace to be handled by the node under this GameObject.
This time, dictionary-0001 is specified.
Canvas/DictionaryWindow/Dictionary/…/Content
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.
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
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.
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.
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
Canvas/DictionaryWindow/Dictionary/…/Content/Entry/Icon/A/Disabled
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.
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.
Gs2DictionaryEntryLabel.
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.
Canvas/DictionaryWindow/Input/Acquire A
Gs2ExchangeRateModelContext
Sets the GS2-Exchange exchange rate at which the entry will be made available.
Here, the A-rate model in the exchange-0004 namespace of GS2-Exchange is set to exchange.
Canvas/DictionaryWindow/Input/Acquire A/Gs2ExchangeExchangeAction
You can add a prefab from this context menu.
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.