0
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Unity5 NGUIで、NGUITools.AddChildしたものの実体を参照する

これだとエラー

exp.cs

GameObject prefab = (GameObject)Resources.Load("Prefabs/UI/Balloons/BtnBalloon") as GameObject;
Destroy(prefab,4f);
NGUITools.AddChild(BalloonParentObj, prefab);

これだとOK

exp.cs


GameObject prefab = (GameObject)Resources.Load("Prefabs/UI/Balloons/BtnBalloon") as GameObject;
GameObject BalloonPrefab = NGUITools.AddChild(BalloonParentObj, prefab);// NGUIに追加 帰り値で、prefabの実体を参照
Destroy(BalloonPrefab,4f); //4秒後に追加したprefabを削除

NGUITools.AddChildの返り値で引数の実体を参照できる

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?