List of unknown table types

30 views
Skip to first unread message

Goran Saric

unread,
Nov 10, 2016, 9:52:08 AM11/10/16
to FlatBuffers
Hi there

I'm still struggling to implement a complex save game system with Unity. I wonder how I can accomplish the follow scenario:

There are several independent obstacles in the game, that appear in different parts of the game. They all have their own logic and data fields and also their own FlatBuffers table schema.
There is also a central SaveData schema / table, which includes the position of the player and it's properties, which scenes are loaded etc. 

The question is now, how can I store all the present obstacles within the SaveData table without defining all the different types in advance in the schema? 

Is the design-pattern I'm trying to achieve probably not the best in this case? 
I hope you guys can understand my problem :)

Thanks for any help. 

mikkelfj

unread,
Nov 10, 2016, 12:18:33 PM11/10/16
to FlatBuffers


The question is now, how can I store all the present obstacles within the SaveData table without defining all the different types in advance in the schema? 

Is the design-pattern I'm trying to achieve probably not the best in this case? 
I hope you guys can understand my problem :)

Many choose to create a wrapper table with a single element [ubyte] and an enum or string to identify the content type and embed the buffer, but this requires the buffer to be realigned on some platforms when alignment must be larger than 4 bytes.

An alternative is to use the optional file_identifier at offset 4 (or 8 if using size prefixed buffers). Here you can give each schema a unique file identifier and you can test this identifier before processing.

Wouter van Oortmerssen

unread,
Nov 14, 2016, 12:35:30 PM11/14/16
to mikkelfj, FlatBuffers
What is stopping you from including the schemas of the things SaveData depends on?

--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Goran Saric

unread,
Nov 15, 2016, 7:54:31 AM11/15/16
to FlatBuffers
The wrapper table approach worked fine for me, thanks for the hint mikkelfi!
Can you explain me the drawback with the 4 bytes on certain platforms more detailed? 
And which platforms are affected? 

Goran Saric

unread,
Nov 15, 2016, 8:02:41 AM11/15/16
to FlatBuffers, mik...@dvide.com

What is stopping you from including the schemas of the things SaveData depends on?

I'm just trying to decouple independent elements / objects to have a more generic solution. Otherwise I have to define all obstacles (there are a lot) in the SaveData schema, even if they didn't appear at the position and scene where the player saves the game state.  
Reply all
Reply to author
Forward
0 new messages