Can I put custom class in Room's Properties?

johnny_tictoc
edited February 2017 in Photon Server
// in Room.cs
/// <summary>
        ///   Gets a PropertyBag instance used to store custom room properties.
        /// </summary>
        public PropertyBag<object> Properties { get { return this.roomState.Properties; } }
Is there any extra code I need to do for a custom class to be properly serialized when it is sent across the network?

My class only has primitive types like ints and strings. But I am wondering if there are any extra code or attributes that I need to add to my class.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @johnny_tictoc,

    You can try to Photon deserialize/serialize your custom class and set property value as byte array.
    I do not think that registering custom type is used for properties. It is meant for custom event data only.
    For more information read about "Serialization in Photon".
  • Kaiserludi
    Kaiserludi admin
    edited February 2017
    Hi @johnny_tictoc,
    JohnTube said:


    I do not think that registering custom type is used for properties. It is meant for custom event data only.

    Actually registering a custom type for your class should work just fine for properties values.

    You can freely use anything in property values that is supported by Photons serialization (see JohnTubes link). The serialization code does not differ between raising events and setting properties.