Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

My project is full of CS0649 warning when I using the .Net 4.x

Discussion in '2018.3 Beta' started by watsonsong, Sep 28, 2018.

Thread Status:
Not open for further replies.
  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    My project is full of the warning about the serialied field is never assigned to.
    Is there any way or any plan to disable such a warning on serilized field?
     
  2. Giometric

    Giometric

    Joined:
    Dec 20, 2011
    Posts:
    170
    You can use the C# preprocessor directive to turn the warning off:
    Code (csharp):
    1.  
    2. // Tells the compiler to disable this particular warning
    3. #pragma warning disable 0649
    4.  
    5. [SerializeField]
    6. private int someNumber;
    7.  
    8. // Don't forget to re-enable it
    9. #pragma warning restore 0649
    10.  
     
  3. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    In the previous version of unity, the c# compiler will not report this warning in unity. I think the new version using the rylson compiler is missing this option.
    Yes I can modify the code, but what I say is the behavior is different from the previous version of unity and I think this option should be disabled by unity both in the editor compiler and the integered IDE such as visual studio project.
     
  4. Racoon_7

    Racoon_7

    Joined:
    Nov 11, 2017
    Posts:
    11
    See here.
    You're not the only one who thinks the warning should be disabled for [SerializeField], but Unity's current stance seems to be to leave it as it is.
     
    xVergilx likes this.
Thread Status:
Not open for further replies.