Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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:
    378
    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:
    378
    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!