- Home /
Custom "Can't add due to conflicting component"
I would like to have a similar popup to the "Can't add due to a conflicting component" you receive when trying to add a BoxCollider2D to a GameObject with a Rigidbody already attached or any similar scenario.
I was hoping there was a decorator for this but if there is I can't find it. I'm guessing I would have to use a custom PropertyAttribute but there doesn't seem to be any sort of addcomponent callback in place that could be used to trigger the check and accompanying message.
Any idea of where to root around for a solution?
I guess that could work but it would then be calling all of your event functions which would end up causing more problems than the one I set out to solve.
Adding if-statement to check Application.isPlaying and some Platform Dependent Compilation tricks can do the job, but it will be a mess. I like your solution!
Answer by nathanielstevens · Feb 12, 2015 at 06:03 PM
You can perform the check and accompanying dialog message in the OnEnable of the component's CustomEditor script.