Search Unity

(SOLVED) Need help with obsolete code.

Discussion in 'Scripting' started by Denisowator, Oct 22, 2017.

  1. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
    A few days ago I bought the "EZ Parallax" asset for around £15, and so far it's working fine, except I'm getting a few warnings in the console about the code, and I'd like to get rid of them as soon as possible (just so I won't have to worry about them or see them).

    I emailed the creator 2 days ago, but I haven't heard back from him yet. So I wanted to try my luck here while I wait for a reply.

    Basically what's happening is I'm getting two warnings.

    The first one is:
    Assets/EZParallax/Editor/EZParallaxEditor.cs(207,20): warning CS0618: `UnityEditor.EditorGUIUtility.LookLikeControls()' is obsolete: `LookLikeControls and LookLikeInspector modes are deprecated. Use EditorGUIUtility.labelWidth and EditorGUIUtility.fieldWidth to control label and field widths.'

    Here is the line it refers to:

    EditorGUIUtility.LookLikeControls();

    I tried fixing it like so...

    EditorGUIUtility.labelWidth = 0;
    EditorGUIUtility.fieldWidth = 0;


    And it does get rid of the warning, but I'm not sure what I'm supposed to be setting it to (since the original doesn't specify any values).

    The second warning is:
    Assets/EZParallax/Editor/EZParallaxEditor.cs(214,22): warning CS0618: `UnityEditor.EditorApplication.MarkSceneDirty()' is obsolete: `Use EditorSceneManager.MarkSceneDirty or EditorSceneManager.MarkAllScenesDirty'

    Here is the line it refers to:

    EditorApplication.MarkSceneDirty();

    I tried replacing it with what it states in the warning:

    EditorSceneManager.MarkSceneDirty();

    But it just gives me an error, saying it doesn't exist in the current context:
    Assets/EZParallax/Editor/EZParallaxEditor.cs(214,4): error CS0103: The name `EditorSceneManager' does not exist in the current context

    I haven't used any of these things (code) before, so I don't know what I'm supposed to be doing.

    Anyone any ideas?
     
    Last edited: Oct 22, 2017
  2. gibberingmouther

    gibberingmouther

    Joined:
    Dec 13, 2016
    Posts:
    259
    none of your images are showing up in your post?
     
  3. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
    Yep, probably because I copied them straight from the email.
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
  5. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I guess you had an option in the IDE that you maybe didn't notice (same w/ the reference page) about including : UnityEditor.SceneManagement, aka. " using UnityEditor.SceneManagement "
    quoted from the manual: "class in UnityEditor.SceneManagement"
     
    Denisowator likes this.
  7. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
    That appears to have worked.
    But now I'm getting an error saying the method needs to have arguments, and I don't know what the parameters should be.

    I looked in the MarkSceneDirty method page, and it shows "public static bool MarkSceneDirty(SceneManagement.Scene scene);" but I'm not sure what I'm supposed to replace "scene" with in this case.
     
  8. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
  9. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Dunno for sure, but maybe get the current scene? Or just use mark all scenes dirty (all open scenes).
     
    Denisowator likes this.
  10. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
    Currently on a college computer, but I'll try that once I get home. Thanks.
     
  11. Denisowator

    Denisowator

    Joined:
    Apr 22, 2014
    Posts:
    918
    Setting all scenes as dirty works, thanks. :)
    Hopefully doing this won't cause any issues later.