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
3
Question by mononull · Jun 11, 2013 at 03:07 PM · errorgameobjectsetactive

!IsActive && !GetRunInEditMode

I'm setting active with SetActive on a gameobject and I'm getting this error when I run the game and it hits that line of code. It appears to be running fine, but would like to understand and clear this out. Anybody ever get this error? I don't want to post code because it would be a lot of code and I can just work around it.

Comment
Add comment · Show 7
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 InfiniBuzz · Jun 11, 2013 at 03:43 PM 0
Share

Please post the exact error message, I don't get what error message you have?

avatar image mononull · Jun 11, 2013 at 03:57 PM 2
Share

All it says is !IsActive && !GetRunInEdit$$anonymous$$ode as an red error message. It doesn't say anything else.

avatar image InfiniBuzz · Jun 11, 2013 at 04:07 PM 0
Share

O$$anonymous$$ this looks uncommon to me. Is your gameObject not active by default?

avatar image mononull · Jun 11, 2013 at 04:09 PM 0
Share

It's active upon starting. I'm just disabling a script right now ins$$anonymous$$d of the whole gameobject so it's fine. Just thought I would post it in case someone else had the same error.

avatar image robertbu · Jun 11, 2013 at 04:17 PM 0
Share

As a starting point, double click on the error and look in $$anonymous$$ono for the script and line the error is co$$anonymous$$g from. I remember getting this error in EZGUI at one point, but I don't remember how I fixed it.

Show more comments

5 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by gStormDesign · Aug 05, 2013 at 04:56 PM

I got the same obscure error message that appears to be a lost debugging trap for an odd condition.

By way of example, my case was narrowed down to a gameObject.SetActive(false) call from within the OnGUI method, as opposed to Update() or FixedUpdate().

Presumably, the tick cycle chain should be respected for cases where a game object can deactivate itself, and these operations should be performed outside OnGUI(). Hope that helps.

Comment
Add comment · Show 3 · 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 regrunge · Oct 21, 2013 at 08:20 AM 0
Share

I had the same problem and solution, I was setting this.gameObject.SetActive(false) inside the OnGUI. The solution was triggering a boolean within OnGUI that in Update would SetActive(false)

avatar image V-Portela · Oct 01, 2014 at 03:26 PM 0
Share

Thanks! same here, it helped me a lot.

avatar image Amalina-Ahmad · Mar 02, 2017 at 05:53 PM 0
Share

Thanks ! Do setactive outside OnGui() function solve me :D

avatar image
0

Answer by Gurunext · Feb 22, 2014 at 02:54 AM

Yes I had the same problem/error. And it all happens if I try to disable gameobject in OnGUI as described. OnGUI happens more than one tick and for different events. If the correct event does not occur you function won't work. For example if you are pressing a button to deactivate gameobject you would find two events: "Layout and mouseDown". You can simply filter events with IF statement

 if (Event.current.type == EventType.mouseDown)
  gameobject.SetActive(false)
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
avatar image
0

Answer by unmaxim · May 24, 2014 at 01:54 PM

I fixed that problem by removing the following DLL: "Assets/Plugins/UnityEditor.dll"; Note that after removing Unity will probably update it's interface to original (all your internal windows settings will be discarded)

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
avatar image
0

Answer by Kaworuyoshi90 · Aug 15, 2014 at 07:57 PM

This is because you are trying to disable an object that it's in the middle of something, at least that was happend to me, my solution was call the method or copy the code to another method wich the same number of calls from MonoBehaviour, for example: my code was like this: void OnGUI() { deactivateChilds(); }

 void deactivateChilds()
 {
      for( int i = 0; i < transform.childCount; i++ )
      {
          transform.GetChild(i).gameObject.SetActive(false);
      }
 }

and the solution was to call deactivateChilds() from the Update method.

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
avatar image
0

Answer by BulwarkAssassin · Mar 10, 2019 at 07:29 PM

In my case I had a "HideGui()" function being called from "OnGui()" whenever the H key was pressed, which toggles the active state of the canvas between "Canvas.SetActive(true)" and "Canvas.SetActive(false)". My solution was to convert the "HideGui()" function to a coroutine and add the line "yield return new WaitForEndofFrame()" at the beginning. This ensures that whatever other activities in other scripts that were being performed on the canvas have the opportunity to resolve for that frame before the canvas is deactivated. This resolved all of my errors.

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

24 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

Related Questions

GameObject[] Issues 1 Answer

Need workaround for this line of code 1 Answer

SetActive over network 1 Answer

I Can't disable gameObject using .SetActive (or anything else) 2 Answers

Can't activate game object. 3 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