For some reason the LoadContent method does not get called in my Components. For example I have Game class in which I do:
//Game.cs protected override void LoadContent() { editor = new Editor(...); Components.Add(editor); } //Editor.cs public class Editor : DrawableGameComponent{ Game game; public Editor(Game game, ...):base(game){ this.game = game; } //THIS method never gets called! protected override void LoadContent() { background = game.Content.Load<Texture2D>('background'); base.LoadContent(); } }
Any tips?
EDIT: When you keep in mind the order of Initialize and LoadContent everything works out fine!
I suspect your trouble is due to the Initialize function.
LoadContentis called byInitialize. There are two things you need to check for:base.Initialize()is called. In the code above, you are creating and adding the component in theLoadContentfunction of Game.cs, which occurs afterInitialize.Verify that the
Initializefunction in yourEditorclass is calling the baseInitializefunction:Check out this blog post by Nick Gravelyn for more information. Particularly relevant to your question, in his post, Nick writes that: