using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class ClearComponent
{
[MenuItem("我的编辑器/多个物体组件清除")]
static void ClearComponentMore()
{
var allGos = Resources.FindObjectsOfTypeAll(typeof(GameObject));
var previousSelection = Selection.objects;
Selection.objects = allGos;
var selectedTransforms = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab);
Selection.objects = previousSelection;
foreach (var trans in selectedTransforms)
{
//先显示所有物体
trans.gameObject.SetActive(true);
}
//再清除模型上的脚本
Transform[] currentObject = null;
currentObject = Selection.transforms;
for (int index = 0; index < currentObject.Length; index++)
{
currentObject[index].gameObject.SetActive(true);
foreach (Compon
Unity遍历Hierarchy上的所有物体并清除指定组件
最新推荐文章于 2023-08-07 11:35:31 发布