- Home /
How to mark a method Obsolete
The attribute [Obsolete] does not seem to work with Unity. Is there an alternative?
$$anonymous$$ay I ask why you would need to mark a method as obsolete?
Answer by Jamora · Oct 20, 2013 at 07:03 PM
It works for me. The obsolete attribute is in the System namespace.
[System.Obsolete("This is an obsolete method")]
public void Method(){}
Ah, it's in System! And apparently it's System.ObsoleteAttribute().
Answer by dimib · Mar 04, 2021 at 03:13 PM
Unity uses
[Obsolete("Method is obsolete.", false)]
The second bool parameter tells Unity to treat the usage of this method as error or not.
Well, that's not really Unity specific since, as jamora said, it's an attribute defined in the System namespace and is part of the .NET framework and not Unity. It's well documented on the MSDN. This included the optional "isError" parameter.
Your answer
![](https://koobas.hobune.stream/wayback/20220613120304im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Get RangeAttributes from built in class using Reflection 0 Answers
compare Attack and Defence attribute 1 Answer
Set RangeAttribute to specific numbers 1 Answer
Customize how class attributes are shown in the Inspector? 0 Answers
How can script will auto run on attaching a gameobject in editor? 1 Answer