Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

532
Vistas
API agnostic Vector3, Matrix, etc.?

I'm trying to keep my game logic API-agnostic. In doing so, I don't want to use Unity3D's Vector3 struct, or XNA's, etc. What's the best way to do this? It seems like it would be awfully cast-heavy if I rolled my own Vector3 struct and just wrote implicit converters to the various API implementations.

Is there a best practice for this kind of thing? It's not like I can ask Microsoft, Unity, etc. to have a picnic and adhere to a common interface.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

It looks like XNA and Unity implementations of Vector3 are really similar, the main difference being the case of property names. Too bad there's no way to implement extension properties.

What you could do is create a set of extension methods, together with some conditional compilation (#if UNITY_3_3 or #if XNA) and exclusively use those extension methods to retrieve values in your API agnostic code. This would still allow you to pass the Vector3 object unmodified to platform specific code requiring Vector3's without tons of casting.

over 4 years ago · Santiago Trujillo Denunciar

0

Based on my experience, I would select one platform to write your logic to, and then, on the other platform, create a matching implementation with conversions to the platform's native types. There's no point in designing and writing a third implementation and then having to do conversions to both platforms!

All platforms being equal, I would probably favour XNA's, as you can grab an open source implementation from MonoGame or (eventually) ExEn and use that.

However, in practice I think you're probably best off to start out with the platform you intend to develop on (XNA or Unity) and then create your compatibility layer once you actually need it.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda