Sample of Stamina(GS2 UIKit for Unity)
Implement the Stamina function.
Repository
https://github.com/gs2io/gs2-uikit-for-unity-sample/tree/main/Stamina
GS2-Deploy template
Project Description
Open the project and you will see the above.
When executed, the remaining amount of stamina and the UI for stamina operations will be displayed as shown here.
First, click the “Consume(5)” button.
Having consumed stamina, the remaining amount is displayed as “45/50” and a countdown is shown until it is recovered.
Next, click the “Recover(10)” button.
The remaining amount of stamina will be “55/50”. The countdown will not be displayed again because the maximum value has been exceeded.
Project Description
Note the hierarchy of the scene.
Canvas/StaminaWindow
Gs2StaminaOwnStaminaContext
Specifies the stamina of GS2-Stamina handled by the node under this GameObject.
In this case, we specify a stamina named Stamina in the namespace stamina-0001 of GS2-Stamina.
Canvas/StaminaWindow/Stamina.
Gs2StaminaStaminaEnabler
After loading the Stamina, activate StaminaValue.
Canvas/StaminaWindow/Stamina/StaminaValue/Slider
Gs2StaminaStaminaProgress.
Gets the percentage of the current stamina value relative to the maximum value, from 0.0 to 1.0. The value is rounded to 1.0 when the maximum value is exceeded.
The result obtained is passed to OnUpdate(Single) and reflected in the Slider value.
Canvas/StaminaWindow/Stamina/StaminaValue/Slider/Label
Gs2StaminaStaminaValueEnabler.
Enables a GameObject based on whether the maximum value of stamina has been reached.
Canvas/StaminaWindow/Stamina/StaminaValue/Slider/Label/NextRecoverAt
Gs2StaminaStaminaNextRecoverAtFetcher.
Gets the date and time when stamina will be restored next time. The result is called back to OnUpdate(int64) and the value is reflected in Gs2CoreTimeSpanLabel.
Gs2CoreTimeSpanLabel.
Formats the remaining time until the next recovery of stamina into the format specified by Format. The formatted text is called back to OnUpdate(String), from which the value is reflected in the Text component.
Process/Gs2AutoLogin
A prefab is set up to perform the login process.
sample of Account, please refer to the explanation there.