Author Topic: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete.  (Read 8801 times)

Rick74

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Hello,

I posted this also over in the NGUI: Free edition thread, but I thought it might be better to ask here.  After getting the latest free version of NGUI and trying to run it, I was spammed with 33 of these errors;

warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'

I'm currently running Unity free version 4.1.5f1

How would I resolve this?

Thanks!

Stevorino

  • Guest
Someone probably needs to confirm this (I am a newb myself) - But I believe Unity changed the way Active works in version 4.0 and replaced it with more specific SetActive, ActiveSelf, and ActiveInHierarchy methods.

You need to go into each instance of Gameobject.Active (double-click on debug warning to get there quickly) and change it to either SetActive or ActiveSelf.  Check the Unity ScriptReference (http://docs.unity3d.com/Documentation/ScriptReference/GameObject.SetActive.html) to figure out what each does and which is most appropriate.  When I did it, SetActive was usually the right way to go.

Rick74

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Thanks for the feedback.  I'm still learning JS and getting to know Unity as well, so I don't feel comfortable just yet determining which situation I should use each option for.  I guess I was hoping for an update in the install to account for Unity's changes. 

Was there any word as to if or when this will happen for noobs such as myself?

dlewis

  • Guest
The free version is very old, this issue was fixed quite a while ago in the paid version.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
The free version was originally made for Unity 3.5. Unity 4 obsoleted the .active property.

Don't worry about it for now, it still works, but at some point it won't anymore in a future version of Unity,

Rick74

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Ok, thanks for the feedback guys.

Strange but having done NOTHING...I don't seem to be getting errors anymore.   ???  I swear it's voodoo!