Unity3D之報錯 - Instantiating a non-readable texture is not allowed!


報錯:

Instantiating a non-readable 'wall_plank' texture is not allowed! Please mark the texture readable in the inspector or don't instantiate it.

情景描述:

  加載AssetBundle時,把加載出來的所有Object對象都Instantiate實例化了,實例化過程中出現該錯誤。

解決方案:

  方案1:把要使用貼圖文件(如*.Tga)的屬性(如下圖)設置Read/Write Enabled為true,對應的程序參數是TextureImporter.isReadable,即可以正常實例化。它決定了貼圖的存放位置,設置為可讀寫,在移動平台中,會將其同時放在顯存和內存中,導致內存占用增加一倍。

      

  方案2:資源加載時設置type

www.assetBundle.LoadAll(typeof(GameObject))

  方案3:遍歷資源時添加判斷

//通過字符串比較
"UnityEngine.GameObject".Equals(obj.GetType().ToString())
//通過類型比較
typeof(GameObject).IsInstanceOfType(obj)

 

參考:

【1】:http://blog.csdn.net/zzxiang1985/article/details/43339273  Unity+NGUI性能優化方法總結

【2】:http://www.u3dol.com/bbs/d/201406/6109 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM