Sample of Inbox(GS2 UIKit for Unity)

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

Implement the present box functionality.

Repository

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

GS2-Deploy template

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

Project Description

img.png

Open the project and you will see the above.

img_1.png

Run it and you will see a screen with nothing at the top and a menu at the bottom.

img_2.png

Press the “Send” button three times from the menu.

img_3.png

Three messages are displayed in the list. The top part of the screen shows the list of messages received in the gift box like this.

img_2.png

Now press the “Send With Expire” button from the menu.

img_4.png

A list of newly expired messages is displayed in the message list. The date and time are shown in two lines, the upper one is the received date and the lower one is the expiration date. The expiration date is set to one minute after the received date and time.

Please wait for one minute.

img_5.png

The expired message will no longer appear on its own.

Next, press the “Read” button in the middle of the three messages.

img_6.png

The Read button will be grayed out for messages you have already read.

Project Description

img_7.png

Note the hierarchy of the scene.

Canvas/InboxWindow.

Gs2InboxNamespaceContext

Specifies the namespace of the GS2-Inbox to be handled by the node under this GameObject.

img_8.png

This time, the namespace inbox-0001 of GS2-Inbox is specified.

Canvas/InboxWindow/Inbox/…/Content

img_9.png

Gs2InboxOwnMessageListFetcher.

Get a list of messages in the namespace specified by NamespaceContext.

Gs2InboxOwnMessageList

Generates a list of messages obtained by Gs2InboxOwnMessageListFetcher by assigning them to the specified prefab. Maximum Items specifies the maximum number of prefabs to be generated.

img_10.png

This time, Message in the child node is specified as a prefab. If a GameObject specified as a prefab exists 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/InboxWindow/Inbox/…/Content/Message

img_11.png

Gs2InboxOwnMessageContext

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

Gs2InboxOwnMessageFetcher.

Gets the message specified by Gs2InboxOwnMessageContext.

Canvas/InboxWindow/Inbox/…/Content/Message/Metadata

Display the payload of the message.

img_12.png

Gs2InboxMessageLabel.

Format the message 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/InboxWindow/Inbox/…/Content/Message/Timestamp

img_13.png

Gs2InboxMessageExpiresAtEnabler.

Controls whether to show or hide a message based on the expiration time value set in the message. If the expiration date is set, ExpiresAt is set to enable.

Canvas/InboxWindow/Inbox/…/Content/Message/Timestamp/ReceivedAt

Gs2InboxMessageLabel

img_14.png

The date and time the message was received are displayed. The formatting method is specified in Format, The formatted text is called back to OnUpdate(String), from which the value is reflected in the Text component.

Canvas/InboxWindow/Inbox/…/Content/Message/Timestamp/ExpiresAt.

Gs2InboxMessageLabel

img_14.png

Message expiration date is displayed. The formatting method is specified in Format, The formatted text is called back to OnUpdate(String), from which the value is reflected in the Text component.

Canvas/InboxWindow/Inbox/…/Content/Message/Control

img_15.png

Gs2InboxMessageIsReadEnabler.

Controls whether to show or hide the message based on the read status of the message. If the message is unread, Read is enabled; if the message is read, AlreadyRead is enabled.

Canvas/InboxWindow/Inbox/…/Content/Message/Control/Gs2InboxMessageReadAction

img_16.png

You can add a prefab from this context menu.

img_17.png

Enabling the prefab makes the message specified in Gs2InboxOwnMessageContext readable.

OnReadComplete(String)

can be set to a callback when read-completion is successfully completed, and disables itself.

Canvas/InboxWindow/Input/Send

img_18.png

Gs2ExchangeRateModelContext

Set the GS2-Exchange exchange rate at which GS2-Inbox messages are sent.

img_20.png img_19.png

Here, the exchange rate named SendMessage in the namespace named exchange-0002 of GS2-Exchange is specified.

Canvas/ExperienceWindow/Input/Send/Gs2ExchangeExchangeAction

Specify the exchange quantity in Count and activate the prefab to perform the exchange of the exchange rate specified in Gs2ExchangeRateModelContext.

OnExchangeComplete(String)

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

Canvas/InboxWindow/Input/Send With Expire

img_21.png

Gs2ExchangeRateModelContext

Sets the GS2-Exchange exchange rate at which GS2-Inbox expiration month messages are sent.

Here, the exchange rate named SendMessageWithExpire in the namespace named exchange-0002 of GS2-Exchange is specified.

Canvas/ExperienceWindow/Input/Send With Expire/Gs2ExchangeExchangeAction

Specify the exchange quantity in Count and activate the prefab to perform the exchange at the exchange rate specified in Gs2ExchangeRateModelContext.

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.