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 KnightRiderGuy · Sep 12, 2016 at 10:21 PM · buttoncoroutinebuttonscoroutinesinvoke

Is it possible to invoke a button Press With a Coroutine?

I have a series of coroutines that I would like to see if I can get them to invoke a button press but I have not found any information on if that is even possible or if so how?

Comment
Add comment · Show 4
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 flashframe · Sep 12, 2016 at 10:44 PM 0
Share

Do you mean you want to mimic a button press visually?

avatar image KnightRiderGuy flashframe · Sep 12, 2016 at 10:49 PM 0
Share

Well we have UI button on a canvas panel that I'm wondering if we can invoke a press with a coroutine.

avatar image Hanoble KnightRiderGuy · Sep 12, 2016 at 10:56 PM 0
Share

You want to visually show the button pressing though? Not just simply running the logic that is connected to the button press?

Show more comments

1 Reply

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

Answer by daleran · Sep 12, 2016 at 11:22 PM

So, if I understand your question correctly, you are trying to invoke the functionality of a button that is blocked by another panel some other way. All you have to do is get a reference to the button and invoke the onClick event that all buttons have:


UnityEngine.UI.Button myButton.onClick.Invoke();

It's all in the Unity documentation: UI.Button

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 KnightRiderGuy · Sep 13, 2016 at 03:16 AM 0
Share

Thanks @daleran, but will that work from a coroutine?

avatar image daleran KnightRiderGuy · Sep 13, 2016 at 04:13 AM 0
Share

Yeah, a coroutine is just a function that gets called asynchronously in unity. It's not like a thread where you have to worry about thread safety. It's just unity's way of running things in parallel. Anything you can call from update() or OnCollision() or any other method can be called from a coroutine. $$anonymous$$ore info here.

avatar image KnightRiderGuy daleran · Sep 13, 2016 at 12:45 PM 0
Share

O$$anonymous$$ awesome @daleran I'll have to try this. So all I should need to do if my button is called: "CloseButton"

in my coroutine I would do something like"

 IEnumerator AbortSP$$anonymous$$screen(){
 yield return new WaitForSeconds (0.5f); //Wait Time
 UnityEngine.UI.Button CloseButton.onClick.Invoke();
 }


Is that right?

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

64 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 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 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

I need to Stop and Restart a Co-Routine at anytime 1 Answer

CancelInvoke cant cancell,Updating InvokeRepeating 1 Answer

NullReferenceException in StartCoroutine 1 Answer

Loading spinner freezez for a while 1 Answer

Returning from Coroutine stops the Update() method. 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