1
我正在開發一個Unity託管插件。目前,然而,當我想用嵌入式資源,如圖像,Texture2D
不加載字節的dll工作正常。有沒有人遇到過這種情況?將紋理圖像統一爲嵌入式資源
這裏是我的代碼,看看如果圖像是真正加載到字節,它的工作原理:
try
{
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream myStream = myAssembly.GetManifestResourceStream("QBoard");
img = ReadFully (myStream);
print(img.Length);
}
catch
{
print("Error accessing resources!");
}
然而,當我希望將圖像加載從DLL如下:
questionTexture.LoadImage(img);
GUI.Box (new Rect (dWidth/2-50, dHeight/2-50,200,50),new
GUIContent(qlist.text,questionTexture));
結果是在統一編輯器中的測試項目出現以下錯誤:
NullReferenceException: Object reference not set to an instance of an object