- Home /
Problem using Resources.Load on iOS
Heres the Error Message I'm getting..
InvalidCastException: Cannot cast from source type to destination type. UnityEngine.Resources.Load[Sprite] (System.String path) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/BaseClass.cs:656) AnimateTap.Start () (at Assets/AnimateTap.cs:33)
Heres the code thats causing the problem...
theframes[i] = Resources.Load("anim000"+i.ToString());
This works fine on windows and android. Its is only when I change the build target to iOS that I start getting this error.
(Just to explain what I'm doing here in this line of code, I'm loading a series of seperate pngs into an array so I can easily animate them by switching the sprite in the sprite renderer.)
Answer by deltron1830 · Mar 21, 2014 at 03:36 PM
Ok. I figured it out.. The problem was with the png images I was using. It seems if you just import them as sprites as normal they will not work on iOS. You must tick the "override for iphone" box. I then selected "truecolor" format for them.
I have to say the exception I was thrown on this was not very enlightening. Could be improved imo.
Your answer
Follow this Question
Related Questions
How to log uncaught exceptions on iOS? 1 Answer
iOS - XML Serialization - JIT exception 1 Answer
unable to build for android if Scripting Backend is set up as IL2CPP 0 Answers
Unity IL2CPP 0 Answers
XCode iOS Exception 1 Answer