methusalah / SplineMesh

A Unity plugin to create curved content in real-time with bézier curves
https://twitter.com/dumas181
MIT License
1.05k stars 104 forks source link

SendMessage cannot be called during Awake, CheckConsistency, or OnValidate #37

Open david-pfx opened 4 years ago

david-pfx commented 4 years ago

This error happens when loading the Showcase in the editor. There are about 20 of them , like this:

SendMessage cannot be called during Awake, CheckConsistency, or OnValidate UnityEngine.GameObject:.ctor(String, Type[]) SplineMesh.UOUtility:Create(String, GameObject, Type[]) (at Assets/SplineMesh/Scripts/Utils/UOUtility.cs:9) SplineMesh.ExampleGrowingRoot:Init() (at Assets/SplineMesh/Scripts/Example/ExampleGrowingRoot.cs:81) SplineMesh.ExampleGrowingRoot:OnValidate() (at Assets/SplineMesh/Scripts/Example/ExampleGrowingRoot.cs:49) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

You can find info about this problem here: https://forum.unity.com/threads/sendmessage-cannot-be-called-during-awake-checkconsistency-or-onvalidate-can-we-suppress.537265/ and here: https://forum.unity.com/threads/sendmessage-cannot-be-called-during-awake-checkconsistency-or-onvalidate.428580/.

Basically this problem happens if you call the Unity API to set stuff before the system is stable. There is a partial description here: https://docs.unity3d.com/2019.1/Documentation/ScriptReference/GameObject-tag.html, but it applies to lots of other stuff.

It's new, since some time in 2019, there is a bug report, Unity have responded and it's probably not going away any time soon. The ideal fix is: don't set stuff in Awake() or OnValidate(). I'm running 2020.1.1 and I don't have any old versions available to check.