phases where I have zero appetite and am super sensitive about food textures (more sensitive than usual)

Sometimes I have these phases where I have practically no feeling of hunger or appetite and eating gets really hard. Even my safe foods like spaghetti with tomato sauce or a sandwich makes me gag. In these times i often make myself high cal smoothies/shakes if i have no other option but even the smothie is sometimes hard to get down when its slightly too thick. It sucks a lot because I am underweight and already struggle with gaining and maintaining weight. Why does this happen and is there anything I can do to deal with this? Do any of you also struggle with something similar?