using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class GetSerachPrefab : MonoBehaviour { public GameObject needDragGoBtn; public TextMeshProUGUI text; /// /// 选项Btn; /// public Button SelectBtn; public string path; private void Start() { GetPrefab(); needDragGoBtn=transform.parent.parent.parent.parent.Find("Image_拖拽设备框").GetChild(0).gameObject; } public void GetPrefab() { SelectBtn.onClick.AddListener(() => { path = string.Format("古泉站机房模型90个型号/{0}", text.text); needDragGoBtn.GetComponent().prefab = Resources.Load(path); }); } }