Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

535
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda