Hi,
I ran into some problem using generics/templates in Unity while deploying my code to iPad.
Here is some simple code :
using UnityEngine;"
using System.Collections;
using System.Collections.Generic;
class TestValue<T>
{
public T _value;
public TestValue(T _p)
{
_value = _p;
}
}
class TestDictonary<T>
{
public Dictionary< TestValue<T>, int> _dic;
public TestDictonary(T _p)
{
_dic = new Dictionary<TestValue<T>, int>();
_dic.Add(new TestValue<T>(_p), 2);
}
public void PrintAll()
{
Debug.Log( _dic.Values.Count );
}
}
public class TestLogging : MonoBehaviour
{
void Awake()
{
TestDictonary<string> myDictionary = new TestDictonary<string>("Yep");
myDictionary.PrintAll();
}
}
While running this on my iPad i got:
ExecutionEngineException: Attempting
to JIT compile method
‘System.Collections.Generic.Dictionary2<TestValue1,
int>:.ctor ()’ while running with
–aot-only.
I have done some research and it seems a common problem ( http://ios.xamarin.com/Documentation/Limitations )
What I dont get is how could I discover that before (ie not at runtime) ?
Why is there no errors reported during compilation ?
The compilation under unity is done with the flag --aot=full … so why such cases aren’t be discovered there ?
Here is the Unity command line i had discovered in the logs - note how AOT is set to full.
AOT cross compiler: /Applications/Unity.app/Contents/BuildTargetTools/iPhonePlayer/mono-xcompiler --debug --aot=full,asmonly,write-symbols,soft-debug,static,outfile=“Assembly-CSharp.dll.s” “Assembly-CSharp.dll” current dir : /Users/XXXX/Dev/Unity/TestLogging/Temp/StagingArea/Data/Managed
Thoughts anyone ?
– da_chinese