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
2
Question by Fattie · Feb 04, 2013 at 11:10 AM · texture2dresources.loadhiccuploadleveladditiveasync

Resources.Load ... async ? For large images.

Note .. for 2016+ Unity have indeed recently added LoadResourceAsync which can be relevant.


Essentially, is there a Resources.LoadAsync ... or has anyone come up with a similar solution?

When loading a large texture (a PNG) using Resources.Load, a game will hiccup for 1/2 second.

is there a solution?

I'm thinking, one might be able to use the Application.LoadLevelAdditiveAsync command in Unity,

load a small fake "level" that contains nothing other than the texture in question.

Any experience with this?

The only other idea I had was, cut the image into tiny pieces, small enough that unity does not stutter on a Resources.Load. Load each one with a gap of a couple frames between each, and paste together.

Any thoughts on loading large images on the fly with no stutter? Cheers

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 Fattie · Feb 04, 2013 at 04:15 PM 0
Share

intriguing ... you can indeed stream it in with WWW using the Strea$$anonymous$$gAssets folder.

 var thePath:String = System.IO.Path.Combine(
    Application.strea$$anonymous$$gAssetsPath, "large.png");
 Debug.Log("thePath is "+thePath);
 var w:WWW;
 w = new WWW( "file://" + thePath);
 yield w;
 tempTexture = w.texture; .. etc

BUT ... I have found that IT STILL HICCUPS. (For large images.)

I believe the problem is creating the openGL texture. No matter how well it streams in the PNG, you'll get a major hiccup when it makes the texture. There seems to be no solution for this.

Thanks as you guys exactly answered the specific question stated .. it's WWW to stream stuff in, use file:// and StreamignAssets folder.

avatar image Wolfram · Feb 04, 2013 at 04:31 PM 0
Share

Do you use w.texture directly, or do you create a Texture 2D from that? In case of the latter, you can try an uncompressed format (TextureFormat.ARGB32), they are much faster to generate than compressed textures. Not sure whether this is also true for iOS, though.

avatar image Fattie · Feb 05, 2013 at 06:19 AM 0
Share

Wolf, I did try using w.texture directly, no difference.

I did use uncompressed formats and tried many.

It's really a shame that I can't find a way to simply stream a largish image from "disk" during gameplay.

After all, strea$$anonymous$$g audio (even enormous sounds) for sound effects etc during gameplay works perfectly in Unity, with no hiccup.

Indeed note that I tried it with images as small as 250.250 and it still hiccups.

A bit of a mystery / problem .....

thanks for your input!

1 Reply

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

Answer by Wolfram · Feb 04, 2013 at 11:30 AM

You will have better luck using the WWW class. It can load in the background, yield until it's finished, and then you have your image available, without, or maybe very little lag.

Comment
Add comment · Show 4 · 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 Landern · Feb 04, 2013 at 01:47 PM 0
Share

you can use file:// to retrieve local, as a matter of fact there was in bug in 4.0, fixed in 4.0.1 for doing just this.

avatar image Wolfram · Feb 04, 2013 at 01:51 PM 0
Share

It accepts any URL, therefore also local objects. In addition, it does not restrict you to your project folder (except maybe on $$anonymous$$obiles). We use it for example to load tons of videos on-demand from the User's Documents folder. This also reduces your build size, but you'll have to ship the image/video data separately.

avatar image Wolfram · Feb 04, 2013 at 01:59 PM 0
Share

Just don't use File:/// on your $$anonymous$$ac, it will crash the application ;-) (sorry, can't seem to find an English article about that).

avatar image Landern · Feb 04, 2013 at 02:43 PM 1
Share

English Article

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

11 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

Related Questions

When generating prefab, i cant load images from either resource or assetbundle 2 Answers

Displaying an image from a resource folder. 2 Answers

Resources does load up in the editor but not in build 0 Answers

Sphere with texture using C# scripting 1 Answer

Why does the behavour of my script change when it is built? 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