Author Topic: Unable to save type TNet.TcpProtocol error...  (Read 3044 times)

blueskined

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Unable to save type TNet.TcpProtocol error...
« on: February 20, 2013, 07:14:36 AM »
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.
  1. using UnityEngine;
  2. using System.Collections;
  3. using TNet;
  4.  
  1.         void Start ()
  2.         {
  3.                 TNManager.Connect(ServerIP);
  4.                 TNManager.StartUDP(Random.Range(10000, 50000));
  5.                 owner = TNManager.player;
  6.         }
  7.  
  1.         void OnGUI()
  2.         {
  3.                 if(GUI.Button(new Rect(ButtonPosition.x, ButtonPosition.y, ButtonSize.x, ButtonSize.y), "Print Info"))
  4.                 {
  5.                         TNObject tno = GetComponent<TNObject>();
  6.                         tno.Send("PrintInstanceInfo", Target.AllSaved, owner);
  7.                 }
  8.                
  9.                 GUI.Label(new Rect(ButtonPosition.x, ButtonPosition.y + 30, ButtonSize.x, ButtonSize.y), labelText, style);
  10.         }
  11.  

  1.         [RFC] void PrintInstanceInfo(Player owner)
  2.         {
  3.                 labelText = "The Last Player Updated is: " + owner.id.ToString();
  4.                 Debug.Log("RFC Function go in");
  5.         }
  6.  
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....)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unable to save type TNet.TcpProtocol error...
« Reply #1 on: February 20, 2013, 08:52:59 AM »
You can't pass the TNet.Player as a parameter. Pass it by the ID instead (player.id).