示例#1
0
    private void OnSyncRoom(byte[] data)
    {
        for (int i = 0; i < playerButtonContent.childCount; i++)
        {
            Destroy(playerButtonContent.GetChild(i).gameObject);
        }

        BaseNetData ndata = Utils.FromBytesJSON <BaseNetData>(data);
        Room        room  = ndata.Values["room"].ObjectValue as Room;

        foreach (Client c in room.Clients)
        {
            GameObject mobj = Instantiate(playerButtonPrefab, playerButtonContent);
            mobj.GetComponent <PlayerButton>().Init(c.Nickname);
        }
    }
示例#2
0
    private void OnGetRooms(byte[] data)
    {
        for (int i = 0; i < roomButtonContent.childCount; i++)
        {
            Destroy(roomButtonContent.GetChild(i).gameObject);
        }

        BaseNetData ndata = Utils.FromBytesJSON <BaseNetData>(data);
        List <Room> rooms = ndata.Values["rooms"].ObjectValue as List <Room>;

        foreach (Room r in rooms)
        {
            GameObject mobj = Instantiate(roomButtonPrefab, roomButtonContent);
            mobj.GetComponent <RoomButton>().Init(r.Name);
            mobj.GetComponent <RoomButton>().ID = r.ID;
        }
    }