Search Unity

UI Event sent before Awake()

Discussion in 'UGUI & TextMesh Pro' started by bgulanowski, Jul 15, 2019.

  1. bgulanowski

    bgulanowski

    Joined:
    Feb 9, 2018
    Posts:
    36
    Is this a bug?

    I'm getting OnRectTransformDimensionsChange() messages before Awake(). I can easily work around it, but it seems to violate the implied behaviour contract of MonoBehaviour objects.

    The problem for me is that I use Awake() to initialize fields that reference other components on the same object. As I said, I can work around this either by making the connection in the editor or by doing it in OnRectTransformDimensionsChange(), but I prefer to use Awake(). I suspect there are other situations where sending event messages before Awake() would defy expectations.