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 pateras · Jun 27, 2013 at 03:20 PM · textureimportwebplayer

How can I set texture import properties at runtime? Must work in Web Player.

I have a PNG texture sheet that I'm generating, and it's not rendering in my NGUI atlas properly because the import properties are just the simple default settings. If I save the texture, import it into Unity, and modify its import settings, it renders properly. Now I need to figure out how to do this at runtime in such a way that works from the web player.

Texture2D has a few properties on it that look like they do at least some of what I'm looking for, but they don't seem to make much of a difference. Here is how I'm generating the texture sheet:

 List<Texture2D> textures = CreateTextures(parsed);

 Texture2D packedTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);

 var coordinates = packedTexture.PackTextures(textures.ToArray(), 1, 4096);

 packedTexture.filterMode = FilterMode.Point;

 File.WriteAllBytes(Application.persistentDataPath + "/Tester/output.png", packedTexture.EncodeToPNG());

When I run that, it outputs the texture to that provided directory, and when I load that into Unity, its import settings are still the default (for example the filter mode is bilinear).

How can I, in code, set the texture's import properties, from the default (on the left in the below picture) to more advanced settings (on the right):

http://i.imgur.com/4Q4GJfV.png

Remember, this has to work from the web player, so anything in UnityEditor is out.

Thank you.

Comment
Add comment · Show 1
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 humam · May 17, 2017 at 10:09 PM 0
Share

@pateras did you find the solution to it?

I have the same code as yours and I have to update Import property read/Write enabled on the fly! also This texture is overwritten (re-created; by drawing more on the previously saved texture from the previous iteration ) in every iteration!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Graham-Dunnett · Jun 27, 2013 at 03:54 PM

The webplayer has zero access to the file system of the machine where it is running. To procedurally generate a texture you'll need to do it entirely using Unity API calls. So that basically means setting pixels using `SetPixels`.

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 pateras · Jun 27, 2013 at 04:23 PM 0
Share

I don't see what SetPixels gets me. I'm already creating the texture, I just need to set its properties so that it's rendered properly (e.g. filter mode).

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

17 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

Related Questions

How to keep texture resolution from blender? 1 Answer

How to import textures from photoshop to unity perfectly? 1 Answer

Texture color is not right after import 0 Answers

Compressing a texture imported with www class 0 Answers

Cannot enable mip map generation in advanced import settings for any texture/sprite? 2 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