备份CatanBuilding瘦身独立工程
This commit is contained in:
81
Assets/Scripts/AOTScripts/AgreementsPolicesPanel.cs
Normal file
81
Assets/Scripts/AOTScripts/AgreementsPolicesPanel.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
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();
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user