As everyone has already pointed out, it is probably better just to have the textures preloaded by the clients and send the reference from the server.
However if you encounter another object that you need to send with kryonet but can't serialize it try this:
Have the object implement Serializable
Then when you register the object with Kryonet try:
1
| kryo.register(nameofyourobject.class, new SerializableSerializer()); |
You can also try:
You will need to create an empty constructor in your object for the serializer to use.
1 2 3 4 5 6
| public nameofyourobject(){} ---- FieldSerializer ObjectSerializer = new FieldSerializer(kryo, nameofyourobject.class); ObjectSerializer.setCanBeNull(true); kryo.register(nameofyourobject.class, ObjectSerializer); |
If your object has non-primitive parameters you may need to create a fieldserializer for each of these datatypes as well. This method will be much more efficient than the first since it uses Kryo's serializer.