• 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 danielmterry · Dec 30, 2016 at 09:35 AM · androidtexturevrimageruntime

Loading 8192x8192 textures at runtime on android

I'm using 8192x8192 truecolor textures in my android project and they work fine when used normally, but now I'm trying to switch to load them at runtime from the streaming assets folder using WWW.LoadImageIntoTexture. (note: I'm doing this because when they are not in the streamingAssets folder the bundle is very large; each 20mb image becomes 256mb).

This works fine when the build platform is standalone but when I switch it to android and run it in the editor I just get a blue texture rather than my image (similar result when running on a device except it's black).

A simplified project with just a 20 line script and an image (20mb) is here: https://drive.google.com/file/d/0ByNPa9Pa1jJ8YVZ1TDdISzFpb3c/view?usp=sharing

Full Script:

public class OptimizationTests : MonoBehaviour {

 WWW localFile;

 void Start()
 {
     string path = "file://" + Application.dataPath + "/StreamingAssets" + "/8kimage.jpg";
     StartCoroutine("LoadTexture", path);
 }

 public IEnumerator LoadTexture(string absoluteImagePath)
 {
     Texture2D texture = new Texture2D(4, 4, TextureFormat.RGBAFloat, false);

     localFile = new WWW(absoluteImagePath);
     yield return localFile;

     localFile.LoadImageIntoTexture(texture);
     GetComponent<Renderer>().material.mainTexture = texture;
 }

}

Comment
Add comment · Show 6
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 tanoshimi · Dec 30, 2016 at 09:43 AM 0
Share

You need to use logcat to find out what's going on on the device but if you're planning to release this I'd recommend you reconsider your texture size - I own 4 Android test devices and I think only one of them will handle textures that large.

avatar image danielmterry · Dec 30, 2016 at 03:19 PM 0
Share

Thanks for the reply. It's not a device issue because it happens in the editor as well, but I have also looked at the logcat output and there is no additional info. 8k textures work on all devices I am supporting (it's a very limited subset).

Show more comments
avatar image QuincyC · Aug 31, 2018 at 01:55 PM 0
Share

I'm running into exactly the same problem in 2018, did you ever figure this out?

Show more comments
avatar image toddisarockstar · Sep 02, 2018 at 01:58 AM 0
Share

I agree with @tanoshimi there should be no reason you need a texture that big for android. im not sure if this helps but this has allways been the the way ive done it and it always worked for me:

     using System.IO;
 
 byte[] by = File.ReadAllBytes("filepath here");
     Texture2D paper = new Texture2D(2,2);        
             paper.LoadImage(by);

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Gear VR - photo inside sphere deformed texture 2 Answers

Loading Pictures from Android Device into game at runtime 1 Answer

Save an image to PersistentDataPath then access it again 1 Answer

How to handle many highly detailed models in a mobile device ? 1 Answer

How to change RawImage texture to another one when i press a buton for it 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