Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by cowlinator · Jul 02, 2013 at 12:11 AM · texture2druntimedimensionsloadimage

Change texture non-power of 2 setting at runtime?

We have an app that downloads images and creates textures from them using Texture2d.LoadImage() while you are using the app (runtime). These textures are used in the GUI.

Unfortunately, the textures created from these images look like crud, because Unity automatically scales them for power of 2 dimensions.

I know you can change a texture to a gui texture in the inspector, or you can use TextureImporter.npotScale = TextureImporterNPOTScale.None in an editor script, and the problem will be solved.

My question is, is there any way to accomplish this or any similar solution or workaround at runtime?

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 CyberMew · Sep 05, 2013 at 04:49 PM 0
Share

I would like to know this as well!

Since it automatically scales it to the nearest power of 2, the current workaround is to manually create the images with those dimensions in $$anonymous$$d, which is reallllly bad.

avatar image FrimaMickD · Sep 05, 2013 at 05:07 PM 1
Share

I did not try this myself but out of curiosity, doing something like this does not work? : Texture2D test = new Texture2D(100,100); test.LoadImage(myData);

Another solution might be to load the image using LoadImage and THEN creating another texture of the wanted size (say, 100x100) and using GetPixels() and SetPixels() to fill it correctly.

Just thinking out loud, did not try myself.

avatar image ArkaneX · Sep 05, 2013 at 09:23 PM 1
Share

$$anonymous$$aybe I'm missing something, but loading image bytes into texture after downloading it with WWW class work just fine for me. $$anonymous$$y image is 1920x1200, and the resulting texture has the same dimensions. Nothing gets scaled to POT. Displaying it in GUI works ok as well.

1 Reply

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

Answer by cowlinator · Jun 21, 2014 at 01:40 AM

I forgot about this question. Anyway, I figured this out.

 new Texture2D(...) 

does not, in fact, coerce a texture to be a square power of 2. The reason my textures looked like crud is that mip-mapping is turned on by default, and for whatever reason, unity sometimes uses smaller mip-maps for ui elements.

to turn off mip-mapping, use

 new Texture2D(w, h, textureFormat, false)

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 esanuriana08 · Mar 26 at 10:01 AM 0
Share

Thanks brother. its zuperr 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

19 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

Related Questions

White Edges on Sprites Loaded from PNG at Run-time 0 Answers

iOS crashing on Texture2D LoadImage 1 Answer

How to load an image at runtime via WWW correctly 1 Answer

Can't Resources.load new generated texture2D as lightmaps at run time 0 Answers

Capture screenshot to texture, memory issue 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