public Transform _uiRootTran;
?
_uiRootTran = GameObject.FindGameObjectWithTag("UICanvas").transform;
var nameTxtObj = new GameObject(); nameTxtObj.transform.SetParent(_uiRootTran); var rect2 = nameTxtObj.AddComponent<RectTransform>(); rect2.anchorMin = new Vector2(0.5f, 0.5f);//锚点 rect2.anchorMax = new Vector2(0.5f, 0.5f); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? rect2.sizeDelta = new Vector2(260, 80);//尺寸 ?rect2.localPosition = new Vector3(0, 100, 0);//坐标
var label = nameTxtObj.AddComponent<Text>(); label.color = new Color(0, 1, 0, 1); label.text = "88888"; label.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; //label.fontStyle = FontStyle.Bold;
label.fontSize = 60;
|