Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by secret-arts · Jan 28, 2013 at 01:44 AM · guidrawtexture

GUI.DrawTexture shows in Unity but not in Build

Hey folks, this issue is so strange that I'm convinced I've done something stupid.

I'm building a game with a GUI image using GUI.DrawTexture. When I test the game in Unity, the texture shows. When I build the game for Windows or Mac, it doesn't. I know it's not an issue with positioning since I'm setting it to be centered on the screen to be sure it shows up. I've also tried other GUI methods like DrawButton and DrawLabel, and they work as expected. I saw someone suggest that I remove my Scene from the build and then re-add it. This had no noticeable effect.

It might be worth noting that I'm porting my code from Javascript to C#, and this exact code and image worked as expected in Javascript.

Anyway, here's my code:

     void OnGUI(){
         GUI.DrawTexture(new Rect(Screen.width * 0.5f, Screen.height * 0.5f, 112.0f, 124.0f), timerBar);
     }

Any ideas? Thanks!

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Gizmoi · Jan 28, 2013 at 01:52 AM 1
Share

Are you getting any errors? Check the output_log. Try placing Debug.Log to gain more info. I suspect the timerBar may be null for some reason. How are you getting that?

avatar image secret-arts · Jan 28, 2013 at 02:21 AM 0
Share

Hi Gizmoi, it's true, timerBar is ending up as null, but I'm still not sure why. I'm setting it in the inspector, as I've done for several other Textures that work just fine. I'll keep sifting through the logs.

avatar image Gizmoi · Jan 28, 2013 at 10:21 AM 0
Share

Perhaps its not getting imported correctly?
Is the object this script is on instantiated at runtime or a prefab, or both?

avatar image secret-arts · Jan 28, 2013 at 07:47 PM 0
Share

The object is is a prefab. I can add another prefab object that uses the same Texture as I'm trying to use for the GUI, and it appear with no problem. When I swap in a different Texture for use in the GUI, and it also won't load.

After trying everything I could think of, I finally just tried a workaround-- to load the Texture at runtime using Resource.Load, which worked fine. I'm a little concerned though, since this I was just trying to test out a GUI element to see how it looked, and I've got a bunch more elements to incorporate. It wouldn't be much of a pain to load them all at runtime, but I'd rather know what caused the problem.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Elringus · Jul 13, 2013 at 12:52 PM

I'm having very similar issue right now. The only difference is that I’m using DrawTexture method only on repaint and with custom material (particle-additive):

 void OnGUI () {
     if (Event.current.type.Equals(EventType.Repaint)) 
         Graphics.DrawTexture(new Rect(), texture, material);
 }

Also, I’m using some post effects (image effects) on the main camera.

I found, that turning all the image effects off lets the texture show up in the build. Then you can enable them again, and texture will continue rendering normally.

I just sent bug report with repro project and hope that Unity will fix it someday…

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by fabio1955 · Mar 04, 2014 at 01:07 PM

I have already met this problem on a AMD card. I found a solution here: http://varuagdiary.blogspot.it/2012_01_01_archive.html.

The trick is to take off the alpha layer of the render texture during postrender. It works!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fabio1955 · Mar 06, 2014 at 09:18 AM 0
Share

Did you solve this?

avatar image secret-arts · Mar 06, 2014 at 05:26 PM 0
Share

Unfortunately this project went live long ago-- I'm convinced that in my case it was a problem with the project itself, since to 'solve' it I created a new project, copied over my assets and code, and everything just worked.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using Grayscale Textures For Transparency 1 Answer

GUI.DrawTexture not working? (nothing shows up) 1 Answer

Display GuiTexture in front of Gui.DrawTexture 1 Answer

[Closed]GUI.DrawTexture inside GUI.DrawTexture 1 Answer

inventory system - change GUI.DrawTexture texture 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges