Hi!
I am just curious.
My line of code
source?.GetComponent()?.AddEnergyPercent(gainPercent * 0.01f);
throws "Missing Reference Exception". It is easy to fix by adding
if(source != null)
before it. The "source" is a GameObject, and it can be sometimes null, and it's not always have "Energy" component. But the "?." operator is not for check it is null or not?
↧