无法将资产加载为XML文件 [英] Can't Load asset as XML file

查看:70
本文介绍了无法将资产加载为XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用XNA完成了项目,目前正在尝试使用Monogame进行转换.

I have done my project with XNA and I'm currently trying to convert it while using Monogame.

我的问题是我无法加载XML文件.

My problem is that i can't load my XML file.

错误:Could not load Level asset as a non-content file!

我的代码:file = Content.Load<XmlData[]>(path);

Path =不带扩展名的xml名称文件. (我都尝试过).

Path = xml name file without extension. (i tried both).

XMLData类:

public class XmlData
{
    public int id;
    public int posx;
    public int posy;
    public int rot;
    public int Width;
    public int Height;
}

和我的一些XML文件:

and some of my XML file:

<?xml version="1.0" encoding="utf-8" ?>
  <Asset Type="MyDataTypes.XmlData[]">
    <Item>
      <id>17</id>
      <posx>54</posx>
      <posy>30</posy>
      <rot>90</rot>
      <Width>184</Width>
      <Height>5</Height>
    </Item>

我在XNA中遇到这样的问题,我不得不将以下行添加到我的XML文件中<XnaContent> </XnaContent> 而且我还不得不将XML数据添加为一个库(即使它只是一个类).

I had a problem like this with XNA, I had to add the following line to my XML file <XnaContent> </XnaContent> and I also had to add XML data as a library (even if it was only one class).

那么Monogame有什么区别?为什么我无法加载此XML文件?适当地,我的xml文件是内容.

So what's the difference with Monogame? Why I can't load this XML file? In propriety, my xml file is a content.

感谢您的帮助,我将不胜感激.

Thanks for any help, I'll be grateful.

我以为我在这里找到了问题-> <Asset Type="MyDataTypes.XmlData[]"> 我尝试了<Asset Type="XmlData[]">,因为我没有MyDataTypes库了.我还尝试了Content目录和Asset目录.什么都没有.我会继续发布最新消息.

I thought I had found my problem here --> <Asset Type="MyDataTypes.XmlData[]"> I tried <Asset Type="XmlData[]"> cause i don't have MyDataTypes library anymore. I also tried with Content directory and asset directory. Nothing worked yet. I keep this post update.

推荐答案

我相信您无法在monogame中做到这一点,因为它没有内容管道可以将xml转换为xnb文件,因此,除非我弄错了,最好在xna中构建文件,然后将xnb文件复制到您的monogame项目中,并将其设置为内容"和如果更新则复制"

I believe that you cannot do that in monogame, as it does not have a content pipeline to convert the xml to xnb files, so, unless I'm mistaken, your better off to build the files in xna and just copy the xnb files in to your monogame project and set them to "Content" and "Copy if newer"

这篇关于无法将资产加载为XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆