JetBrains / JetBrains/resharper-unity
Add inspection warning: Unity event function cannot be used both in base type and derived type without virtual
Open
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
Case in point:
```
class BaseType : MonoBehaviour
{
protected bool myExtremelyImportantValue = false;
private void Awake() { myExtremelyImportantValue = true; } // Never runs
}
class DerivedType : BaseType
{
private void Awake() { /* ... */ } // Runs
private void Start()
{
Assert.IsTrue(myExtremelyImportantValue); // Fails, catastrophic failure of the programmer's sanity!!!
}
}
```
An inspection would prevent this easy mistake, and could offer a quick-fix to make `Awake` protected virtual and invoke `base.Awake()` in descendants.
Contributor guide
Assessment
This issue has not been assessed yet.