MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

IL2CPP support?

Open svermeulen opened this issue 10 years ago • 16 comments

Does this package support being compiled with IL2CPP? I just tried doing that but got a bunch of errors like this:

Assets\Plugins\HoloToolkit\SpatialMapping\Scripts\RemoteMapping\MeshSaver.cs(10,24): error CS0234: The type or namespace name 'Tasks' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?)
Assets\Plugins\HoloToolkit\SpatialMapping\Scripts\SpatialProcessing\SurfaceMeshesToPlanes.cs(11,24): error CS0234: The type or namespace name 'Tasks' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?)
Assets\Plugins\HoloToolkit\CrossPlatform\Scripts\Reflection\ReflectionExtensions.cs(90,59): error CS0246: The type or namespace name 'TypeInfo' could not be found (are you missing a using directive or an assembly reference?)

svermeulen avatar Oct 06 '16 15:10 svermeulen

@NeerajW Is this something we hope to target?

jwittner avatar Oct 12 '16 16:10 jwittner

@svermeulen I don't believe we do. What is your scenario? You could try to compile it yourself using the https://github.com/Microsoft/HoloToolkit repository.

NeerajW avatar Oct 12 '16 17:10 NeerajW

This is what I do to reproduce it:

  • Clone repo
  • Open directory in Unity 5.5 beta 7
  • Change to Windows Store platform
  • Click Player Settings and change to IL2CPP
  • Run a Build
  • Observe errors

I'd like to create my app using IL2CPP because some of the libraries I'm using don't work with .NET backend (but work with IL2CPP). Also I'm assuming that my app will be faster using IL2CPP.

I'm unclear on what you're suggesting about compiling from the other HoloToolkit repo. All I want is to use the unity specific components

svermeulen avatar Oct 12 '16 17:10 svermeulen

Have you tried fixing these errors in those files? I cannot have a requirement on scripts to always test/support this option. Feel free to issue a PR with fixes. Thanks!

NeerajW avatar Oct 12 '16 18:10 NeerajW

Ok sure I will take a look and submit a pull request if I end up fixing it

svermeulen avatar Oct 12 '16 18:10 svermeulen

https://github.com/Microsoft/HoloToolkit-Unity/issues/265 Wasn't targeted explicitly for ILCPP but please check and see if this fixes the issue for you.

StephenHodgson avatar Nov 10 '16 20:11 StephenHodgson

@svermeulen any update on this?

StephenHodgson avatar Feb 24 '17 18:02 StephenHodgson

This could become an option sooner rather than later; Unity 5.6 recently added support for calling Windows Runtime APIs from IL2CPP code, which wasn't possible before. It also exposes .NET 4.6 API, so those errors in the first post should be gone now.

https://docs.unity3d.com/Manual/IL2CPP-WindowsRuntimeSupport.html https://forum.unity3d.com/threads/will-2017-1-support-async-await-on-xbox-one.464972/

Holo-Krzysztof avatar Apr 14 '17 15:04 Holo-Krzysztof

The errors are gone indeed; the remaining problem is caused by SWIG passing non-static method delegates to native code. IL2CPP is currently able to convert delegates to function pointers only when the delegate is a C# static method.

dimatomp avatar Apr 24 '17 15:04 dimatomp

Hi, sorry to reopen the issue, but at my side it still not working. I have just created a new project and added the Holotoolkit as explained in the GetStarted.md (Using the ClickThroughExample). But when I try to compile i have 3 errors

Assets\HoloToolkit\SpatialMapping\Scripts\RemoteMapping\MeshSaver.cs(162,53): error CS1061: 'StorageFile' does not contain a definition for 'OpenStreamForReadAsync' and no extension method 'OpenStreamForReadAsync' accepting a first argument of type 'StorageFile' could be found (are you missing a using directive or an assembly reference?)
Assets\HoloToolkit\SpatialMapping\Scripts\RemoteMapping\MeshSaver.cs(189,53): error CS1061: 'StorageFile' does not contain a definition for 'OpenStreamForWriteAsync' and no extension method 'OpenStreamForWriteAsync' accepting a first argument of type 'StorageFile' could be found (are you missing a using directive or an assembly reference?)
Error building Player because scripts had compiler errors`

I have selected .Net 4.6 for the API compatibility level and used Holotoolkit -> build Windows for building

Sorry for my bad english, it's not my main language.

EDIT Aparently it's working if we remove the content of the preprocessing if and only keep the content of the else

simon-baehler avatar May 31 '17 10:05 simon-baehler

I have run in to this issue as well. it would be useful to have a solution as the MeshSaver.cs gives a good example for storing and reading files on the hololens.

The issue may be on the Unity/IL2CPP side. it appears to be specific to the 'using windows.storage' namespace as this file is the only point that is used. the compiler override switches to Net Core which may be missing the namespace. The question becomes how can we get it added.

jgrif-ibm avatar Jun 29 '17 18:06 jgrif-ibm

I am still getting these errors. Is there anything official I can do about this?

eluchsinger avatar Oct 06 '17 15:10 eluchsinger

It's fixed. Make sure your project is targeting .net 4.6.

I've also got a PR for the latest version of Unity that fixes a bunch of IL2CPP issues

StephenHodgson avatar Oct 06 '17 15:10 StephenHodgson

@StephenHodgson what version are you referring to?

jsmith09 avatar Oct 16 '17 17:10 jsmith09

The latest master branch. Unsure if this got into a release just yet.

StephenHodgson avatar Oct 16 '17 17:10 StephenHodgson

Confirmed fixed using simon-baehler's solution above. Delete everything within the preprocessor 'if' and leave only the code under 'else'.

Dmarfurt avatar Oct 18 '17 21:10 Dmarfurt