59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
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); });
|
|
}
|
|
}
|