如何让资产在WP7内容项目列表? [英] How to get a list of the assets in the WP7 Content Project?

查看:150
本文介绍了如何让资产在WP7内容项目列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以载入纹理搭配:

Texture2D texture = ContentManager.Load<Texture2D>(assetName);



但是,如果文件不存在,这将引发异常。有没有一种方法来确定是否一个给定名称的要求其实资产存在第一?

But this throws an exception if the file doesn't exist. Is there a way to determine if a requested asset of a given name actually exists first?

我存储了一系列使用后缀数字计数器资产(art001.png, art002.png,...),并想有一个简单的通话,只需通过他们计算预加载的纹理。

I'm storing a series of assets using suffixed number counters (art001.png, art002.png, ...) and would like to have a simple call preload the textures by just counting through them.

推荐答案

这是不可能通过您的XAP文件的内容进行迭代。你只需要保持你希望加载的资产清单。

It is not possible to iterate through the contents of your XAP file. You'll just have to maintain a list of the assets you wish to load.

我有我的应用程序类似的问题,我最后写一个简单的脚本,看起来在一个特定的文件夹中寻找匹配的文件名模式和更新的文本文件。所以,我跑构建应用程序之前,文本文件被打包并在应用程序读取以确定可以加载哪些文件的脚本。或者,你可以跳过麻烦,保持手工代码列表。

I had a similar problem with my app, I ended up writing a simple script that looked in a particular folder for a matching filename pattern and updating a text file. So, I'd run the script before building the app, the text file gets packaged and read in the app to determine what files could be loaded. Or you can skip the trouble and maintain a list in code by hand.

这篇关于如何让资产在WP7内容项目列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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