Reputation: 977
I have a script currently running OnValidate() to update a GameObject while I'm in the editor. At times, when things reset, the script will run the following lines:
private void OnValidate()
{
if (reset == true)
{
obj.transform.parent = transform;
}
}
In return, I end up with some Warnings in the console like the following:
SendMessage cannot be called during Awake, CheckConsistency, or OnValidate
UnityEngine.Transform:set_parent(Transform)
Planet:Initialize() (at Assets/Planet.cs:46)
Planet:OnValidate() (at Assets/Planet.cs:20)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
So my question is: What message/method is the program trying to send using SendMessage that it is unable to call?
Upvotes: 1
Views: 1409
Reputation: 691
Apparently set_parent uses SendMessage behind the covers, and that can be problematic from OnValidate calls.
Upvotes: 1