You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.1 KiB
77 lines
2.1 KiB
4 years ago
|
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<GameObject> ChildList = new List<GameObject>();
|
||
|
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<Toggle>().isOn = false;
|
||
|
c.gameObject.SetActive(false);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (value)
|
||
|
{
|
||
|
//切镜头,显示操作面板
|
||
|
MyMsg.GuanQuName = MyShowText.text;
|
||
|
OilSetManager.GetInstance.BindOilTank(MyMsg);
|
||
|
//var radius = MyMsg.GetComponent<MeshRenderer>().bounds.size.x;
|
||
|
var radius = MyMsg.transform.Find("OilStandard").GetChild(0).GetComponent<MeshRenderer>().bounds.size.x;
|
||
|
float dis;
|
||
|
if (radius >= 20)
|
||
|
{
|
||
|
dis = 75;
|
||
|
}
|
||
|
else if (radius > 14 && radius < 20)
|
||
|
{
|
||
|
dis = 50;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
dis = 40;
|
||
|
}
|
||
|
Camera.main.GetComponent<CameraManager>().SetCameraView(MyMsg.transform.position, dis, 160, 47);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//关闭操作面板
|
||
|
OilSetManager.GetInstance.BindOilTank(null);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void DataBind()
|
||
|
{
|
||
|
GetMyName();//绑定名称
|
||
|
}
|
||
|
|
||
|
private void GetMyName()
|
||
|
{
|
||
|
MyShowText = transform.Find("Text").GetComponent<Text>();
|
||
|
MyShowText.text = name;
|
||
|
}
|
||
|
}
|