简体   繁体   English

Monogame构建内容运行时

[英]Monogame builduing content runtime

I'm making an editor similar to Unity. 我正在制作类似于Unity的编辑器。 I'm using WinForms and I'm embedding a MonoGame window in a form like shown here . 我使用的WinForms,我的形式嵌入MonoGame窗前,仿佛显示在这里 Everything's working fine, but now I need to add new content to the project and I need that to be made runtime. 一切正常,但是现在我需要向项目中添加新内容,并且需要将其添加为运行时。 I've looked into this example but, firstly it uses the xna content building and secondly, when I run it and load something I can't seem to find an xnb file. 我研究了这个示例,但首先,它使用xna内容构建,其次,当我运行它并加载某些内容时,我似乎找不到xnb文件。 So what should I do to build with Monogame builder runtime and have the xnb files? 那么,如何使用Monogame Builder运行时进行构建并获得xnb文件?

I haven't done much with mono jet but when I make a new mono game project and add a System.Windows.Forms reference, I can do something like: 我对mono jet的工作还不多,但是当我创建一个新的mono游戏项目并添加System.Windows.Forms参考时,我可以执行以下操作:

if(_currentKeyboardState.IsKeyDown(Keys.Space) && _previousKeyboardState.IsKeyUp(Keys.Space))
{
    using (var dialog = new System.Windows.Forms.OpenFileDialog())
    {
        dialog.Filter = "PNG (*.png)|*.png";
        if(dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            var fileName = System.IO.Path.GetFileName(dialog.FileName);
            System.IO.File.Copy(dialog.FileName, System.IO.Path.Combine("Content", fileName));
            _texture = this.Content.Load<Texture2D>(fileName);
        }
    }
}

which instantly renders the new texture at runtime. 在运行时立即渲染新纹理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM