Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

RenderTexture on GUI crashes application

Discussion in 'PSM' started by GMM, Apr 15, 2014.

  1. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    Hello guys.

    I am currently trying to convert my camera handling system to the Vita, but it seems like no matter what i try, the application crashes whenever i try to send a RenderTexture to the GUI.

    Code like this seems to work on PC, but i cannot seem to figure out why this cannot work on the Vita:
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class SimpleRenderTex : MonoBehaviour
    5. {
    6.     private RenderTexture renderTex;
    7.     private Rect viewRect = new Rect(0,0,Screen.width,Screen.height);
    8.    
    9.     void Start ()
    10.     {
    11.         renderTex = new RenderTexture(128,128, 24, RenderTextureFormat.RGB565);
    12.         renderTex.Create();
    13.        
    14.         camera.targetTexture = renderTex;
    15.     }
    16.    
    17.     void OnGUI()
    18.     {
    19.         GUI.DrawTexture(viewRect, renderTex);
    20.     }
    21. }
    22.  
    Now, the problem does not seem to be in the actual GUI aspects of things since it will still crash without the GUI.DrawTexture aspects included, so i will assume that the main problem is when the system creates the 128x128, 24 bit rendertexture. Rendering from camera to a rendertexture in the editor does seem to work, but i cannot seem to get it to work from code.
     
    dan_ginovker likes this.
  2. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Try a different render texture format. There should be some more examples on the wiki.
    Code (csharp):
    1. 16,16, TextureFormat.RGB24
    2. 4, 4, TextureFormat.DXT1
    Also try this, theres a render textures support option at bottom:

    Code (csharp):
    1. function ShowDevice() {
    2.     GUILayout.Label ("Unity player version "+Application.unityVersion);
    3.     GUILayout.Label("Graphics: "+SystemInfo.graphicsDeviceName+" "+
    4.     SystemInfo.graphicsMemorySize+"MB\n"+
    5.     SystemInfo.graphicsDeviceVersion+"\n"+
    6.     SystemInfo.graphicsDeviceVendor);
    7.     GUILayout.Label("Shadows: "+SystemInfo.supportsShadows);
    8.     GUILayout.Label("Image Effects: "+SystemInfo.supportsImageEffects);
    9.     GUILayout.Label("Render Textures: "+SystemInfo.supportsRenderTextures);
    10. }
     
  3. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    Thanks Jesus, i will try this out.
     
  4. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Just tested the show device info on mine..
    Graphics PSVita GXM 104mb
    Says shadows, effects and render textures do not work, but they do as I've got render to textures and shadows haha

    So ignore the device info, its wrong, but still try out the different texture formats, link here.
    http://docs.unity3d.com/Documentation/ScriptReference/RenderTextureFormat.html



     
  5. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    ARGB32 seems to work pretty okay for me, but i will have to see if other formats work better. Thanks for the help!