PrivateFieldWarnings

Author: Fredrik Ludvigsen (Steinbitglis)

Background
Because Unity's newest compiler in 2018.3 is giving warning every time you create a field that is both serializable, private and not assigned to from any script; to keep your console from being spammed with warnings, you should decorate each such field with a pragma that disables such warnings (hinting to the compiler that Unity is going to assign data to the field during deserialization, and not through scripting in runtime).

In short: should be but at the same time, you are responsible for actually assigning data to the variable from within the editor.

The C# compiler does no such checking, this is your own responsibility, whether the warning is disabled or not.

The following script can automatically enter the pragma statements.

Description
This script edits c# scripts (inserts the following)

#pragma warning disable 0649 // Before any private serializable field

#pragma warning restore 0649 // After

Usage
Make sure you have grep and sed available. Either in the git bash, or through some other means.

Make sure to commit your changes to your repository before running the script, so you can keep track of which changes have been written.

Run pragma_warning_writer.sh inside of your assets folder.