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
1
Question by rule62 · Mar 07, 2011 at 12:05 AM · textcoroutineread

Intermingled Read and Render?

Here, we're reading a text file for coordinate data. We'll want to generate meshes and render them. (or use prefabs)

Is there a way to instantiate and render as we read along? Rather than read everything and then render everything? So, we get a sort of "popping" effect.

Although I haven't used them, I'm guessing this is a coroutine deal where the reading is held up while the render is done?

thanks

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

2 Replies

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

Answer by Statement · Mar 07, 2011 at 12:23 AM

  • You could make use of threads for the file access if you need this to be done runtime.
  • You could amortize the construction of meshes early and create a list of Meshes.

A coroutine might work if you use the WWW class. Otherwise a coroutine won't be of much use unless you load a few bytes each time.

If you need to continuously stream data, I think a thread could be proper. That way the rest of the game continues even if the load takes some time.

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 rule62 · Mar 07, 2011 at 12:36 AM 0
Share

Yeah, that's basically what I'm getting at. I'd like to start rendering with some of the data to keep the user's attention while the code reads/processes the bulk of the data.

avatar image rule62 · Mar 07, 2011 at 12:37 AM 0
Share

Yes, it looks like threads is what I'm after. I never done used no threads before! I'm frightened!

avatar image Statement · Mar 07, 2011 at 02:00 AM 0
Share

Using threads is quite easy with .net. Synchronizing data between threads can become a bit trickier. Also note most unity methods aren't usable from another thread. One way I prefer is to have a synchronized queue. A thread produce something, puts it in the queue and continues producing something more. The main thread can then check each frame if there is anything in the queue and take it.

avatar image Statement · Mar 07, 2011 at 02:01 AM 0
Share

http://msdn.microsoft.com/en-us/library/system.collections.queue.synchronized.aspx

avatar image
0

Answer by Eric5h5 · Mar 07, 2011 at 12:59 AM

Unless you have a massive amount of data or your code is bad, it would only take a fraction of a second anyway, so it's unlikely you need to worry about it.

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 rule62 · Mar 07, 2011 at 01:49 AM 0
Share

hmmm... it's less about the read time and more about some of the processing of the data prior to rendering. Upwards of 2 $$anonymous$$utes.

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

Why does accessing www.text blocks the coroutine using WWW class? 1 Answer

Line Reading 1 Answer

How to read particular line from *.txt file? 1 Answer

Read text from http 2 Answers

Reading from a .txt file until a certain character is detected 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