少年修仙传客户端基础资源
hch
2024-05-20 63ab36b08e46a5889b36d75024d6992c69b418fb
Assets/Editor/Tool/RemoveMissingScripts.cs
@@ -52,25 +52,31 @@
            count2++;
            EditorUtility.DisplayProgressBar("Processing...", "遍历丢失脚本Prefab中....", count / pathList.Count);
            GameObject obj = (GameObject)AssetDatabase.LoadAssetAtPath(path, typeof(GameObject));
            getAllChild(obj.transform);
            checkMissing(obj);
            getAllChild(obj);
        }
        EditorUtility.ClearProgressBar();
    }
    void getAllChild(Transform tf)
    void getAllChild(GameObject go)
    {
        foreach (Transform child in tf)
        foreach (Transform child in go.transform)
        {
            var components = child.GetComponents<Component>();
            for (int j = 0; j < components.Length; j++)
            checkMissing(child.gameObject);
            getAllChild(child.gameObject);
        }
    }
    void checkMissing(GameObject go)
    {
        var components = go.GetComponents<Component>();
        for (int j = 0; j < components.Length; j++)
        {
            if (components[j] == null)
            {
                if (components[j] == null)
                {
                    missObj.Add(child.gameObject);
                    continue;
                }
                missObj.Add(go.gameObject);
                continue;
            }
            getAllChild(child);
        }
    }