I am not very experienced on network thing, so I am trying to start a new scene from scratch, trying to get some sense of TNet. Using NTServer.exe standlon on my pc, ip is 192.168.1.6.
I made 2 game objects, 1 TNManager, 1 TNObject, script attached on TNObject, and TNManager Objects reference TNObject. I am trying to setup a very simple scene, just a label, when players click the button cross internet the label will show the player's ID who clicked the button.
using UnityEngine;
using System.Collections;
using TNet;
void Start ()
{
TNManager.Connect(ServerIP);
TNManager.StartUDP(Random.Range(10000, 50000));
owner = TNManager.player;
}
void OnGUI()
{
if(GUI
.Button(new Rect
(ButtonPosition
.x, ButtonPosition
.y, ButtonSize
.x, ButtonSize
.y),
"Print Info")) {
TNObject tno = GetComponent<TNObject>();
tno.Send("PrintInstanceInfo", Target.AllSaved, owner);
}
GUI
.Label(new Rect
(ButtonPosition
.x, ButtonPosition
.y + 30, ButtonSize
.x, ButtonSize
.y), labelText, style
); }
[RFC] void PrintInstanceInfo(Player owner)
{
labelText = "The Last Player Updated is: " + owner.id.ToString();
Debug.Log("RFC Function go in");
}
when I play the scene, it work, but when I click the "Print Info" button, I got this error:
Unable to save type TNet.TcpProtocol
UnityEngine.Debug:LogError(Object)
TNet.UnityTools:Write(BinaryWriter, Object[]) (at Assets/TNet/Client/TNUnityTools.cs:260)
TNObject:SendRFC(UInt32, Byte, String, Target, Boolean, Object[]) (at Assets/TNet/Client/TNObject.cs:551)
TNObject:Send(String, Target, Object[]) (at Assets/TNet/Client/TNObject.cs:439)
PrintInfo:OnGUI() (at Assets/TNet/Examples/Scripts/Test/PrintInfo.cs:51)
I am sure I did something wrong, but I just can't figure it out, please help!!
(I haven't even try to create multiple clients yet....)