Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by rustofelees · Sep 17, 2015 at 08:40 PM · textureswww.texture

Loading PSD files at runtime with WWW

I've had much success loading png files at runtime, but am running into problems when trying to load PSD textures[same exact directory/name except for a .psd extension] in the same manner.

 public void ReloadTexture()
 {
     string fileLocation = "file://C://Users//xxx//Desktop//skins//metal_a.png";
     StartCoroutine(WaitforWww(fileLocation));
 }
 
 IEnumerator WaitforWww(string fileLocation)
 {
     WWW www = new WWW(fileLocation);
     yield return www;
 
     Texture tex2d = (Texture)www.texture;
     Debug.Log(tex2d.GetType());
     MaterialManager.SMaterialManager.humanMaterial.mainTexture = tex2d;
 }


This code runs exactly as expected, however if I change the fileLocation to point to metal_1.psd, I get a white/red question mark as the texture that's loaded into my material.

Do I need to handle psd files differently? Most of my research shows that I do not, but I cannot get a psd file to load with the same code that is successful with a png.

Thoughts?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Sep 17, 2015 at 09:03 PM

Did your research take you to the docs? Because it quite clearly says:

The data must be an image in JPG or PNG format. If the data is not a valid image, the generated texture will be a small image of a question mark

At runtime you can only load either JPEG or PNG files. No other image formats are supported. Don't confuse the Unity engine (the runtime) with the Unity editor. The editor supports much more formats. That's most the time a matter of licenses. Unity bought a lot licenses to be able to support a lot different formats. However the runtime is something different. Because if they would include software that requires a special license you as developer would have to pay for it too.

If you need support for a certain format you need to find a .NET / mono compatible third-party loader library.

Comment
Add comment · Show 1 · 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 rustofelees · Sep 17, 2015 at 09:10 PM 0
Share

Thanks for your answer! I saw that originally, tried to use this code ins$$anonymous$$d and it didn't work :

 public void ReloadTexture2()
     {
         Debug.Log("here");
         string fileLocation = "C://Users//xxx//Desktop//skins//metal_1.psd";
         
         
         Texture2D tex = null;
         byte[] bytes;
 
         bytes = File.ReadAllBytes(fileLocation);
         tex = new Texture2D(2, 2, TextureFormat.ARGB32, true );
         
         tex.filter$$anonymous$$ode = Filter$$anonymous$$ode.Point;
         tex.LoadImage(bytes);
 
         $$anonymous$$aterial$$anonymous$$anager.S$$anonymous$$aterial$$anonymous$$anager.human$$anonymous$$aterial.mainTexture = tex;
         
     }

Then I tried to go back to the WWW means, and forgot that it only supported png and jpeg files. Thank you again.

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

28 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 avatar image avatar image avatar image avatar image 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

App crashing on Ipad - suspected memory leak. 1 Answer

Resources vs Asset Bundles vs file:// 0 Answers

Possible for a shader to have two decal slots? 2 Answers

heightmap or displacement map 1 Answer

NPOT for Texture2DArray 0 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