【发布时间】:2019-10-18 20:30:41
【问题描述】:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class GetComponents : MonoBehaviour
{
public List<Collider> allColliders = new List<Collider>();
private List<GameObject> allObjects = new List<GameObject>();
// Start is called before the first frame update
void Start()
{
allObjects = FindObjectsOfType<GameObject>().ToList();
foreach (GameObject go in allObjects)
{
foreach (Collider collider in go.transform.GetComponents<Collider>())
{
allColliders.Add(collider);
}
}
}
// Update is called once per frame
void Update()
{
}
}
最后我想要两个列表,可能会将它们写入文本文件,例如输出格式:
Wall1 -- BoxCollider,CapsuleCollider
Door22 -- 没有碰撞器
Door10 -- BoxCollider
类似的东西。目标是找出哪些游戏对象有碰撞器、哪些碰撞器以及哪些游戏对象根本没有碰撞器。
【问题讨论】: