Author Topic: TNObject send parameters  (Read 3552 times)

dale.golby

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
TNObject send parameters
« on: May 07, 2014, 01:19:41 AM »
Was just wondering if there are limits to what you can send through the tno.Send() function, like are there things that you cannot send?

Asking because it did not like me trying to send through a gameObject, I was most likely doing something else wrong causing it issues, but I still get the feeling that it's not possible.

Thanks.

Manmax75

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 32
    • View Profile
Re: TNObject send parameters
« Reply #1 on: May 07, 2014, 02:39:48 AM »
Coppied from Line 240 from UnityTools.cs

  1. static public bool CanBeSerialized (Type type)
  2.         {
  3.                 if (type == typeof(bool)) return true;
  4.                 if (type == typeof(byte)) return true;
  5.                 if (type == typeof(ushort)) return true;
  6.                 if (type == typeof(int)) return true;
  7.                 if (type == typeof(uint)) return true;
  8.                 if (type == typeof(float)) return true;
  9.                 if (type == typeof(string)) return true;
  10.                 if (type == typeof(Vector2)) return true;
  11.                 if (type == typeof(Vector3)) return true;
  12.                 if (type == typeof(Vector4)) return true;
  13.                 if (type == typeof(Quaternion)) return true;
  14.                 if (type == typeof(Color32)) return true;
  15.                 if (type == typeof(Color)) return true;
  16.                 if (type == typeof(DateTime)) return true;
  17.                 if (type == typeof(IPEndPoint)) return true;
  18.                 if (type == typeof(bool[])) return true;
  19.                 if (type == typeof(byte[])) return true;
  20.                 if (type == typeof(ushort[])) return true;
  21.                 if (type == typeof(int[])) return true;
  22.                 if (type == typeof(uint[])) return true;
  23.                 if (type == typeof(float[])) return true;
  24.                 if (type == typeof(string[])) return true;
  25.                 return false;
  26.         }
  27.  

These are all the types you can serialize. Things like game objects or transforms are too complicated and have references to things that are explicitly local to your simulated game.
If you want to identify a gameobject or send an object reference to a client, I recommend sending it's TNObject Unique-ID. And then searching for it locally on the player.
Or alternatively syncing your own ID system.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNObject send parameters
« Reply #2 on: May 08, 2014, 03:24:22 AM »
This has actually been removed in the current Pro version (so you will see it live soon). You can now send just about anything via parameters. Any data, that is. You still won't be able to send references to game objects or components.