public Text text; //自己的Item的Text public UIItem(string name, Transform parent) //构造,传入生成的Item的名字,和他的父级 { dic = new Dictionary <ShowType, Action>() { { ShowType.bag, () => { Tips.Get().Show(item); } },//走背包的方法 { ShowType.shop, () => {; } } }; GameObject game = GameObject.Instantiate(Resources.Load <GameObject>("ECS/" + name), parent, false);//生成Item的实例 game.GetComponent <Button>().onClick.AddListener(() => { dic[item.show].Invoke(); //执行 对应的显示层的 委托 }); text = game.transform.GetComponentInChildren <Text>(); //找到自己的Text组件 }