LinkText组件更新
parent
350d1b2cc9
commit
20cc18b85c
|
|
@ -51,4 +51,27 @@ public class LinkText : MonoBehaviour, IPointerClickHandler
|
|||
otherAreaClickAction?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置含超链接跳转<link>的文本
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
public void SetText(string text)
|
||||
{
|
||||
TMP_Text pTextMeshPro = GetComponent<TMP_Text>();
|
||||
pTextMeshPro.text = text;
|
||||
|
||||
string pattern = "<link=\"(.*?)\">(.*?)</link>";
|
||||
System.Text.RegularExpressions.MatchCollection matches = System.Text.RegularExpressions.Regex.Matches(text, pattern);
|
||||
|
||||
List<UnityAction> LinkActions = new();
|
||||
foreach (System.Text.RegularExpressions.Match match in matches)
|
||||
{
|
||||
string linkID = match.Groups[1].Value;
|
||||
string linkText = match.Groups[2].Value;
|
||||
|
||||
LinkActions.Add(() => Application.OpenURL(linkID));
|
||||
}
|
||||
SetLinkAction(LinkActions);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,24 +161,14 @@ public class UI_StartGameInterfaceController : UIWindow
|
|||
}
|
||||
else
|
||||
{
|
||||
linkText.SetLinkAction(new System.Collections.Generic.List<UnityAction>()
|
||||
{
|
||||
() =>
|
||||
{
|
||||
Application.OpenURL("https://kedrgame.com/user_agreement.txt");
|
||||
//CallAction(Gameplay.Net.AppConfig.Instance.LoginURL + "agreements");
|
||||
},
|
||||
() =>
|
||||
{
|
||||
Application.OpenURL("https://kedrgame.com/privacy_agreement.txt");
|
||||
//CallAction(Gameplay.Net.AppConfig.Instance.LoginURL + "agreements");
|
||||
},
|
||||
() =>
|
||||
{
|
||||
Application.OpenURL("https://kedrgame.com/children_privacy_agreement.txt");
|
||||
//CallAction(Gameplay.Net.AppConfig.Instance.LoginURL + "agreements");
|
||||
},
|
||||
});
|
||||
string url1= "https://kedrgame.com/user_agreement.txt";
|
||||
string url2 = "https://kedrgame.com/privacy_agreement.txt";
|
||||
string url3 = "https://kedrgame.com/children_privacy_agreement.txt";
|
||||
string content = string.Format("我已详细阅读并同意<link=\"{0}\"><u>《许可服务协议》</u></link> " +
|
||||
"<link=\"{1}\"><u>《隐私政策》</u></link>" +
|
||||
"和<link=\"{2}\"><u>《儿童信息及隐私保护政策》</u></link>",
|
||||
url1, url2, url3);
|
||||
linkText.SetText(content);
|
||||
}
|
||||
linkText.SetOtherAreaClicked(() => agreement.isOn = !agreement.isOn);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue