text里面设置这个字符串 publicvoidOnPointerClick(PointerEventData eventData) {intlinkIndex =TMP_TextUtilities.FindIntersectingLink(_desText, Input.mousePosition, eventData.pressEventCamera);if(_desText.textInfo.linkInfo.Length ==0)return; TMP_LinkInfo linkInfo=_desText.textInfo.linkInfo[linkIndex]; RectTra...
Unity心得-1 1.Application.persistentDataPath 沙盘路径,在ios平台下用UnityWebRequest方法获取的时候,要在路径前加 "file://"。在用File.Exists()方法判断路径是否存在时,不能加"file://"。 2.接口可以跨dll 抽象类不行 3.TMP_TextUtilities.FindIntersectingLink返回带link的文本在总文本的搜索索引 4.Tween有个...
例如,你可以创建一个实现了IPointerClickHandler接口的脚本,并将其挂载到TMPText元素上。在脚本中,你可以使用TMP_TextUtilities.FindIntersectingLink方法来检测点击事件是否发生在超链接上,并据此执行相应的操作(如打开URL)。 通过以上步骤,你就可以在Unity项目中使用TMPText来显示富文本了。
int linkIndex = TMP_TextUtilities.FindIntersectingLink(textMeshProUGUI, Input.mousePosition, null); if (linkIndex != -1) { TMP_LinkInfo linkInfo = textMeshProUGUI.textInfo.linkInfo[linkIndex]; string url = linkInfo.GetLinkID(); Application.OpenURL(url); } } } 在Unity 界面上点中此脚本,拖...
public static int FindIntersectingLine(TMP_Text text, Vector3 position, Camera camera)ParametersTypeNameDescription TMP_Text text Vector3 position Camera camera ReturnsTypeDescription Int32 FindIntersectingLink(TMP_Text, Vector3, Camera)Function returning the index of the Link at the given position ...
TextMeshProUGUIpTextMeshPro=GetComponent<TextMeshProUGUI>(); 11+ intlinkIndex= 12+ TMP_TextUtilities.FindIntersectingLink(pTextMeshPro,eventData.position, 13+ null);// If you are not in a Canvas using Screen Overlay, put your camera instead of null ...
public static int FindIntersectingLine(TMP_Text text, Vector3 position, Camera camera)ParametersTypeNameDescription TMP_Text text Vector3 position Camera camera ReturnsTypeDescription Int32 FindIntersectingLink(TMP_Text, Vector3, Camera)Function returning the index of the Link at the given position ...
public static int FindIntersectingLine(TMP_Text text, Vector3 position, Camera camera)ParametersTypeNameDescription TMP_Text text Vector3 position Camera camera ReturnsTypeDescription Int32 FindIntersectingLink(TMP_Text, Vector3, Camera)Function returning the index of the Link at the given position ...