Author Topic: NGui 2.7, Update to Unity 4.3 and obsolete warnings like LookLikeControl  (Read 11517 times)

Tiles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
I`ve updated my project to Unity 4.31 before a few moments. This is the third attempt. Now i get thrown to death with obsolete warnings. Most of them comes from NGui. I´ve tackled most of the Undo.RegisterObject vs RegisterUndo warnings already. But there are some of them left where i am lost. Like this one:

  1. Assets/NGUI/Scripts/Editor/NGUIMenu.cs(99,30): warning CS0618: `UnityEditor.Undo.RegisterSceneUndo(string)' is obsolete: `Use DestroyObjectImmediate, RegisterCreatedObjectUndo or RegisterUndo instead.'

When i replace the Undo.RegisterSceneUndo by RegisterUndo then i get a red warning.

And i get a whole bunch of LookLikeControls warnings where i am absolutely lost with. When i try to change the code as suggested, then i end in red warnings too.

It`s messages like this:

  1. Assets/NGUI/Scripts/Editor/UIScrollBarInspector.cs(14,34): warning CS0618: `UnityEditor.EditorGUIUtility.LookLikeControls(float)' is obsolete: `LookLikeControls and LookLikeInspector modes are deprecated. Use EditorGUIUtility.labelWidth and EditorGUIUtility.fieldWidth to control label and field widths.'
  2.  

What do i need to do here?
« Last Edit: December 21, 2013, 05:44:57 AM by Tiles »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
You should upgrade to the newest NGUI, I'd say.

Alternatively, you can ignore the warning - it's only deprecation, it still works for a while more.

Tiles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Thanks Nicki, but both options are out of question, unfortunately.

I've upraded to NGui 3.x before, and the scaling of my font was fubar then. That`s no option really for my current project.

And ignoring the warnings means to have lots of disturbing warnings in the console that pops up every time i modify some of my scripts. Other warnings sinks in the masses then, making the search for mistakes very cumbersome.

The warnings says already what to do. I just don`t understand what is meant for the mentioned two cases. The explanations are too vague, the Unity manual is of no help neither. And i haven`t found the right way yet. Every changing leaded to a red warning so far.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
In NGUI 3 I replaced all those functions with a call to NGUITools/NGUIEditorTools instead. Inside that function I wrote the "if unity 3.5, do this, else do that" statement that resolves this. If you can't upgrade to the latest -- which I would strongly advise by the way -- then your only other option is to resolve the errors yourself in a similar fashion. NGUI 2 line has been deprecated and will not be receiving any new updates.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Also, just because it's a red warning, doesn't mean it won't work. ;)

Tiles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Quote
If you can't upgrade to the latest -- which I would strongly advise by the way -- then your only other option is to resolve the errors yourself in a similar fashion. NGUI 2 line has been deprecated and will not be receiving any new updates.

I already tried to update to NGui 3 before, and i failed. The scaling of my font is destroyed with the update. The project is nearly done. It`s not worth the hassle to rebuild my gui just because of a not good working update. It already works.

I don`t want an upgrade for 2.7x. I just want to resolve those two remaining problems. By myself. And as told above, i already have solved quite a few problems with the undo. Unfortunately the advices in the warnings are everything but clear. And i am in trouble with the two remaining cases. So i need a bit help here. That`s why i ask here, at the NGui Support forum.

Honestly, i am a bit disappointed that i cannot get a clear answer how to fix this issues.

Quote
Also, just because it's a red warning, doesn't mean it won't work. ;)

This is not true. Unity moans about conflicts then, and refuses to start the game until the error is fixed.




Tiles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Okay, seems that i got at least the LookLikeControls fixed. I wish there would be an examplecode in the Unity manual ...

Example:

  1.     public override void OnInspectorGUI ()
  2.     {
  3.         //EditorGUIUtility.LookLikeControls(15f);
  4.         EditorGUIUtility.labelWidth=15f;
  5.         EditorGUIUtility.fieldWidth=15f;
  6.  
  7. ...

Great changing Unity, thanks. Now i have two lines where i had just one before ...  ::)

Remains the SceneUndo problem ...

Tiles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Have that undo rascal too. I was wrong, you provided the solution already. I was just too blind to read it. I´ve had a look at the 3.x code now to compare what is different. And have used that code snippets from the 3.x code to fix the 2.7 code then.

Problems solved. Warnings are gone. Thanks for help :)