Hello,
I'm trying to send a custom class via a broadcast, and get it via a RFC method.
Here is the class:
[Serializable]
public class GameData : IBinarySerializable
{
public int id { get; private set; }
public string name { get; private set; }
public string spriteName { get; private set; }
public int hostID;
public GameData(int id, string name, string spriteName)
{
this.id = id;
this.name = name;
this.spriteName = spriteName;
hostID = int.MinValue;
}
public void Serialize(BinaryWriter writer)
{
writer.Write(id);
writer.Write(name);
writer.Write(spriteName);
writer.Write(hostID);
}
public void Deserialize(BinaryReader reader)
{
id = reader.ReadInt();
name = reader.ReadString();
spriteName = reader.ReadString();
hostID = reader.ReadInt();
}
}
and in an empty scene, with just the following script attached to the camera (and a TNObject with ID 1):
public class Test2 : TNBehaviour
{
void Start ()
{
Debug.Log(TNManager.StartUDP(12345));
}
void Update ()
{
if (Input.GetKeyDown(KeyCode.S))
{
GameData gameData
= new GameData
(5,
"Hello",
"World"); gameData.hostID = 25;
tno.BroadcastToLAN(12345, "OnGameCreatedRFC", gameData);
}
}
[RFC]
void OnGameCreatedRFC(GameData gameData)
{
Debug.Log(gameData);
}
}
Calling Debug.Log(gameData) return null.
Any idea why?
Thanks!