I'm having the same issue, it's really simple to reproduce it as well.
NOTE: It only occurs when building to an iOS device, this error message DOES NOT pop up when using the Editor!
The version of libjpeg included in Unity's libiPhone-lib.a file is an older version than what was included in Scaleform 4.2's libraries (which are copied over using the PostprocessBuildPlayer perl script)
Scaleform copies libjpeg.a from the Unity Project Root/Assets/Lib/iPhone-armv7/clang/libjpeg.a when deploying to the Xcode project created when you do a build inside Unity for iOS
Here's the steps to reproduce this issue:
1) Create a new Unity project
2) Import Scaleform's .unitypackage as per the readme/tutorial docs (NOTE: I also tested it with the ScaleformTutorial_Consumer.unitypackage as we have purchased a SF/Unity iOS license)
3) Create a folder called 'Resources' under the 'Assets' folder
4) Create a folder called 'Levels' under the 'Resources' folder
5) Place Level0001.jpeg in the 'Levels' folder (NOTE: It is not a jpeg, I had to rename it to upload to this forum)
6) Rename the Level0001.jpeg to Level0001.bytes
7) Create a script called TestJPEGLibrary.cs in the Assets/scripts folder
8) Paste the listing below (TestJPEGLibrary.cs) in the above script file
9) Open the main_level.unity scene from the demo you extracted
10) Create an empty GameObject and attach TestJPEGLibrary.cs to it
11) Build to an iOS Device (I selected the 'Symlink Unity libraries' checkbox)
NOTE: that the issue occurs when calling the Texture2D.LoadImage(byte [] data) method (I would assume the same would be true when using www.data as per Mann1ng's post.
The following is printed in the Xcode console when running the build with an attached device:
Wrong JPEG library version: library is 80, caller expects 61
Because of the version mismatch, any data loaded by the Texture2D is invalid/corrupt/useless.
Listing for TestJPEGLibrary.cs:
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using System.IO;
#endif
public class TestJPEGLibrary : MonoBehaviour
{
private bool hasTriedLevelLoad = false;
public void Update()
{
if(!hasTriedLevelLoad)
{
hasTriedLevelLoad = true;
LoadLevel("Level0001");
}
}
public void LoadLevel(string name)
{
if (string.IsNullOrEmpty(name))
{
Debug.LogError("Invalid Level Name: Empty");
return;
}
//UNITY DOES NOT RELOAD .bytes files in resources until Unity is reloaded or some other conditions are met
//Building to device uses the resources loaded in memory and not the actual files in the folder
#if UNITY_EDITOR
if (!File.Exists(Application.dataPath + "/Resources/Levels/" + name + ".bytes"))
{
Debug.LogError("Invalid Level Name: Does not exist");
return;
}
byte [] bytes = File.ReadAllBytes(Application.dataPath + "/Resources/Levels/" + name + ".bytes");
#else
TextAsset ta = Resources.Load("Levels/" + name) as TextAsset;
if (ta == null)
{
Debug.LogError("Invalid Level Name: Does not exist");
return;
}
byte[] bytes = ta.bytes;
#endif
Texture2D level = new Texture2D(0, 0);
level.LoadImage(bytes);
MonoBehaviour.Destroy(level);
}
}