Search Unity

Reading from the screen is not allowed when you have used a downloaded texture

Discussion in 'Scripting' started by fasilpv, Feb 16, 2011.

  1. fasilpv

    fasilpv

    Joined:
    Mar 19, 2009
    Posts:
    9
    Hi,

    I get the following exception when I tried to call ReadPixels from texture. Can you guys please help to solve this issue. I am using Unity3.2 version

    The call I am making is this

    tex.ReadPixels(new Rect(0, 0, camera.targetTexture.width, camera.targetTexture.height), 0, 0);

    and the exception is

    SecurityException: Reading from the screen is not allowed when you have used a downloaded texture without proper crossdomain.xml authorization
    UnityEngine.Texture2D.ReadPixels (Rect source, Int32 destX, Int32 destY) (at C:/BuildAgent/work/f724c1acfee760b6/Runtime/ExportGenerated/Editor/Graphics.cs:1089)

    Thanks, Fasil
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    please read the security sandbox on unity 3 webplayer page in the manual.
    generally: if you download textures from an unsafe (ie not crossdomained) place, it is readlocked and you can't access it to send it in some form to another place, thus a required measure to prevent data theft - while still allowing people to get images from google or facebook etc
     
  3. fasilpv

    fasilpv

    Joined:
    Mar 19, 2009
    Posts:
    9
    Thanks for the reply. But in this application, I do not download textures from unsafe place. That is, I just create a new texture dynamically like this,

    tex = new Texture2D(256, 256, TextureFormat.ARGB32, false);

    and call tex.ReadPixels() method. Please let me know if I am wrong.

    -Fasil
     
  4. fasilpv

    fasilpv

    Joined:
    Mar 19, 2009
    Posts:
    9
    This issue noticed only in one machine. Is it machine specific issue?
     
  5. Ming

    Ming

    Joined:
    Sep 21, 2011
    Posts:
    2
    I also am having problems with this SecurityException. However, I'm not using any downloaded textures as far a I know. In fact, it works perfectly once compiled into a .unity3d file and accessed from the web. It's only broken when trying to run it in the editor.

    To my dismay after many hours of investigating the wrong things, I discovered that in this setting:

    Modified Project->Settings->Editor

    I had https://yourhostsite.com/game.unity3d instead of http://yourhostsite.com/game.unity3d

    thought I'd share in case anyone else out there is as dumb as me.
     
  6. KarolD

    KarolD

    Joined:
    Oct 23, 2012
    Posts:
    12
    Sorry for necroposting, but I get the same exception and it's not the case Ming is mentioning.
    Any other ideas ? I get this exception but I do not use ReadPixels anywhere in my code.. though I use some plugins, but I don't even know how to trace which it might be, because this error tells me nothing..