由于某种原因,我的组件中没有调用 LoadContent 方法。例如,我有我做的游戏类:
//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();
}
}
有小费吗?
编辑:当您记住 Initialize 和 LoadContent 的顺序时,一切正常!