十堰考核场景东油沥青
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.3 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class DeleteMissingScripts : EditorWindow
{
[MenuItem("Tools/移除丢失的脚本")]
public static void RemoveMissingScript()
{
GameObject[] pAllObjects = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject));
int r;
int j;
for (int i = 0; i < pAllObjects.Length; i++)
{
if (pAllObjects[i].hideFlags == HideFlags.None)//HideFlags.None 获取Hierarchy面板所有Object
{
var components = pAllObjects[i].GetComponents<Component>();
var serializedObject = new SerializedObject(pAllObjects[i]); // 将object序列化
var prop = serializedObject.FindProperty("m_Component"); //得到object的Component序列化数组
r = 0;
for (j = 0; j < components.Length; j++)
{
if (components[j] == null)
{
prop.DeleteArrayElementAtIndex(j - r);
r++;
}
}
serializedObject.ApplyModifiedProperties();
}
}
}
[MenuItem("Tools/添加缺失克隆类型")]
public static void AddCloneTypes()
{
Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
for (int i = 0; i < obj.Length; i++)
{
if (obj[i].GetComponent<CloneableEnums>())
{
var types = obj[i].GetComponent<CloneableEnums>().CloneableTypes;
if (types.Contains(CloneObjType.Ambulance))
{
Debug.Log(obj[i].name);
if (!types.Contains(CloneObjType.LiveBuildCar))
{
types.Add(CloneObjType.LiveBuildCar);
}
if (!types.Contains(CloneObjType.EmergencyVehicle))
{
types.Add(CloneObjType.EmergencyVehicle);
}
if (!types.Contains(CloneObjType.Cruiser))
{
types.Add(CloneObjType.Cruiser);
}
}
}
}
}
}