RequireComponent only blocks removal? Can I force a warning if missing at runtime?


I have several scripts I want associated with a GameObject and I don’t want that GameObject to exist in the scene without these components.

As such I have attached a script to that GameObject which has a bunch of:

[RequireComponent (typeof(ScriptName))]

However, if I run the game without those required components I don’t even get an error. If I add the component and try to remove it, I get an error message and it wont let me. But, there is no safegaurd/warning if they required component is never added.

Is there a way I can FORCE an object to get scripts added to it if its missing from the required (ideally in the IDE and not in the code)?


ScriptName mahscript;

void Start();
mahscript = ***.getComponent<ScriptName>();
if (mahscript == null) Debug.Error("Oh no!");

Additionally, you can do this in editorscript too, if you’d like.