Find missing paramters?

Hi there!

There has anyway to find all missing parameters in all component by code?

Thanks!

What are “missing parameters”?

2 Likes

Ok, If I have a component with

public GameObject Test

so the Test will be this component parameter right?

then if this parameter has been assign with some game object, and then that game object has been removed by accidentally or someway, that parameter will show “missing" in the parameter at the slot right?

that is what I want to find if some component was be like that.

You can just do a normal null check to see if it has been Destroyed.

There are thousands of situations where a reference variable is okay to have a null value. Every root object’s transform has a parent of null. Most colliders in a scene will have an attachedRigidbody of null. An AudioSource used for multiple sounds typically has a null clip property.

So, back to the question, what are “missing parameters”? It’s a case-by-case situation.

There are code attributes which people have written (Odin, Naughty Attributes, Inspector Gadgets) to highlight a parameter whenever it is null. That can probably be leveraged in some sort of search system to find cases where there is a parameter with a “required” attribute which is null.

The most robust solution is using Odin Validator asset. But it is paid. There are countless free assets on the asset store and on github doing just this. You can also write your own editor scripts, defining your own rules when to alert about missing references and when not to.

I found it easily worth the cost and there appears to be a 50% discount at the moment.