• 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 tvwxyz · Jul 29, 2014 at 02:21 AM · coroutinelong

Coroutine with a long procedure?

I have a terrain generating procedure that takes 30-60 seconds to run every time it's called and works to my satisfaction. I might be able to optimize it a bit so it doesn't take quite as long but will still take several seconds to run. (The procedure has several nested loops.)

I want to display a "loading..." screen so the user doesn't think the game crashed. I understand how to use coroutines but it seems like I will have to create several methods that perform specific steps of the procedure and have the coroutine constantly check their status until they're finished.

Any ideas on the best way to do this? (Let me know if my explanation needs clarification.)

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

Answer by smallbit · Jul 29, 2014 at 02:35 AM

If it only takes several seconds, you can just do some simple animation that is not related to the real progress of generation i.e. loading bar in windows, or loading texts with dots.

Than if it goes longer than that, you can distract user by showing the actual activity, like they do in Sir you are being hunted, or minecraft (i.e. generating north clusters etc, which will be displayed on entering to each of your loops). You also can print out time.time of finishing each of your loops (in editor), and assign them estimate progress (like 20%, 50%) than display it on the screen along with the info what the game is doing right now. This should calm the user.

Finally you can estimate more precisely how much does each step take from overall loading time, each iteration of each inner loop and show the more precise progress based on that. Or you can count the outcome (number of triangles etc.. in the generated scene in the scene (in editor mode)), and than calculate percentage on run via currently generated/maximum counter. This is however complicated, and user does not need to know it exactly.

One advice I've seen a lot, is to put a "Hint of a day" field on the loading screen (.i.e you can get better loot from higher level enemies etc..) this always takes users mind of the loading time. I've seen somewhere multiple hint changing each 5 secs or so.

Hope it will give you the idea !

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
avatar image
0

Answer by tvwxyz · Jul 30, 2014 at 02:23 AM

For those interested, here is a link to the solution I'm using until I get Unity Pro... http://chicounity3d.wordpress.com/2014/01/25/loading-screen-tutorial/

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Coroutines and waiting for a function to finish execution 1 Answer

Yield everytime boolean is True (C#) 1 Answer

How do I use Yield in C#? 3 Answers

Animation Event issue what am I doing wrong here 2 Answers

Activating 3 rotations based on multiple presses on one key 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges