Sample of Inbox(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
Open the project and you will see the above.
Run it and you will see a screen with nothing at the top and a menu at the bottom.
Press the “Send” button three times from the menu.
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.
Now press the “Send With Expire” button from the menu.
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.
The expired message will no longer appear on its own.
Next, press the “Read” button in the middle of the three messages.
The Read button will be grayed out for messages you have already read.
Project Description
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.
This time, the namespace inbox-0001 of GS2-Inbox is specified.
Canvas/InboxWindow/Inbox/…/Content
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.
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
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.
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
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
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
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
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
You can add a prefab from this context menu.
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
Gs2ExchangeRateModelContext
Set the GS2-Exchange exchange rate at which GS2-Inbox messages are sent.
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
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.