Is RequireComponent[typeof(CustomScript)] possible?

Hi, Is it possible to automatically load a custom script component with this attribute?

Absolutely. The script must inherit from MonoBehaviour and must compile though.

@Berenger
In Unity 2020.3 it’s normally works:

    [RequireComponent(typeof(CtrlVerticalSpeedMoveCharater))]
    public class MainCtrlStateMachine : MonoBehaviour
    {....}

Note. public class CtrlVerticalSpeedMoveCharater : MonoBehaviour and therefore it can be attached to GameObject.

If you talk about the “CustomSciprt” which isn’t derived from MonoBehaviour (ScirptableObject or standard C# sciprt) in this case it doesn’t have any sense, but "it "can be did by common c# technics.

189018-requiredcomponentscript.jpg