Sample of Showcase(GS2 UIKit for Unity)
This sample reflects the in-game store managed by GS2-Showcase in the UI.
Folder structure
Sample folder :
(Unity project)/Assets/Game Server Services/Samples/UIKit/Gs2Showcase/
Sample scenes :
(Unity Project)/Assets/Game Server Services/Samples/UIKit/Gs2Showcase/Scenes/Showcase.unity
This sample relies on the following prefab Fields in the prefab need to be configured.
- Gs2
- Gs2AccountAutoLogin
GS2-Deploy Sample Template:
(Unity project)/Assets/Game Server Services/Samples/UIKit/Gs2Showcase/Settings/initialize_showcase_template.yaml
Explanation
Gs2ShowcaseShowcase
This component reflects the items displayed on the showcase in the UI. It retrieves a list of products displayed on the specified display shelf, materializes the Prefab specified in DisplayItemPrefab for each product, and populates the UI with the Transformations specified in PopulateNode. The Prefab specified in DisplayItemPrefab is materialized for each item and registered as a child of the Transform specified in PopulateNode.
Gs2ShowcaseDisplayItem
This component is specified as the root hierarchy of the Prefab that is created for each item registered in the display shelf. This component implements the void Buy() method, which can be called to purchase products. In this sample, this method is called in the OnClick event of the Button.
Since the Buy method invokes a coroutine to execute the purchase process, it is necessary to deactivate the button after pressing it to prevent multiple invocations of the coroutine. This component can register an OnBuyComplete event that will fire an event when the purchase process is complete. This event can be handled to transition to the post-purchase sequence or to re-activate the button.