static void CheckMissing(GameObject go, System.Type type)
{
bool isAnyChange = false;
var components = go.GetComponentsInChildren(type, true);
foreach (var component in components)
{
if (component == null)
{
Debug.Log("component missing ");
continue;
}
SerializedObject so = new SerializedObject(component);
bool isSoChange = false;
var sp = so.GetIterator();
while (sp.Next(true))
{
if (sp.propertyType == SerializedPropertyType.ObjectReference)
{
if (sp.objectReferenceValue == null
&& sp.objectReferenceInstanceIDValue != 0)
{
sp.objectReferenceInstanceIDValue = 0;
isSoChange = true;
Debug.Log("set missing reference to none: " +
go.name + "," +
component.gameObject + "." + component.name);
}
}
}
if (isSoChange)
{
so.ApplyModifiedProperties();
isAnyChange = true;
}
}
if (isAnyChange)
{
EditorUtility.SetDirty(go);
}
}
[工具]检测引用丢失(Missing)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- Update Log:2017.8.24: 初版 2017.10.8: 添加无法使用的解决办法 升了xcode9使...
- FBMemoryProfiler 基础教程 [FBMemoryProfiler](https://github.c...
- 1.问题 你知道delegate 如果是strong 修饰的话,就会引起循环引用。导致内存释放不掉,内存泄漏。你...