nuolo

移除 Missing(Mono Script)

`
private static void FindMissingReferences()

{
    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]);
            var prop = serializedObject.FindProperty("m_Component");
            r = 0;

            for (j = 0; j < components.Length; j++)
            {
                if (components[j] == null)
                {
                    prop.DeleteArrayElementAtIndex(j - r);
                    r++;
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
    }
}

`

分类:

技术点:

相关文章:

  • 2021-07-16
  • 2021-04-06
  • 2021-07-13
  • 2022-01-08
  • 2021-11-07
  • 2022-01-06
猜你喜欢
  • 2021-10-31
  • 2021-04-29
  • 2021-11-29
  • 2021-06-11
  • 2021-11-30
  • 2021-08-09
  • 2021-07-29
相关资源
相似解决方案