84 lines
2.0 KiB
C#
84 lines
2.0 KiB
C#
|
|
using System.Threading.Tasks;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class AgreementsPolicesPanel : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
[SerializeField]
|
|
private Button aggreementBtn;
|
|
|
|
[SerializeField]
|
|
private Button quitBtn;
|
|
|
|
[SerializeField]
|
|
private TMP_Text title;
|
|
|
|
[SerializeField]
|
|
private TMP_Text text;
|
|
|
|
private const string prf_key = "AgreementsPolicesPanel";
|
|
|
|
|
|
void OnDisable()
|
|
{
|
|
aggreementBtn.onClick.RemoveAllListeners();
|
|
quitBtn.onClick.RemoveAllListeners();
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
int linkIndex = TMP_TextUtilities.FindNearestLink(text, Input.mousePosition, null);
|
|
if (linkIndex != -1)
|
|
{
|
|
TMP_LinkInfo linkInfo = text.textInfo.linkInfo[linkIndex];
|
|
var linkID = linkInfo.GetLinkID();
|
|
Debug.Log(linkInfo.GetLinkID());
|
|
Debug.Log(linkInfo.GetLinkText());
|
|
if (linkID == "Privacy")
|
|
{
|
|
#if UNITY_IOS
|
|
linkID = GConstant.V_IOS_Privacy_Policy_URL;
|
|
#else
|
|
linkID = GConstant.V_Android_Privacy_Policy_URL;
|
|
#endif
|
|
}
|
|
|
|
Application.OpenURL(linkID);
|
|
}
|
|
}
|
|
|
|
private void OnAggreementBtnClicked()
|
|
{
|
|
Debug.Log("OnaggreementBtnClicked");
|
|
}
|
|
|
|
public async Task<bool> Agreement()
|
|
{
|
|
if(PlayerPrefs.HasKey(prf_key))
|
|
return true;
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
var taskSource = new TaskCompletionSource<bool>();
|
|
|
|
aggreementBtn.onClick.AddListener(() =>
|
|
{
|
|
PlayerPrefs.SetInt(prf_key, 1);
|
|
taskSource.SetResult(true);
|
|
});
|
|
|
|
quitBtn.onClick.AddListener(() => taskSource.SetResult(false));
|
|
|
|
var aggree = await taskSource.Task;
|
|
|
|
aggreementBtn.onClick.RemoveAllListeners();
|
|
quitBtn.onClick.RemoveAllListeners();
|
|
gameObject.SetActive(false);
|
|
|
|
return aggree;
|
|
}
|
|
}
|