82 lines
1.8 KiB
C#
82 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SavesConflictPopupManager : MonoBehaviour
|
|
{
|
|
public delegate void LoadCloudButtonClickEvent();
|
|
|
|
public delegate void UseLocalButtonClickEvent();
|
|
|
|
public delegate void DoNothingButtonClickEvent();
|
|
|
|
[SerializeField]
|
|
private Button UsePrefsSaveButton;
|
|
|
|
[SerializeField]
|
|
private Button LoadCloudButton;
|
|
|
|
[SerializeField]
|
|
private Button DoNothingButton;
|
|
|
|
[SerializeField]
|
|
private Text PopupDescription;
|
|
|
|
public static event LoadCloudButtonClickEvent OnLoadCloudButtonClick;
|
|
|
|
public static event UseLocalButtonClickEvent OnUsePrefsButtonClick;
|
|
|
|
public static event DoNothingButtonClickEvent OnDoNothingButtonClick;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (LoadCloudButton != null)
|
|
{
|
|
LoadCloudButton.onClick.AddListener(InvokeLoadCloudButtonClickEvent);
|
|
}
|
|
if (UsePrefsSaveButton != null)
|
|
{
|
|
UsePrefsSaveButton.onClick.AddListener(InvokeUseLocalButtonClickEvent);
|
|
}
|
|
if (DoNothingButton != null)
|
|
{
|
|
DoNothingButton.onClick.AddListener(InvokeDoNothingButtonClickEvent);
|
|
}
|
|
}
|
|
|
|
public void SetPopupDescription(string description)
|
|
{
|
|
PopupDescription.text = description;
|
|
}
|
|
|
|
private void InvokeLoadCloudButtonClickEvent()
|
|
{
|
|
SavesConflictPopupManager.OnLoadCloudButtonClick?.Invoke();
|
|
}
|
|
|
|
private void InvokeUseLocalButtonClickEvent()
|
|
{
|
|
SavesConflictPopupManager.OnUsePrefsButtonClick?.Invoke();
|
|
}
|
|
|
|
private void InvokeDoNothingButtonClickEvent()
|
|
{
|
|
SavesConflictPopupManager.OnDoNothingButtonClick?.Invoke();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if (LoadCloudButton != null)
|
|
{
|
|
LoadCloudButton.onClick.RemoveAllListeners();
|
|
}
|
|
if (UsePrefsSaveButton != null)
|
|
{
|
|
UsePrefsSaveButton.onClick.RemoveAllListeners();
|
|
}
|
|
if (DoNothingButton != null)
|
|
{
|
|
DoNothingButton.onClick.RemoveAllListeners();
|
|
}
|
|
}
|
|
}
|