Hi there,
I’m trying to work out and get a List & Struct to sync but im getting a really weird error when i try to add data into the list.
When ever this line(50): PlayerConnectionList.Add( new NetworkingPlyList.PlyData( Name , Addy , Port , true , Guid , Nwid , IsHost ) );
I get the error:
If anyone could advise me on what I’m doing wrong it would be extremely helpful as I’m completely lost currently.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Networking;
using System.Collections.Generic;
public class NetworkingPlyList : NetworkBehaviour {
public struct PlyData
{
public string PlayerName;
public string PlayerAddress;
public string PlayerPort;
public bool Connected;
public string GUID;
public string NetworkID;
public bool Host;
public PlyData( string Name , string Addy , string Port , bool PlayerConnected , string Guid , string Nwid , bool IsHost )
{
PlayerName = Name;
PlayerAddress = Addy;
PlayerPort = Port;
Connected = PlayerConnected;
GUID = Guid;
NetworkID = Nwid;
Host = IsHost;
}
}
public class SyncListPlyData : SyncListStruct<PlyData>
{
}
public SyncListPlyData PlayerConnectionList = new SyncListPlyData();
public void PrintPlayers() {
Debug.Log( "Printing Players" );
foreach ( PlyData Ply in PlayerConnectionList )
{
Debug.Log( "PlyConnectionData[[ Players Address= " + Ply.PlayerAddress + ":" + Ply.PlayerPort + " GUID: " + Ply.GUID + " NetworkID: " + Ply.NetworkID + " Connected: " + Ply.Connected + " IsHost: " + Ply.Host );
}
}
public void AddPlayer( string Name , string Addy , string Port , string Guid , string Nwid , bool IsHost )
{
print( "Adding Ply to this list inside NetworkingPlyList" );
PlayerConnectionList.Add( new NetworkingPlyList.PlyData( Name , Addy , Port , true , Guid , Nwid , IsHost ) );
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}