63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using HUD;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author YangHua
|
||
//@create 20230426
|
||
//@company Adam
|
||
//
|
||
//@description:
|
||
//============================================================
|
||
namespace Adam
|
||
{
|
||
[Serializable]
|
||
public struct ModelInformation
|
||
{
|
||
public StationInformation stationInformation;
|
||
public List<GameObject> tations;
|
||
}
|
||
public class HUDController : MonoBehaviour
|
||
{
|
||
|
||
public List<ModelInformation> modelInformations = new List<ModelInformation>();
|
||
|
||
// Use this for initialization
|
||
private void Awake()
|
||
{
|
||
for (int i = 0; i < modelInformations.Count; i++)
|
||
{
|
||
for (int j = 0; j < modelInformations[i].tations.Count; j++)
|
||
{
|
||
StationInformation si = Instantiate(modelInformations[i].stationInformation);
|
||
GameObject go = modelInformations[i].tations[j];
|
||
si.SetTarget(Camera.main.transform);
|
||
si.Init(go.transform, GetBounds(go));
|
||
}
|
||
}
|
||
}
|
||
|
||
private Bounds GetBounds(GameObject obj)
|
||
{
|
||
Bounds bounds = new Bounds();
|
||
if (obj.transform.childCount != 0)
|
||
{
|
||
Renderer[] renderers = obj.GetComponentsInChildren<Renderer>();
|
||
for (int i = 0; i < renderers.Length; i++)
|
||
{
|
||
bounds.Encapsulate(renderers[i].bounds);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
bounds = obj.GetComponent<Renderer>().bounds;
|
||
}
|
||
return bounds;
|
||
}
|
||
|
||
|
||
}
|
||
}
|