I've been using ex2D for a few days now, and I'm having trouble instantiating an exSprite at runtime.
I'm setting up my exSprite, I saved it as a prefab, I delete it from the scene hierarchy, I start the game and at a certain point I instantiate that prefab using Unity's Instantiate method. I also set this new object as a child of my only layer (using transform.parent).
But it seems that this new exSprite is never drawn.
Am I forgetting something ?
在我的测试中, 我是这么来做的:
我做了一个 EmptyGO, EmptyGO 底下放置了一个 exSpriteGO. 然后把这样一个层级关系的 GO 做成 prefab.
之后用以下代码 spawn
using UnityEngine;
using System.Collections;
public class Test_SimpleSpawn : MonoBehaviour {
public GameObject prefab;
public GameObject layer;
// Use this for initialization
IEnumerator Start () {
yield return new WaitForSeconds(3.0f);
GameObject newGO = GameObject.Instantiate (prefab) as GameObject;
newGO.transform.parent = layer.transform;
}
// Update is called once per frame
void Update () {
}
}
I've been using ex2D for a few days now, and I'm having trouble instantiating an exSprite at runtime.
I'm setting up my exSprite, I saved it as a prefab, I delete it from the scene hierarchy, I start the game and at a certain point I instantiate that prefab using Unity's Instantiate method. I also set this new object as a child of my only layer (using transform.parent). But it seems that this new exSprite is never drawn.
Am I forgetting something ?
在我的测试中, 我是这么来做的:
我做了一个 EmptyGO, EmptyGO 底下放置了一个 exSpriteGO. 然后把这样一个层级关系的 GO 做成 prefab.
之后用以下代码 spawn