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 /
This question was closed May 02, 2021 at 01:34 AM by asheftajwaramin for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by asheftajwaramin · Apr 30, 2021 at 09:09 PM · startcoroutine

StartCouroutine is not working

This log is showing. But nothing is working after that.

 Debug.Log("Creating Player" + ludoPlayerUser);
 StartCoroutine(RegisterToSql(ludoPlayerUser));

here is the code in IEnumerator RegisterToSql(LudoPlayerUser ludoplayer). I thought there is a problem in UnityWebRequest() then I commented other codes and saw no debug log is showing. I am using Unity 2021.1.5f1

         Debug.Log("Transferring to Sql");
         /*WWWForm form = new WWWForm();
         form.AddField("playerName", ludoPlayer.getPlayerName());
         form.AddField("uid", ludoPlayer.getUid());
         form.AddField("goldCoin", ludoPlayer.getGoldCoin());
         form.AddField("contact", ludoPlayer.getContact());
         form.AddField("diamondCoin", ludoPlayer.getDiamondCoin());
         form.AddField("totalKill", ludoPlayer.getTotalKill());
         form.AddField("photoUrl", ludoPlayer.getPhotoUrl());
         Debug.Log("Form Created");
         Debug.Log("Form: " + form);*/
         yield return new WaitForSeconds(2);




Comment
Add comment · Show 11
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 HellsHand · Apr 30, 2021 at 09:45 PM 0
Share

That code is fine. What is the code around StartCoroutine(), what is happening before it's called?

avatar image asheftajwaramin HellsHand · May 01, 2021 at 05:59 PM 0
Share

It authenticate users via firebase. when authentication is successful then I am creating user in database.

 auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
             {
                 if (task.IsCanceled)
                 {
                     Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
                     return;
                 }
                 if (task.IsFaulted)
                 {
                     Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);
                     return;
                 }
 
                 // Firebase user has been created.
                 Firebase.Auth.FirebaseUser newUser = task.Result;
                 Debug.LogFormat("Firebase user created successfully: {0} ({1})",
                     newUser.DisplayName, newUser.UserId);
                 LudoPlayerUser ludoPlayerUser = new LudoPlayerUser(newUser.Email, newUser.Email, 5000, 0, 0, newUser.UserId, null);
                 Debug.Log("Creating Player" + ludoPlayerUser);
                 StartCoroutine(RegisterToSql(ludoPlayerUser));
                 toast.showToast("Signup successful...", 2);
             });

 
avatar image HellsHand asheftajwaramin · May 01, 2021 at 06:13 PM 0
Share

It would appear that the authentication task is not allowing for a Coroutine to run alongside it. It is really the only explanation I can come up with that accounts for the Log being run before it. That said, is it possible to run the Coroutine after the task completes or is it a necessity that it runs inside? Could you use a regular method as opposed to a Coroutine?

Show more comments
avatar image guillermoruizvida · Apr 30, 2021 at 11:07 PM 0
Share

I think u have to put RegisterToSql(ludoPlayerUser) just after yield return new WaitForSeconds(2);

avatar image asheftajwaramin guillermoruizvida · May 01, 2021 at 06:04 PM 0
Share

Do you mean something like this? Debug.Log("Creating Player" + ludoPlayerUser); yield return new WaitForSeconds(2); StartCoroutine(RegisterToSql(ludoPlayerUser));

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

118 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 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'd like to move a cube without delay.(C#) 0 Answers

StartCorutine not Working 3 Answers

Cannot null Coroutine variable if it calls an interface 2 Answers

How to begin startcoroutine (IEnumerator) with UI button. 1 Answer

WWW DownloadManager, C# 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