yasirkula / UnityIngameDebugConsole

A uGUI based console to see debug messages and execute commands during gameplay in Unity
MIT License
2.11k stars 221 forks source link

Large amount of warnings #7

Closed zoeesilcock closed 5 years ago

zoeesilcock commented 5 years ago

Hi, I really like this plugin and have been using it for a while in my project, thanks for making it available for free.

Recently I noticed that it was spamming my console with a bunch of warnings. These warnings are harmless and appear to be a result of using private fields but it would be nice to avoid them.

There are a total of 42 warnings, here is one of them:

Field 'DebugLogPopup.debugManager' is never assigned to, and will always have its default value null

From some quick searching online I found a workaround where you give the private fields a default value (like null for example). This removes the warning but I'm not sure if it causes any issues with the plugin. Could you please investigate this?

yasirkula commented 5 years ago

Looks like it is a common issue that is not related to this plugin; google "unity field is never assigned to serializefield" and you'll see.

zoeesilcock commented 5 years ago

It's a common issue because using private fields with [SerializeField] is a common way of encapsulating values so that they only can edited from the Unity Editor, not from code. It does appear that this warning isn't shown on all versions of Unity, but the warning is a valid complaint since as far as C# can see these fields are never touched by any code. So in short, yes it is related to this plugin and there are a few different workarounds that can be applied to this plugin to avoid the warnings.

I am seeing the warning on Unity 2018.3.0f2 if that helps in recreating the problem.

RunninglVlan commented 5 years ago

I set default values for all SerializeFields which caused CS0649 warnings in #9. This doesn't break anything, the warnings just aren't shown anymore.

2 more warnings remain related to obsolete fields. Haven't touched them yet, but they can be fixed in 2 ways: stringBuilder.Append( "Image Effects: " ).Append( SystemInfo.supportsImageEffects ? "supported\n" : "not supported\n" ); -> 1: stringBuilder.Append( "Image Effects: supported\n" ); 2: Just remove such lines

yasirkula commented 5 years ago

Resolved in https://github.com/yasirkula/UnityIngameDebugConsole/commit/bb0e088dc77dcd21691dec024b7efb43b45633fe