How to hide/show serialized class object in the inspector with boolean value change?

I don’t know if I worded it correctly but I hope you get it.
I have a Dialogue class that among other things contains boolean value ‘isOptionDialogue’ and array of serialized DialogOption class objects that contain int and string value. Code looks like so:

public class Dialogue : MonoBehaviour 
{
    //some other stuff

    public bool isOptionDialogue;
    public DialogOption[] dialogOptions;
}

[Serializable]
public class DialogOption
{
    public int targetIndex;
    public string optionSentence;
}

and it shows in the inspectior like so:

alt text

But I want to make it so it only shows Dialog Options when bool IsOptionDialogue is set to true.

Is false:
alt text

Is true:alt text

I am really bad with UnityEditor stuff. I followed some sample code I found and tried doing something by overriding OnInspectorGUI() and drawing things with EditorGUILayout but I only got it to work with simple variables. I have no idea how to draw an array of serialized class objects. Please help

unity answers usually has all the answers already available, it’s just a matter of searching the right way. I found this for your case: