1. 程式人生 > >Unity 3D之cloth開發中遇到的一個問題

Unity 3D之cloth開發中遇到的一個問題

在unity 5.x開發中遇到了一個很鬱悶的問題,這個問題不會影響你的遊戲的執行,但是卻會使你在演示或是交流的時候出現尷尬。

問題描述:Mesh.colors is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
UnityEditor.ClothInspector:OnEnable()

IndexOutOfRangeException: Array index is out of range.
UnityEditor.ClothInspector.SetupSelectedMeshColors () (at C:/buildslave/unity/build/Editor/Mono/Inspector/ClothInspector.cs:337)
UnityEditor.ClothInspector.OnEnable () (at C:/buildslave/unity/build/Editor/Mono/Inspector/ClothInspector.cs:249)

看到這兩個程式碼,就知道不是自己的程式碼的問題,但是又很擔心是不是自己寫的程式碼與Unity中的cloth模組衝突了。

其實這個問題普遍會出現在對Resource中的資源匯入時出的錯誤。如果你直接在Resourse資料夾中更改Prefab的引數,當在匯入Resourse資料夾中cloth布料時就會出現上述問題。如果非要調節引數,最好是將檔案拉到Hierarchy面板中,再進行修改