using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIClickBody : UIBase { public Button btn; public Transform currentModel; public Transform moreBtn; public Button btn1; public Button btn2; private void Awake() { var allModel = DataManager.Instance.GetGameData().allModel; for (int i = 0; i < allModel.Length; i++) { if (allModel[i].gameObject.activeSelf) { currentModel = allModel[i].transform; } } var buwei1 = currentModel.Find("胸部"); var buwei2 = currentModel.Find("下肢"); var newUI = GameObject.Instantiate(btn, this.transform); Vector2 player2DPosition = Camera.main.WorldToScreenPoint(buwei1.position); newUI.transform.position = player2DPosition; newUI.gameObject.SetActive(true); newUI.onClick.AddListener(() => { Debug.Log("点熊"); moreBtn.transform.position = newUI.transform.position + new Vector3(105f, -40f); moreBtn.gameObject.SetActive(true); }); var newUI2 = GameObject.Instantiate(btn, this.transform); Vector2 player2DPosition2 = Camera.main.WorldToScreenPoint(buwei2.position); newUI2.transform.position = player2DPosition2; newUI2.gameObject.SetActive(true); newUI2.onClick.AddListener(() => { Debug.Log("点下"); moreBtn.transform.position = newUI2.transform.position + new Vector3(105f, -40f); moreBtn.gameObject.SetActive(true); }); btn1.onClick.AddListener(() => { moreBtn.gameObject.SetActive(false); }); btn2.onClick.AddListener(() => { moreBtn.gameObject.SetActive(false); }); } }