当inspector发生改变时OnValidate,调用destory报错
Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate. You must use Destroy instead.报错,如何删除子节点在这个方法中》?
void OnValidate()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.delayCall += () =>
{
createReels();
};
#endif
// Main();
}
加入延迟执行,并且销毁方法改为
while (gameObject.transform.childCount > 0)
{
DestroyImmediate(gameObject.transform.GetChild(0).gameObject);
}
页:
[1]