码迷,mamicode.com
首页 > 其他好文 > 详细

记一下关于Instantiate时Awake Start的执行

时间:2015-07-20 16:37:04      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:unity3d

Root 

using UnityEngine;
using System.Collections;

public class RootScript : MonoBehaviour {

    public GameObject profab;

    void Awake()
    {
        Debug.Log(Time.time + "Root Awake");
    }

	// Use this for initialization
	void Start () {
        Debug.Log(Time.time + "Root Start");
        Invoke("startLoadUI", 0.1f);
	}
	
	private void startLoadUI()
    {
        GameObject go = Instantiate(profab) as GameObject;
    }
}


Child

using UnityEngine;
using System.Collections;

public class ChildScript : MonoBehaviour {

    void Awake()
    {
        Debug.Log(Time.time + "Child Awake");

    }

	// Use this for initialization
	void Start () {
        Debug.Log(Time.time + "Child Start");
    }
	
	// Update is called once per frame
	void Update () {
	
	}
}


运行结果

技术分享






版权声明:本文为博主原创文章,未经博主允许不得转载。

记一下关于Instantiate时Awake Start的执行

标签:unity3d

原文地址:http://blog.csdn.net/lihuozhiling0101/article/details/46968223

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!