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 tations; } public class HUDController : MonoBehaviour { public List modelInformations = new List(); // 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(); for (int i = 0; i < renderers.Length; i++) { bounds.Encapsulate(renderers[i].bounds); } } else { bounds = obj.GetComponent().bounds; } return bounds; } } }