0
我试图将它们添加到对象的数组后卸载资产,但它返回一个错误,说我只能清除一次一个,但我不知道该怎么做统一删除资产
object[] tempItems = Resources.LoadAll("Inventory/Weapons");
foreach (object i in tempItems)
{
GameObject it = (GameObject)i;
Debug.Log(it);
itemList.Add(it);
Debug.Log(itemList.Count);
}
foreach (object i in tempItems)
{
GameObject it = (GameObject)i;
Resources.UnloadAsset(it);
}
UnloadAsset
只能在个别资产使用,不能在游戏对象的/组件AssetBundles
林现在使用
UnityEngine.Object[] tempItems = Resources.LoadAll("Inventory/Weapons");
foreach (UnityEngine.Object i in tempItems)
{
GameObject it = (GameObject)i;
Debug.Log(it);
itemList.Add(it);
Debug.Log(itemList.Count);
}
foreach (UnityEngine.Object i in tempItems)
{
Resources.UnloadAsset(i);
}
但是我仍然得到错误使用或
UnloadAsset may only be used on individual assets and can not be used on GameObject's/Components or AssetBundles
这是错误
Resources.UnloadAsset(i);
使用大写o的对象返回兼容性错误,同样使用unloadAsset建议返回相同的错误 – Sniffle6
Object'是'UnityEngine.Object'和'object'之间的歧义参考 – Sniffle6
@ Sniffle6修改了我的答案。再看一遍。如果出现错误,请写下您从中获取错误的代码行。 – Programmer