Unified struct in C to represent multiple sensor data
You could create a struct consisting of nothing but an enum to state the type, and a void* to the data. Then cast the data to the type corresponding to the enum before using it. That's how run-time type generic programming is traditionally done in C.

With standard C, you can also nowadays use the _Generic keyword to enable compile-time type evaluation, which is very handy when all types can be determined at compile-time.

More modern/advanced forms of type generic programming with an object-oriented design uses the concept of opaque type/opaque pointers which can be useful for writing hardware abstraction layers in embedded systems. Example. Though obviously in embedded systems you shouldn't use malloc, but some manner of static allocation.

The unions in the linked example only serve to enable different forms of notation, like either referring to 3 variables by x, y or z, or as an array. This is called type punning (through union) and is perfectly OK in C. In C++ it is an undefined behavior bug. Since the library is intended for Arduino C++, it is therefore without doubt completely broken. So when looking for inspiration of how to write proper programs, I'd strongly recommend avoiding hobbyist github projects, including everything labelled 'Arduino'.