Search Unity

Lost Graphics Device

Discussion in 'Editor & General Support' started by Xenostar, May 3, 2011.

  1. Xenostar

    Xenostar

    Joined:
    Oct 1, 2010
    Posts:
    18
    Hi,

    Is there anyway to detect when the graphics device has been lost so that when our unity webplayer becomes active again i can re render any invalid render targets that are around.

    Thanks,
    Tony.
     
  2. Xenostar

    Xenostar

    Joined:
    Oct 1, 2010
    Posts:
    18
    Bump, sorry to, but still cant find any more information on this.
     
  3. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    Hey Xenostar,
    there is no way for you to check gfx device's state, however there is no need for that either. You can simply check RenderTexture.IsCreated property. Instead of polling it every frame you can check it in MonoBehaviour.OnApplicationFocus callback when focus is false and render to your render texture then.
     
  4. Fooo

    Fooo

    Joined:
    Mar 11, 2011
    Posts:
    41
    Awesome thanks for this! I had the same issue where I couldn't find where to recreate the rendertexture!
     
  5. Fooo

    Fooo

    Joined:
    Mar 11, 2011
    Posts:
    41
    This isn't perfect though. Since if you toggle full screen manually, you'll also need to invoke your code. When you lock your computer and come back - you'll see messed up textures until you click in the window (for focus). Seems like you have to check in the update or somewhere similar for now.
     
  6. Zenix

    Zenix

    Joined:
    Nov 9, 2009
    Posts:
    213
    Is there a non hacky way to do this yet?