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 ullman · Dec 28, 2014 at 10:35 AM · textureresources

Resources folder, works in editor, doesn't work in runtime

So here's the deal. I have a script thats supposed to load a texture, Resources/myTexture, into a GUI rect. I test this in editor, and everything seems to be fine. I create a standalone game, and no texture loads. I've cross checked the names again and again, spent a whole day on it, and don't seem to be able to figure it out. This is an edited version of the code:

 t = Resources.Load("myTexture") as Texture2D;
 Rect r = new Rect(0, 0, width,height);
 GUI.DrawTexture(r, t);

works perfectly in editor.... any help on how to figure this problem out would be great. I'll update this post if I figure out anything else

Comment
Add comment · Show 3
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 Graham-Dunnett ♦♦ · Dec 28, 2014 at 10:36 AM 0
Share

Try adding Debug.Log(t) after the Load. $$anonymous$$aybe the texture isn't written into the Resources file?

avatar image ullman · Dec 29, 2014 at 01:04 AM 0
Share

debugging t.name gives me the right results results, no errors... which means it should be working fine. But standalone still shows nothing.

avatar image ullman · Dec 29, 2014 at 02:54 AM 0
Share

I've checked and rechecked texture names, directory, etc. Everything is what it should be. I've debugged every step.. I don't get why this should give me an error if it's working fine in the editor. Why wouldn't it find the error in the editor?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hav_ngs_ru · Dec 29, 2014 at 07:56 PM

Try to GUI.Label(t) in standalone instead of Debug.Log in editor. I guess it would be null.

If it works in editor means that your filenames are right. If it doesnt work in standalone means that you texture is not included to build by Unity.

There are two cases why resource are included to build: it is referenced by some object in scene (or by prefab included to build for some reasons), and it is in Assets/Resources folder. Try to force Unity to include your texture by making public Texture field in some script attached to some GO in your scene and attach (drag-drop) you texture to it. If in this case standalone application will work fine - the only conclusion is "unity dont want to include your resources placed in Resources folder for some reason"... it would be very strange and it will be needed to watch all your project to find issue..

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Load texture and shaders at runtime on iPhone 2 Answers

My ios Project is too big!?what can i do? 1 Answer

Make reference to the project texture file in the material field 1 Answer

Loading textures into an array after build 1 Answer

Texturing a mesh created at runtime 1 Answer


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