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 neo · Jan 09, 2011 at 12:14 PM · iostextures

Is it possible to turn JPEG images into textures at runtime in Unity on iOS devices?

Note: High level answers of the type "Read the documentation on the XXX function" appreciated here. I'm not sure where to begin researching a solution for this because everything I've done before has used PNGs built into the project.

Question: I've got an app I want to build in Unity. The app takes information from an RSS feed provided by a third party (under license, I'm not stealing, but they control the format of the data, not me.) I need to take that data an parse it and pull out text and images. I want to put the images into textures on objects in Unity.

I can use an RSS parser in objective-C. I have unity Pro, so I can use the "native code" functionality here. But I am curious how I take the JPGs (whose URLS are in the RSS feed) and convert them into textures I can apply to objects within the Unity Scene.

The JPEGS are of a uniform size. The meshes they will be applied to are all instantiated from the same prefab and are identical, except for the texture.

I can likely convert them to PNGs on the Objective-C side. So, maybe my question is: How do I create a couple hundred instances of a prefab, all of which have the same material, but each of which has a different texture?

Or can I programmatically create materials from JPEGs?

Maybe the process is, turn them into PNGs, move them from the Objective-C side and then create materials on the fly?

Appreciate any pointers if there is an easier way to do it, or if there's any gotchas I need to watch out for.

For instance, I understand that the Unity development environment does some processing to optimize textures during build, and I'll need to somehow make my images be in the right format for feeding to the game engine, at runtime.

Thanks.

Comment
Add comment · Show 2
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 neo · Jan 09, 2011 at 12:44 PM 0
Share

Found Texture2D.loadImage which takes a TextAsset and apparently works with JPEGs, which solves part of the path. If the format is DXT1 then the resulting image will be compressed. Is this compatible with iOS? (EG: create a Texture2D with DXT1 format, then use loadImage and feed it an array of jpeg bytes?)

This seems like a solution, the only method that I could find for loading an image into a texture at runtime, but TextAsset seems to be designed to work with txt files in your project. I can't create one by loading an image from a URL.

avatar image neo · Jan 09, 2011 at 12:55 PM 1
Share

Ah, looks like WWW.Texture is what I want.

0 Replies

· Add your reply
  • Sort: 

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

No one has followed this question yet.

Related Questions

Some textures don't load on iOS 0 Answers

A node in a childnode? 1 Answer

Why a 109kb .png file teakes 8mb in unity? 1 Answer

u3dxt causing failed validation 2 Answers

Some textures on iOS build are black?!?!?! 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