Search Unity

Update to Unity 4.3 and obsolete warnings for Undo and LookLikeControls

Discussion in 'Scripting' started by Tiles, Dec 21, 2013.

  1. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    The obsolete warnings when a new Unity version arrives is one of those things that drives me crazy in a regular manner. Sometimes it`s clear what is meant. But sometimes you cannot figure it out what is meant even after hours and days of research.

    One thing is the new Undo.Register Undo vs Undo.RecordObject. It`s no problem to replace that. But what about Undo.RegisterSceneUndo? The mentioned solution to replace it by Undo.RegisterUndo leads to a red warning.

    Code (csharp):
    1. Assets/NGUI/Scripts/Editor/NGUIEditorTools.cs(710,30): warning CS0618: `UnityEditor.Undo.RegisterSceneUndo(string)' is obsolete: `Use DestroyObjectImmediate, RegisterCreatedObjectUndo or RegisterUndo instead.'
    --->

    Code (csharp):
    1.  
    2. Assets/NGUI/Scripts/Editor/NGUIEditorTools.cs(710,30): error CS1501: No overload for method `RegisterUndo' takes `1' arguments
    End of story. I am lost here.

    And then there is a whole bunch of LookLike Controls warnings.

    Code (csharp):
    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.'
    To replace EditorGUIUtility.LookLikeControls(80f); by EditorGUIUtility.labelWidth(80f); does not work. It throws an error.

    Code (csharp):
    1. Assets/NGUI/Scripts/Editor/UISpriteAnimationInspector.cs(24,34): error CS1955: The member `UnityEditor.EditorGUIUtility.labelWidth' cannot be used as method or delegate
    What?

    The manual is as usual also no big help here ...

    https://docs.unity3d.com/Documentation/ScriptReference/EditorGUIUtility-fieldWidth.html

    Why is there no example of useage?

    Could somebody please lead me to the right track?
     
    Last edited: Dec 22, 2013
  2. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    *bump*
     
  3. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Okay, seems that i got at least the LookLikeControls fixed. I wish there would be an examplecode in the Unity manual ...

    Example:

    Code (csharp):
    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 ... :rolleyes:

    Remains the SceneUndo problem ...
     
  4. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    The SceneUndo obsolet warnings were not so easy to fix. But having a look at the NGui 3.x code leaded me to the solution then. All warnings gone. Thanks for help everybody.
     
  5. chubsteroonskii

    chubsteroonskii

    Joined:
    Dec 25, 2013
    Posts:
    1
    Can I see the solution for the SceneUndo obsolete warnings? I am experiencing the same error, thank you :)
     
  6. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Overlooked the reply, sorry. Better late than never ...

    Have a close look at the warning, they contain also the solution how to fix the problem.
     
  7. toum

    toum

    Joined:
    Nov 21, 2009
    Posts:
    15