少年修仙传客户端基础资源
client_Wu Xijin
2019-01-16 d53a782e2fd91ffc47dad0dd5a080ee451a351b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEngine.SceneManagement;
 
public class RemoveMissingScripts : Editor
{
    [MenuItem("程序/移除丢失的脚本")]
    public static void RemoveMissingScript()
    {
        var gos = GameObject.FindObjectsOfType<GameObject>();
        foreach (var item in gos)
        {
            SerializedObject so = new SerializedObject(item);
            var soProperties = so.FindProperty("m_Component");
            var components = item.GetComponents<Component>();
            int propertyIndex = 0;
            foreach (var c in components)
            {
                if (c == null)
                {
                    soProperties.DeleteArrayElementAtIndex(propertyIndex);
                }
                ++propertyIndex;
            }
            so.ApplyModifiedProperties();
        }
 
        AssetDatabase.Refresh();
        Debug.Log("清理完成!");
    }
 
}