预制体的无效组件,只能 手动 移除,保存预制体。
Missing的组件,通常情况 是 工程的Asset不存在该脚本,或者是脚本已经被删除。
...
/// <summary>
/// 移除 物体 的所有 组件
/// </summary>
/// <param name="gameObject">要移除的 物体 的组件</param>
public static void RemoveComponent(GameObject gameObject)
{
List<Component> comList = new List<Component>();
Debug.Log("RemoveComponent:" + gameObject.name);
foreach (var component in gameObject.GetComponents<Component>())
{
if (component != null)
{
//comList.Add(component);
Debug.Log("RemoveComponent:" + gameObject.name + "/" + component.GetType());
}
else//当组件为无效组件,或者Missing Component,则为空
{
Debug.Log("RemoveComponen