/// <summary>
    /// 生成预设物体
    /// </summary>
    /// <param name="prefab">预设物体</param>
    /// <returns></returns>
    protected GameObject SpawnChildren(SpawnChild sc, Transform parent)
    {
        GameObject go = null;

        if (!Spawnall.ContainsKey(sc))
        {
            Spawnall.Add(sc, new List <GameObject>());
        }

        switch (sc)
        {
        case SpawnChild.FirstPoolItem:
            go = selfMainpool.Allocate();
            break;

        case SpawnChild.SecendPoolItem:
            go = selfSecendpool.Allocate();    //Instantiate(prefab);
            break;

        default:
            break;
        }
        go.SetActive(true);
        go.transform.SetParent(parent);
        Spawnall[sc].Add(go);
        return(go);
    }
Exemplo n.º 2
0
    void SpawnChildren()
    {
        GameObject ChildToBeSpawned = SpawnChild.CreateChild(ToSpawn, transform.parent, transform.position, Direction);

        switch (Direction)
        {
        case DIRECTION.Forward:
            ChildToBeSpawned.transform.LookAt(transform.position + Vector3.right);
            break;

        case DIRECTION.Backward:
            ChildToBeSpawned.transform.LookAt(transform.position + -Vector3.right);
            break;

        case DIRECTION.Right:
            ChildToBeSpawned.transform.LookAt(transform.position + -Vector3.forward);
            break;

        case DIRECTION.Left:
            ChildToBeSpawned.transform.LookAt(transform.position + Vector3.forward);
            break;
        }
    }