sigtrapgames / SmartData

A designer-friendly, editor-driven Unity3D framework for connecting data and events.
MIT License
271 stars 14 forks source link

Too much warnings #11

Closed omid3098 closed 5 years ago

omid3098 commented 5 years ago

When I clone this repository together with Rely, I will get over 50 warnings without changing anything, and as I try to have 0 warnings in my projects, I can not skip warnings related to this repositories.

Would you please consider a time to remove these warnings?

image

SixWays commented 5 years ago

Unfortunately this is a symptom of the fact that Unity (or possibly .Net 4.x) no longer supresses this warning for non-public fields with the [SerializeField] attribute. This is logged as a bug here, and although Unity have closed it as "by design" (which is utterly absurd), it seems to still be under consideration. I'm loathe to either a) litter my code with #pragmas or b) make all my fields public to fix an issue which really belongs to Unity, as this affects all code currently.

omid3098 commented 5 years ago

Ok, thanks for information. So there is nothing to do in this repository! I personally do a null check and set a default value to hide these kinds of warnigns.

[SerializeField] Collider collider;
void Awake(){
   if (collider == null) collider = GetComponent<Collider>();
   // or using find object in some cases.
   // the line may not actually execute, but the warning will be gone.
}