Disable/suppress warning CS0649 in C# for a specific field of class

前端 未结 5 2070
春和景丽
春和景丽 2020-12-18 17:54

I have some fields in a C# class which I initialize using reflection. The compiler shows CS0649 warning for them:

Field foo\' is never assigned

5条回答
  •  情话喂你
    2020-12-18 18:21

    If you want to disable ALL warnings in the project (rather than per script) then do this:

    Ceate a text file called mcs.rsp (for editor scripts) in your YOUR_PROJECT_NAME/Assets directory with contents (for example):

    -nowarn:0649

    (You can change the number to match whatever warning you want)

    Original answer

    Note: This doesn't disable the warnings in the Unity console if you are using Unity (I am still investigating how to remove those)

    Here is some Unity documentation with more information

提交回复
热议问题