using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class OilTankController : BaseToggle { public GameObject HasChild; private Text MyShowText; public OilTanksManager MyManager; public OilTankMessage MyMsg; public List ChildList = new List(); public override void RespondFun(bool value) { if (ChildList.Count > 0) { if (value) { foreach (GameObject c in ChildList) { c.gameObject.SetActive(true); } } else { foreach (GameObject c in ChildList) { c.GetComponent().isOn = false; c.gameObject.SetActive(false); } } } else { if (value) { //切镜头,显示操作面板 MyMsg.GuanQuName = MyShowText.text; OilSetManager.GetInstance.BindOilTank(MyMsg); //var radius = MyMsg.GetComponent().bounds.size.x; var radius = MyMsg.transform.Find("OilStandard").GetChild(0).GetComponent().bounds.size.x; float dis; if (radius >= 20) { dis = 75; } else if (radius > 14 && radius < 20) { dis = 50; } else { dis = 40; } Camera.main.GetComponent().SetCameraView(MyMsg.transform.position, dis, 160, 47); } else { //关闭操作面板 OilSetManager.GetInstance.BindOilTank(null); } } } public void DataBind() { GetMyName();//绑定名称 } private void GetMyName() { MyShowText = transform.Find("Text").GetComponent(); MyShowText.text = name; } }