Show a warning in the inspector

I’d like to show a warning in the inspector like the Point Effector 2D does if there is no 2D Collider present on the same game object:

51359-3.png

How to accomplish that?

1 Answer

1

You have to implement a custom inspector for your class and when you want to show such a warning you can use “EditorGUILayout.HelpBox” inside OnInspectorGUI. Something like that:

EditorGUILayout.HelpBox("Some warning text", MessageType.Warning);

It works like a sharm now and thanks for the hint with the RequireComponent attribute. I didn't know it, yet but I'll use it :).