using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddColliders : MonoBehaviour
{
public List<GameObject> objectsToAddCollider = new List<GameObject>();
// Start is called before the first frame update
void Start()
{
AddDescendantsWithTag(transform, objectsToAddCollider);
}
// Update is called once per frame
void Update()
{
}
private void AddDescendantsWithTag(Transform parent, List<GameObject> list)
{
foreach (Transform child in parent)
{
if (child.gameObject.GetComponent<MeshRenderer>() != null
&& child.gameObject.GetComponent<)
{
list.Add(child.gameObject);
}
AddDescendantsWithTag(child, list);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这一行中,我正在检查是否有附加到游戏对象的网格渲染器,但如何检查它是否未附加任何碰撞类型?然后如何向其添加网格碰撞器?
这是我到目前为止尝试过的:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public …Run Code Online (Sandbox Code Playgroud)