Compare commits

...

2 Commits

2 changed files with 15 additions and 5 deletions

View File

@ -1,6 +1,8 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
//public class Union //public class Union
//{ //{
@ -25,14 +27,21 @@ public class TradeDes : MonoBehaviour
public string updateTime; public string updateTime;
//公会相关组件 //公会相关组件
public Button sqBtn;//申请按钮
public TextMeshProUGUI nameTxt;//名称text
//public TextMeshPro countTxt;//数量Text
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Awake()
{ {
sqBtn = transform.Find("Button").GetComponent<Button>();
nameTxt = transform.Find("name").GetComponent<TextMeshProUGUI>();
if (sqBtn == null)
Debug.LogError("申请按钮未找到!");
if (nameTxt == null)
Debug.LogError("名称 TextMeshPro 组件未找到!");
} }
// Update is called once per frame // Update is called once per frame
@ -52,6 +61,7 @@ public class TradeDes : MonoBehaviour
leaderUserName = body.LeaderUserName; leaderUserName = body.LeaderUserName;
createTime = body.CreateTime; createTime = body.CreateTime;
updateTime = body.UpdateTime; updateTime = body.UpdateTime;
nameTxt.text = name;
} }
} }

View File

@ -28,7 +28,7 @@ public class TradeUnion : MonoBehaviour
{ {
GameObject union = GameObject.Instantiate(gonghuiPrefab, content); GameObject union = GameObject.Instantiate(gonghuiPrefab, content);
union.name = "union_" + i; union.name = "union_" + i;
//这里动态挂载公会脚本 //这里动态挂载公会脚本 并初始化数据
union.AddComponent<TradeDes>().SetInfo(unionPage.Data.DataList[i]); union.AddComponent<TradeDes>().SetInfo(unionPage.Data.DataList[i]);
} }