Unity running in the background with network

Hello,

First of all excuse me if the question is not precise and for the long description.

I want to build an app/game and am facing doubts if I have to build it with unity or unity+wrapper app( if possible ) or not using unity at all( not perferrable ).

The gameapp :slight_smile: is targeting the usual ios,android and window mobile. The gameapp should have two( maybe three ) main statuses …

1.The app is idle: in which the app should run and listen/check for notifications from the server at a low-rate intervals to optimize battery drain , bandwidth etc. It’s not essential to have this state but it’s a huge plus.

2.The app is in a non-game mode where the user can be active in the game( conttrolled by the server ), but not playing( unity doesn’t have to receive messages or be active )

3.From time to time the app initiates mini games. I really want to use unity, because of it’s ease of use, cross-platform compilation, already know javascript, have a lot of experience in flash/as3/flex , coded in c++ for an year and a half, the benefit of the great ide of unity etc … and also … I want these small games to rock for sure :slight_smile:

I want the app to be optimized at max( I know the native development solution, but I’m an Indie ), so it will be perfect performance-wise to write the app in some framework like appcelerator and then use the code generated from unity and somehow connect it. I’m even keen on writing a wrapper app that just handles the server communication and then initialize unity whenever needed.

If you ask me I would build the whole thing in Unity, so I can have even better( why not 3d ) UI and maximum UX, but the thing that most concerns me is the idle period( possibly even when phone is locked ), and also the non-game state. In these states( as I’m planning,but still not sure if possible ), the app should have constant communication with the server( again at low-rate with disconnnection fallback ). Is it possible to have unity enter at 1fps. I checked the Application.targetFrameRate, but does this mean only the rendering is executed just once and having a core application method and additional logic running 2000 times/sec in the meantime ? Also I believe the Unity engine( as a game engine ), is written so methods inside are executed consecutively in a specific order( as it has to be ).Is it possible to insert logic for a non-game purposes that runs at specific intervals( game engine is not running ) and then initiate the game logic( initialize the whole engine & run ) , then stop the game logic and reinitiate again at a lowest possible framerate/cycles/iterations/operations ?

So to summarize all the questions:

  1. Can unity have a state where it is running at a really optimized level. Invoking methods/operations that only I/me have defined and not core engine logic running ( or at least a few ones ). Something like a pre-run method that defines the pre run logic with timers calling specific/custom methods only when needed. Or something like a plug-in that’s executed before the main core logic ? Maybe the question is … Can unity implement Background Fetch functionality of ios7 ?

  2. Does the previous question make sense ? Or maybe I shouldn’t even bother about this if I switch the app from 30 to 1 fps between states( or even turn off the render in certain state ) ?

  3. What do you think of the idea of using the generated source code and wrapping it in another native app ( or another framework ) ? I even thought of having two separate apps and have seen ( in android ) one app switch to another( button in app A opens app B) and share common data.

I hope you can help me ( for sure you already feel close to me, spending all this time, reading this 100 pages poem )…

Thanks :slight_smile:

Maybe. Drawing (or even try to draw) OpenGL in the background will kill your app immediately. You could implement background fetch for iOS 7+, but you’d also need to tweak the app delegate to prevent the Unity engine from starting up in this cases. Background fetch is not reliable though, you don’t know how often it will run, if at all.

Turning off the rendering engine in the background is your only solution for this.

Data sharing isn’t really possible on iOS (pre-iOS 8) to do two separate apps. You’d need to do a fair bit of native work to get this even remotely close to what you want, I don’t think another framework would do you any good.

Hey … Thanks a lot for replying .

I knew it was going to be a tricky one
Thanks anyway