Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ranaaich · Mar 04, 2017 at 08:58 AM · load asset

Dynamic loading of textures - looking for best appraoch

In my unity project I have huge number of textures(frames) as assets. Around ten thousand. Basically these are collection of frames from a video shoot. If I try to use Resource.Load() for all of these frames in start() method then my unity project takes almost 5/7 minutes to run. So, this approach is not fruitful at all.

Analog electrical signals are coming from two Steppers (left and right) and the Unity is processing them. When the signal is detected from the Stepper I will have move forward 15(size of each step) frames at a time.

To do this kind of operation I have defined an array of size 15. Now in the start() method I load this array by first fifteen frames from my resource directory.

Now suppose the signal comes from the left Stepper, which is captured in update() method. In the FixedUpdate() I traverse this Array and render the frames one by one. After rendering I clear this array with Array.Clear(...) and load it with next 15 frames.

So when the next signal comes from the right stepper - these frames from the Array are also rendered one by one. So far so good.

The problem is - when the Stepper speed gets bit higher it sends signal more frequently and as a result Unity crashes.

What would be more efficient way to tackle this kind of scenario.
Should I use two Arrays (one for left, one for right) so that there is considerable lag. I'm trying to keep the solution simple in the sense that I'm assuming left-right-left-right...Stepper sequence for the time being.

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 hexagonius · Mar 04, 2017 at 12:10 PM 0
Share

sounds like a lot of data. What's the reason for the crash? Is it memory?

avatar image tinglers · Mar 04, 2017 at 03:02 PM 0
Share

does increasing the array size help?

avatar image Bunny83 · Mar 04, 2017 at 03:46 PM 0
Share

There is a lot important information missing:

  • What target platform?

  • Do you have some constraints on memory? Or what's the memory amount that you require?

  • What's the image size of one "frame"? (width x height)

  • What exactly do you mean by "rendered one by one"? Do you render one image every "frame" or Unity, do you draw the images next to each other as some sort of list? Why do you use FixedUpdate ? FixedUpdate has nothing to do with rendering so it's use here seems very odd.

  • How do you actually get the information from your stepper?

  • What do you consider a "higher speed"? What's the "normal" (or acceptable) speed in actual time units?

1 Reply

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

Answer by Glurth · Mar 04, 2017 at 05:13 PM

I would recommend the implementation of a "circular cache buffer" to store the frames. This kind of buffer is a specified size (usually a few seconds of playtime), and has TWO indexes; a read index and write index. The indexes are incremented such that when they reach the end of the array, they loop back to the start (thus: "circular").

The operations used to fill the next element of the array, at the write_index, are performed constantly/every update, for some specified amount of time, or until the write_buffer_index reaches the element before (circularly) the read_index_buffer. This way, when a read operation is performed, and the read index is increment, it will automatically load new data "behind" it.

Once you have this in place, you stepper "play" commands simply trigger the system to start drawing the next 15 elements in the circular cache buffer.

Watchout: if you are "playing" the frames faster than you can "load" them, your read index will eventually catch up to your write index! Not sure what you want to do in this situation; I would probably pause "playing" for a few seconds, while it buffers/loads more frames.

Comment
Add comment · 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

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

7 People are following this question.

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

Related Questions

Standard assets problems 0 Answers

how to solve Texture is not accessible error and Can't read from cubemap error? 0 Answers

Do all assets from Assets folder is loading into memory? 1 Answer

Loading external file after build 1 Answer

Exporting Assets Bundle with Lightmaps included possible? 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