How to check if class has RequireComponent on it?
Hi, I'm trying to make a miniature of the player, by instantiating the player gameobject at start, and then stripping it off all the unnecessary things (colliders, rigidbodies...).
It works really well, apart for throwing errors all the time. "Can't remove X because Y (Script) depends on it". I could probably live with these errors, but it makes it hard to read the console properly.
Is the any way I could check a component if it requires another component? I don't even need the specific component it requires.
Answer by legion_44 · Aug 29, 2015 at 03:20 PM
Yes, use
typeof(ComponentType).IsDefined(typeof(RequireComponent), false);
Welp, It kinda helped, but not much. Thanks anyways though. There was ONE custom made script that kept throwing the errors. When I made a debug.log in its OnEnable(), it returned true, however when I made a check in my Generation code, it kept throwing the error. I have no idea why. I deleted the RequireComponent attribute from it since it was there only to make sure I wouldn't forget to add LineRenderer.
I guess you can count that as solved...
Accepted as an answer, because I got what I asked for.