Awake() and Start()

后端 未结 4 953
北荒
北荒 2020-12-29 01:02

I see that we can initialize Variable in Awake() or Start() and Awake() will be called before Start().

When shou

4条回答
  •  执笔经年
    2020-12-29 01:33

    There's not much difference in the performance. But I can tell you a difference between them.

    Take a simple example. Say if you want to print "HELLO" in console even if you have not activated the script in inspector, using Awake() function, you can print it in the console. But if you had written the same thing in Start() function and the script wasn't activated, you don't get any output in the console. That's the difference.

    Codes in Start() function get executed only if the script is activated while, codes in Awake() function get executed even if the script is not activated. Try it !

提交回复
热议问题