尝试在 MG Editor for MacOS M1 中构建 MonoGame 内容

问题描述 投票:0回答:0

我目前正在 Visual Studio 2022 for Mac(所以 M1)中使用 .NET 7.0.203 在 C# 中开发游戏。 MonoGame项目使用DeskotGL,应该是跨平台的。

游戏将使用MonoGame游戏引擎开发。该项目目前是空的。我只想尝试导入地图并运行项目以查看它是否有效。

为了能够首先运行地图,我需要在 MonoGame 编辑器中导入 .blend 地图并构建它,以便拥有将在 VS 中使用的 .xnb 文件,但我收到了那个错误。

错误:

这是我在 Game1.cs 中的实际代码:

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace LaserLounge
{
    public class Game1 : Game
    {
        private GraphicsDeviceManager _graphics;
        private SpriteBatch _spriteBatch;
        private Model _model;

        public Game1()
        {
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible = true;
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load the 3D model
            _model = Content.Load<Model>("mercedes");
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Set up the necessary transformations and camera settings here
            Matrix world = Matrix.Identity;
            Matrix view = Matrix.CreateLookAt(new Vector3(0, 0, 5), Vector3.Zero, Vector3.Up);
            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 0.1f, 100f);

            // Render the 3D model
            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    BasicEffect effect = (BasicEffect)meshPart.Effect;
                    effect.World = world;
                    effect.View = view;
                    effect.Projection = projection;
                }

                mesh.Draw();
            }

            base.Draw(gameTime);
        }
    }
}

我尝试了多个版本的 MonoGame Content Pipeline,但仍然有同样的问题。

我想我已经解释了我的问题,如果有人不明白什么或者我错过了一些细节让我知道。

c# macos visual-studio apple-m1 monogame
© www.soinside.com 2019 - 2024. All rights reserved.