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 /
  • Help Room /
avatar image
0
Question by shanzebali · May 09, 2016 at 05:19 PM · buttonienumeratornotworking

Public IEnumerator wont work if attached to a button.

, public IEnumerator ResumeIfLives()

 {

     if (lives > livesRequired)

     {

         lives = lives - livesRequired;

         yield return new WaitForSeconds(3);

         Time.timeScale = 1.0f;

     }

     yield return null;

 }


ERROR:

ArgumentException: method return type is incompatible

Comment
Add comment · Show 5
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 meat5000 ♦ · May 09, 2016 at 11:29 AM 0
Share

I get no such error from your snippet even when attached to a button.

avatar image shanzebali meat5000 ♦ · May 11, 2016 at 08:35 PM 0
Share

I have posted the script below Please help if possible.

avatar image TBruce · May 09, 2016 at 05:30 PM 0
Share

Same here. Can you post the whole script?

avatar image shanzebali TBruce · May 11, 2016 at 08:35 PM 0
Share

I have posted the script below Please help if possible.

avatar image shanzebali · May 11, 2016 at 08:32 PM 0
Share

IEnumerator ResumeIfLives()

 {

     if (lives > livesRequired)

     {

  
        lives = lives - livesRequired;

         go.GetComponent<Player>().dead = false;

         yield return new WaitForSeconds(5f);

         Time.timeScale = 1.0f;

     }

     yield return null;

     
 }

 public void ResumeButton()

 {

     StopCoroutine(ResumeIfLives());

     StartCoroutine(ResumeIfLives());

 }

i tried making another public void function now it can be attached to a button. This is the script it brings the player back from dead but it does not change the time scale back to 1.0f. I don't know if i am doing it wrong; but i think it doesn't works after the waitForSeconds().

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Trying to increment a variable in a Coroutine on pressing a UI button 0 Answers

Script loads wrong information 0 Answers

IEnumerator when button is pressed 0 Answers

Using Data with a Button? 1 Answer

find an especific multitouch wich is on a image in the canvas 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