我正在使用ODBC连接从Windows 7上的Unity3D环境(Mono.net)中的Access文件(.mdb)获取数据,并且连接,断开连接和请求发生时没有任何错误.
但是当我读到我得到的数据时,我只收到数据库中的数字.它可以是整数或浮点数.但是当我尝试获取字符串时,它总是返回一个空字符串.
以下是我在DataBaseHandler类中用于执行请求(提取)的内容:
public ArrayList Execute(string req)
{
ArrayList output = new ArrayList();
[...]
cmd = new OdbcCommand(req);
cmd.Connection = accessConnection;
OdbcDataReader reader = cmd.ExecuteReader();
while (reader.Read()) {
String[] row = new String[reader.FieldCount];
for (int i=0; i<reader.FieldCount; i++) {
if (!reader.IsDBNull(i)) { // Added if for Visual Studio
// Getting empties strings, but work fine with numbers
row[i] = reader.GetValue(i).ToString();
// I was using GetString before, but didn't work with Visual Studio
}
}
output.Add( row );
}
[...] …Run Code Online (Sandbox Code Playgroud) 如何在Unity中找到带有关键字的GameObjects?
实际上,我有很多GameObject这样命名:
我已经创建函数来获取对象的ID(在[]括号内),因为它是GameObject名称的相关部分.
ID应该是唯一的,但我不确定它是什么!
现在,我希望有一个这个原型的功能:
public static GameObject[] getObjectsWithIdentifier(int identifier)
Run Code Online (Sandbox Code Playgroud)
它将返回具有参数中给出的标识符的所有对象.所以它就像一个搜索功能.
GameObject.Find(name)据我所知,只搜索对象的确切名称.
谢谢你的帮助 !