Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

How can throw "Missing reference exception" this gameObject?.Getcomponent() ??

$
0
0
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?

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>