Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Graphics.DrawTexture doesn't work with built project

Discussion in 'Editor & General Support' started by 3Nu, Dec 7, 2012.

  1. 3Nu

    3Nu

    Joined:
    Feb 13, 2011
    Posts:
    18
    Hi guys, I'm having a problem with the Graphics.DrawTexture function.
    I neee to use this one instead of GUI.DrawTexture, because I want to update the alpha of the texture each frame. This is not possible with GUI.DrawTexture, AFAIK, because it interprets the alpha of the texture as a cut-out operation.

    Well, so far so good, until I build the project (Windows x86/x64) and the textures disappear, or they are not painted at all. I built the executeable with script debugging and all parameters are correct.

    This function seems to work only if called from OnGUI callback. Form other function such as OnPost/PreRender() (with the script attached to the camera) it doesn't.

    Any hint?

    Thanks.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    It doesn't actually do that. You can use alphaBlend = false with GUI.DrawTexture, but in that case it won't use alpha at all.

    --Eric
     
  3. 3Nu

    3Nu

    Joined:
    Feb 13, 2011
    Posts:
    18
    Yes, you are right, I can use the alpha in the texture, whatever is its value, but I can't change it at runtime.
    Anyway, the problem here is that Graphics.DrawTexture doesn't draw anything on the screen but you are running from the editor.

    Is this a bug? Could any developer repro this and let us know please?
     
  4. AlphaSilverback

    AlphaSilverback

    Joined:
    Aug 18, 2016
    Posts:
    10
    I have reproduced the error. I ran unity with both videocards and the texture and screen location are valid. The GUI.DrawTexture() function does not seem to draw the HUD I am instructing it to, even though I have multiple other textures on the near plane of the frustum.