Monobehaviour class variables not shown on inspector

Assume I have two classes:

[Serializable]
public class A : Monobehaviour
{
    public int _myInt;
    public B _classB;
}
[Serializable]
public class B : Monobehaviour
{
    public int _myInt;
    public string _myString;
}

Is there an easy way to make class B variables appear on the inspector on the script of class A?

No, and there shouldn’t be a way, since MonoBehaviours shouldn’t exist if not bound to a gameObject (same reason why you shouldn’t do new B();).

But maybe you don’t need it to be a MonoBehaviour? If you remove the inheritance, attributes of B will appear in the inspector of A.

The fastest way is to do something like this:

[Serializable]
 public class A : MonoBehaviour
 {
     public int _myInt;
     public B _classB;
     private void Start(){
             _classB = GameObject.Find("gameObject name that has class b attached").GetCompoment<B>();
      }
     public void Update()
     {
         _classB.Update();
     }
 }
 
 [Serializable]
 public class B
 {
     public int _myInt;
     public string _myString;
 
     public void Update()
     {
         // do stuff
     }
 }