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
1
Question by zederis · Aug 08, 2019 at 03:58 PM · gameobjectsetactive

Can't activate game object.

I cant find a way to activate my authentication error panel to display the error. print functions works fine, authError.text works fine. no errors shown in the console. authErrorPanel is assigned in the inspector.

 switch (error)
         {
             case "Firebase.FirebaseException: An email address must be provided.":
                 print("no email");
                 authError.text = "Enter Email Address";
                 auhErrorPanel.SetActive(true);
                 break;



Comment
Add comment · Show 1
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 DuduRamos · Aug 08, 2019 at 04:11 PM 0
Share

I think you might be looking for this method ins$$anonymous$$d of SetActive: https://docs.unity3d.com/ScriptReference/Object.Instantiate.html

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Ironstone · Aug 08, 2019 at 04:24 PM

if your text gets changed correctly, perhaps you are activating the wrong gameObject? If you set the auhErrorPanel active, the authError gameObject may still be inactive (I assume).

The SetActive method works fine for me, so just make sure you're activating the right object and check if the rest of the code in that 'case' statement is getting called.

Comment
Add comment · Show 5 · 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 SirPaddow · Aug 08, 2019 at 08:52 PM 0
Share

$$anonymous$$ust be this. Shall I add that you need to make sure that all the parent gameobjects are also active for the authError to be visible.

avatar image zederis SirPaddow · Aug 08, 2019 at 09:30 PM 0
Share

i only deactivate the main error panel. not the children. authError Text component is child of authErrorPanel. And why would the auhErrorPanel.SetActive(true); stop the script? the code below never gets called. and text gets changed only in inspector but not in the scene.

avatar image zederis · Aug 08, 2019 at 09:24 PM 0
Share
 is my switch statement ok?
 
 public void DisplayError(string error)
     {
         Debug.LogWarning(error);
         switch (error)
         {
             case "Firebase.FirebaseException: An email address must be provided.":
                 authError.text = "Enter Email Address";
                 auhErrorPanel.SetActive(true);
                 print("no email");
                 //loginPanel.ShowError("Enter Email Address");
                 //errorPanel.SetActive(true);
                 break;
             case "Firebase.FirebaseException: A password must be provided.":
                 print("no password");
                 authError.text = "Enter Password";
                 auhErrorPanel.SetActive(true);
                 //loginPanel.ShowError("Enter Password");
                 //errorPanel.SetActive(true);
                 break;
             case "Firebase.FirebaseException: The email address is badly formatted.":
                 //loginPanel.ShowError("Invalid Email");
                 //errorText.text = "Invalid Email";
                 //errorPanel.SetActive(true);
                 break;
             case "Firebase.FirebaseException: There is no user record corresponding to this identifier. The user may have been deleted.":
                 //loginPanel.ShowError("Not Registered or Incorrect Email");
                 //errorText.text = "Not Registered or Incorrect Email";
                 //errorPanel.SetActive(true);
                 break;
             case "Firebase.FirebaseException: The password is invalid or the user does not have a password.":
                 //loginPanel.ShowError("Incorrect Password");
                 //errorText.text = "Incorrect Password";
                 //errorPanel.SetActive(true);
                 break;
 
         }
avatar image Dankey_Kang zederis · Aug 08, 2019 at 09:35 PM 0
Share

Your switch statement is fine, I just tried it out and it prints, enabled the GameObject and changes the text. I think they may be right in regards to something must not be hooked up correctly or perhaps something higher in your panels hierarchy needs to be enabled or something.

avatar image zederis Dankey_Kang · Aug 08, 2019 at 09:40 PM 0
Share

it is all hooked up correctly. here is how it all starts:

 public void SignIn()
         {
             FirebaseAuth.DefaultInstance.SignInWithEmailAndPasswordAsync(loginPanel.email.text, loginPanel.password.text).ContinueWith(task => {
                 if (task.IsCanceled)
                 {
                     Debug.LogWarning("SignInWithEmailAndPasswordAsync was canceled.");
                     return;
                 }
                 if (task.IsFaulted)
                 {
                     FirebaseException error = task.Exception.Flatten().InnerExceptions[0] as FirebaseException;
                     string error$$anonymous$$sg = error.ToString();
                     DisplayError(error$$anonymous$$sg);
                     print("i never get printed too");
     
                     return;
                 }
             });
         }
 




avatar image
0

Answer by zederis · Aug 08, 2019 at 06:46 PM

I got the correct game objects. there is something weird going on. I have noticed that the text is changed only in inspector, but not in the scene.. if i type in something manually, the text changes, but not through script.

Comment
Add comment · Show 14 · 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 Ironstone · Aug 08, 2019 at 06:48 PM 0
Share

Does the case definitely get called?

avatar image zederis Ironstone · Aug 08, 2019 at 06:53 PM 0
Share

yes. i get the print message in the console. i also noticed that if i put print message below the setActive it doesn't print anything.

avatar image Ironstone zederis · Aug 08, 2019 at 06:54 PM 0
Share

There is definitely no error? Vague possibility that you clicked on the button to stop showing errors in the console.

Show more comments
avatar image zederis · Aug 08, 2019 at 06:55 PM 0
Share

also if i create a method just to activate the error panel and use that method on a button, the panel gets activated.

avatar image Dankey_Kang · Aug 08, 2019 at 08:07 PM 0
Share

What types or classes are authError and auhErrorPanel?

avatar image zederis Dankey_Kang · Aug 08, 2019 at 09:14 PM 0
Share

public GameObject auhErrorPanel; public Text authError;

avatar image Dankey_Kang zederis · Aug 08, 2019 at 09:21 PM 0
Share

The authErrorPanel refers to a GameObject reference then correct?

Show more comments
avatar image
0

Answer by cemcimrin · Aug 15, 2019 at 12:10 PM

https://stackoverflow.com/questions/53916533/setactive-can-only-be-called-from-the-main-thread

Here you can find why you can't use SetActive(), in task that is not mainthread task. Same happened to my project while switching from NET 3.5 equivalent to NET 4.0. in the link you have both 2 solutions. Hope it Helps.

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.

Follow this Question

Answers Answers and Comments

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

game object set active on trigger enter? 3 Answers

activate GameObject dont work 1 Answer

Script is giving error that no MonoBehaviour scripts in file 0 Answers

show gameobject one time only 2 Answers

Gameobject flickering (Trigger issues?) 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