我将我的 XNA 游戏嵌入到 winforms 的控件中。因此,我需要继承 Control,而不是 Game。
我怎样才能从我的内容项目中加载模型?
这是我的代码:
namespace KinectGraphics.XNAEmbedding {
class XNARenderControl : GraphicsDeviceControl {
Game selfGame;
public XNARenderControl() {
selfGame = new Game();
}
protected void LoadContent() {
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
model = selfGame.Content.Load<Model>("Ka-60");
//model = Content.Load<Model>("earth");
//model = Content.Load<Model>("3dm-tie-f-gt");
}
但是,当执行到 selfGame.Content.Load 时,它会抛出 ContentLoadException: Error loading "Ka-60"。文件未找到。
无论如何,我该怎么做才能加载模型?