This actually isn't fully true, we don't digest all kinds calories equally. Generally speaking, yes, the most important factor in body weight is the total amount of calories consumed. Whether they are proteins, fats, complex carbs, or simple carbs, and when you consume them during the day, effects how much of that energy actually gets stored in the body.
https://www.strongerbyscience.com has an article somewhere on this, and it's not well tested yet, but we're starting to see some scientific evidence to back this up.