Support multiple selection with OnSceneGUI handles (The targets array should not be used inside OnSceneGUI)

When selecting multiple objects I want to display all their respective handles.
The draw handle method is called in OnSceneGUI, however, accessing the property via

((MyInfo) myInfoProperty.objectReferenceValue).DrawHandles();

only draw the handles for the first selected object. Using:

foreach (Object obj in targets) {
    MyObject myObject = (MyObject)obj;
    myObject.myInfo.DrawHandles();
}

works, but spams the following error:

The targets array should not be used
inside OnSceneGUI or OnPreviewGUI. Use
the single target property instead.

which corresponds to what the documentation is saying, but it doesn’t say how to support multiple targets.

I found the answer while writing the question… Thank you, rubber duck.

As the error message says, I just have to use the single target and count on Unity to apply OnSceneGUI to each appropriate selected target. However, this magic only works by using the provided target, not a SerializedProperty I retrieved with serializedObject.FindProperty() as I was doing.

This gives:

MyObject script = (MyObject)target;
script.myInfo.DrawHandles();

That’s it!