从poco项目中下载了unity3D脚本放置在unity的Project中,但是发现poco无法获取TextMashPro组件文本,查阅大量资料,踩了许多坑,终于解决这个问题,开心!
解决方法:
- 在unity项目中放置unity3D脚本,unity3D脚本删除fairygui和ngui这两个文件夹,保留ugui
- 使用Visual Studio Code打开ugui文件夹中的UnityNode.cs脚本
- 使用TextMeshPro类
using System; using System.Collections.Generic; using UnityEngine.UI; using UnityEngine; using TMPro;
4、
public static DictionaryTypeNames = new Dictionary () { { "TMP_Text", "TMP_Text" }, { "Gradient Text", "Gradient.Text" }, { "Image", "Image" }, { "RawImage", "Raw.Image" }, { "Mask", "Mask" }, { "2DRectMask", "2D-Rect.Mask" }, { "Button", "Button" }, { "InputField", "InputField" }, { "Toggle", "Toggle" }, { "Toggle Group", "ToggleGroup" }, { "Slider", "Slider" }, { "ScrollBar", "ScrollBar" }, { "DropDown", "DropDown" }, { "ScrollRect", "ScrollRect" }, { "Selectable", "Selectable" }, { "Camera", "Camera" }, { "RectTransform", "Node" }, };
- 获取TextMashPro组件文本
private string GameObjectText()
{
///Text text = gameObject.GetComponent();
///return text ? text.text : null;
TMP_Text text = gameObject.GetComponent();
return text ? text.text : null;
}



