creator lifecycle callback order

Scenario 1

    let node: cc.Node = cc.instantiatet(cc.loader.getRes(""));
    let xx: Xxx = node.getComponent(Xxx);
    xx.setData();

Calling sequence lifecycle functions such cases classes Xxx is a public method called directly Xxx, setData ().

Scenario 2

//      parentNode
      let node: cc.Node = cc.instantiatet(cc.loader.getRes(""));
      let xx: Xxx = node.getComponent(Xxx);
      xx.setData();
      parentNode.addChild(node);

This situation calling sequence function in the life cycle of the class Xxx is
to call the onLoad () ->
and public Method ->
last start ()

Reproduced in: https: //www.jianshu.com/p/9b56a17f1028

Guess you like

Origin blog.csdn.net/weixin_34092455/article/details/91292395