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
0
Question by Seneral · May 10, 2015 at 06:19 PM · coroutinefunction callblockingeditorutility

Block a function over several frames

I want to achieve the behaviour observed by Unitys EditorUtility Functions OpenFilePanel, SaveFilePanel and similar which blocks the function from which it is called, while remaining the main thread active and running.

Basically, you call a function from within yours, something happens (like a window popping up), the user interacts with it over several frames, an after he finished that, your function continues. But as he interacts with the windows, the main thread continues processing everything else.

Any idea how they've done that?

EDIT: I guess not THEY have done that, rather then Microsoft themselves: The SaveFilePanel for Example, is probably just a wrapper for SaveFileDialog. Every EditorUtilitys function thus probably uses a child of CommonDialogue, yielded when called ShowDialogue.

Can any UT Guy confirm that? If it's so, I'll probably have to find another way of doing that "Block", f.E. with delegates/actions passed to the function of code that should be executed after the operation finishes.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by siaran · May 11, 2015 at 05:33 PM

with a coroutine?

something like

 bool notDone;
 
 IEnumerator Foo(){
  notDone = true;
  //"stops" this function until notDone is set to false
  while(notDone){  
   yield return null;
  }
 //code to execute once notDone is false here
 }

how you set notDone to false after you start this function is up to you.

Comment
Add comment · Show 10 · 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 Seneral · May 11, 2015 at 07:35 PM 0
Share

No Coroutines are not the way to go, I was looking into that before extensively enough;) The problem is, they're not blocking. They perform an action over many frames, but do not wait to finish before they return.

avatar image Griffo · May 11, 2015 at 07:45 PM 0
Share

You say

"Basically, you call a function from within yours, something happens (like a window popping up), the user interacts with it over several frames, an after he finished that, your function continues. But as he interacts with the windows, the main thread continues processing everything else"

Wont the "main thread" be the update function, then you function would be function controlled by a while() ?

Then from there call the other function (like a window popping up) again controlled by a while( after he finished that) it returns to your function ?

But as he interacts with the windows, the main thread (function Update()) continues processing everything else ?

avatar image Seneral · May 11, 2015 at 07:51 PM 0
Share

But a while loop on the main thread will block the whole main thread until it's finished, doesn't it? All involved functions (calling and blocking function, all other functions like Update) run on the main thread, so a while loop would block them all, I guess. Hm, If I think a moment about this, the only solution I could think of is somehow switching the thread for both the calling and switching function, but that's not possible I suppose...

avatar image Seneral · May 11, 2015 at 07:53 PM 0
Share

This question searched for sth similar. No answer there though...

avatar image Griffo · May 11, 2015 at 07:58 PM 0
Share

No .. the while loop would be in the next 2 functions ..

Show more comments

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

19 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

Related Questions

How i can make a function call and then after 15 sec another function call during this function call the first one stops.And this process keep repeating again and again. 1 Answer

Call function after other objects have run their Start() function 2 Answers

Blocking method calls in a coroutine? 1 Answer

Coroutine does not seem to work 1 Answer

Coroutine couldn't be started becuase inactive 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