Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Warning, Obsolete member overrides non-obsolete member

Discussion in 'Scripting' started by Louis42, Mar 31, 2020.

  1. Louis42

    Louis42

    Joined:
    Feb 12, 2020
    Posts:
    6
    Hi everyone, I have been following a tutorial on YT but since it is from 2015, sometimes I have to deal with some obsolete code. I have managed to fix everything using
     [System.Obsolete] 

    but this timeI do not even understand what is going on. I am using the following script:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. [CustomEditor (typeof (MapGenerator))]
    7. public class MapEditor : Editor {
    8.     [System.Obsolete]
    9.     public override void OnInspectorGUI() {
    10.         base.OnInspectorGUI();
    11.  
    12.         MapGenerator map = target as MapGenerator;
    13.  
    14.         map.GenerateMap();
    15.  
    16.     }
    17.  
    18.  
    19. }
    As you can see, I am even using
     [System.Obsolete] 

    but this time the error

    Assets\Editor\MapEditor.cs(9,26): warning CS0809: Obsolete member 'MapEditor.OnInspectorGUI()' overrides non-obsolete member 'Editor.OnInspectorGUI()'

    seems invulnerable.
    Any help? Thanks in advance
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
    What happens if you don't use [System.Obsolete]?
     
  3. Louis42

    Louis42

    Joined:
    Feb 12, 2020
    Posts:
    6
    Now GenerateMap() at line 14 is obsolete, but there are no warnings in the other file
     
  4. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    488
  5. Louis42

    Louis42

    Joined:
    Feb 12, 2020
    Posts:
    6
    I don't know, I'm new to unity. Should I just ignore them?
     
  6. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    488
    Generally, no. In your case, maybe. As far as I understand you're following some old tutorial that's using obsolete stuff. In your case, I would do my research to see what the old code has been replaced. OnInspectorGUI has been replaced by something (my guess is just a regular OnGUI, but I could be wrong).
     
  7. Louis42

    Louis42

    Joined:
    Feb 12, 2020
    Posts:
    6
    I did my researches for other warnings and I figured out the newer replacement for other methods, but in this case I wasn't able to find nothing useful, that's why I ended up writing on this forum. I will try to use OnGUI and I'll let you know. Otherwise I'll just ignore the warnings
     
  8. Louis42

    Louis42

    Joined:
    Feb 12, 2020
    Posts:
    6
    I did my researches for other warnings and I figured out the newer replacement for other methods, but in this case I wasn't able to find nothing useful, that's why I ended up writing on this forum. I will try to use OnGUI and I'll let you know. Otherwise I'll just ignore the warnings
     
  9. Louis42

    Louis42

    Joined:
    Feb 12, 2020
    Posts:
    6
    Ok, so OnGUI was not the answer, since OnInspectorGUI in not obsolete. The problem was in a different script, when I used FindChild() (that is obsolete) instead of Find(). To suppress the warning caused by FindChild I used [System.Obsolete], that labeled my OnInspectorGUI as obsolete too. The warning was due to the fact that I was trying to override a non-obsolete function with an obsolete-labeled one. Thanks everyone for the help