how to transfer data to unity efficiently

I’m in the early stages of programming a sort of adventure game. It’s mostly based in java using android activities, but there’s one activity that I embed unity in so I can get some awesome battle scenes :slight_smile: I’m programming the unity side in c#. I’ve basically hit a bit of a mental block in my head. I know how to call c# methods from java and vice versa but I don’t know how to do this efficiently with a lot of data. As I start the unity instance I need to send it the following data:

  • list of entities that the player and opponent has ‘equipped’
  • list of items both of them have in their ‘bag’

Then for each entity things like:

  • health
  • moves the entity knows
  • more things like this as game evolves

I’ve got it all nailed down as classes in java and c# but obviously I can’t send classes across different languages… So I’m stuck…

I also want to keep this all as DRY as possible, it’d be nice to not have to repeat things like item descriptions in java and the c#(as I’d like the user to be able to access their items in some android activities as well as inside unity)

Thanks

I’d say the best way to transfer data to unity would be to write them to a text file in temp directory, and then let unity read that text file when it loads.

Note that I’m not sure your solution is such a good one, since loading unity player on mobile devices could take some time, and it would be annoying for the player to wait for it to load before every battle.