コード例 #1
0
    public LoadAggregationContainer(List <GameObject> gos)
    {
        foreach (GameObject go in gos)
        {
            Part part = go.GetComponent <Part>();

            if (part == null)
            {
                continue;
            }

            PartSpawnData spawnData = new PartSpawnData(go.transform.position, go.transform.rotation, part);
            data.Add(spawnData);
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (data.Count > spawnPerFrame)
        {
            for (int i = spawnPerFrame - 1; i >= 0; --i)
            {
                PartSpawnData d = data[i];

                if (d.Token.GetType() == typeof(PartToken))
                {
                    SpawnBlock((PartToken)d.Token, d.Position, d.Rotation, d.owner);
                }
                else if (d.Token.GetType() == typeof(PartTokenParent))
                {
                    SpawnBlockParent((PartTokenParent)d.Token, d.Position, d.Rotation, d.owner);
                }

                data.RemoveAt(i);
            }
        }
        else
        {
            foreach (PartSpawnData d in data)
            {
                if (d.Token.GetType() == typeof(PartTokenParent))
                {
                    SpawnBlockParent((PartTokenParent)d.Token, d.Position, d.Rotation, d.owner);
                }
                else if (d.Token.GetType() == typeof(PartToken))
                {
                    SpawnBlock((PartToken)d.Token, d.Position, d.Rotation, d.owner);
                }
            }

            data.Clear();
        }


        if (loadData.data.Count > 0)
        {
            loadData.StreamData(true, NetworkCallbacks.StreamAggregationChannel);
        }
    }