123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using UnityEngine;
- using System.Collections;
- using TMPro;
- /// <summary>
- /// This component is responsible to capture the ClientUpdateAvailable notification and display it to the user.
- /// If the VersionInfo is flagged as forceUpdate, then the close button is removed, so the user can only click the Update button.
- ///
- /// This component should be placed on an active gameObject in the hierarchy. It will disable itself on Awake but will
- /// listen for the ClientUpdateAvailable notification.
- /// </summary>
- public class VersionUpdateUINotification : MonoBehaviour
- {
- public TextMeshProUGUI whatsNewLabel;
- public GameObject closeButton;
- void Awake()
- {
- CoreNotificationCenter.AddListener(OnClientUpdateAvailable, CoreNotificationType.ClientUpdateAvailable);
- gameObject.SetActive(false);
- }
- void OnDestroy()
- {
- CoreNotificationCenter.RemoveListener(OnClientUpdateAvailable, CoreNotificationType.ClientUpdateAvailable);
- }
- void OnClientUpdateAvailable(CoreNotification note)
- {
- VersionInfo versionInfo = (VersionInfo)note.data;
- Show(versionInfo.whatsNew, versionInfo.forceUpdate);
- }
- void Show(string whatsNew, bool forceUpdate)
- {
- GetComponent<ScreenBase>().Show();
- whatsNewLabel.text = whatsNew;
- if (forceUpdate)
- {
- closeButton.SetActive(false);
- }
- }
- public void OnUpdateClickMsg()
- {
- Application.OpenURL(GameConstants.APP_STORE_URL);
- }
- }
|