Trying to display a screen capture as a loading screen.

Hey guys,

So I’m building an online game. The programming allows players to easily jump through different rooms/server instances in a sort of semi-dynamic way.

I am using Photon to aid in the server programming, and switching between rooms requires that I re-create the player in the new room as his server instantiated object gets destroyed automatically (I’ve looked at ways of avoiding this to do it manually, however automatic cleaning works much better for what i’m doing).

So, to counter the brief moment that the player model doesn’t exist when switching rooms, I am displaying a loading screen. Initially (during early development) I was just displaying a black screen with a “Loading…” image planked ontop, which in my oppinion is very disruptive to the whole experience, so ideally I am trying to look at the option of displaying a screen capture of everything on the screen just before the player’s model is destroyed and using that as the loading screen, to make the loading process a little less obstructive.

Things I have tried so far:

  1. My first attempt was done by utilizing the way that the camera works. Inititally, I would disable the camera just before the player’s model was destroyed and then re-enable it once the new copy is instantiated on the other end, and the screen would display the last frame that was rendered before the camera was disabled. This worked okay sometimes, but most of the time caused weird camera jittering effects, particularly to GUI elements. I spent hours trying to work around this problem and wasn’t able to find a solution.

  2. The next attempt was pretty similar to the above, except instead of disabling the camera, I set changed the culling and clearing mask to effectively look like the camera had frozen on a frame. This also worked occasionally but had the same problems as in 1).

  3. My recent attempt involved storing the screen in a Texture2D object, using the ReadPixels method, and then displaying that as a GUITexture on the screen. This has produced the most solid results so far, however the process occasionally takes longer than I need it to, sometimes causing the texture to not display properly because it hasn’t been able to read the pixels quick enough. I would need to be able to display the texture almost instantly at the point that the loading screen should appear, otherwise the whole process wont look smooth.

Is there possibly another way that I could attempt to do this, or am I going to have to go back to displaying an obstructive loading screen?

It would be worth noting that I don’t have Unity pro, so RenderTexture isn’t available to me =[

Many thanks in advance for any suggestions.

I hate to be the one to say this, but I think Unity Pro is you’re only real option. If speed wasn’t a concern, then your 3rd approach would be fine, but that will always be very slow, especially at higher resolutions, older computers, mobile, etc. Given that you want something close to instantaneous, nothing that I can think of will get you there except a RenderTexture.

If you just want to hide the transition, you might consider a screen-glitch type effect, like on an old analog TV, or the same idea but with something more fitting to your art direction. You could do it over the whole screen or just around where the player is/was.