LoadContent does not work in my components

Posted by drozzy on Stack Overflow See other posts from Stack Overflow or by drozzy
Published on 2009-04-12T23:37:59Z Indexed on 2010/12/28 14:54 UTC
Read the original article Hit count: 177

Filed under:

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!

© Stack Overflow or respective owner

Related posts about XNA