Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by unity_0sdsWZad6Fwp-A · Jun 18, 2020 at 01:07 AM · raycastil2cppcomponentscompilationaot

IL2CPP Compiled Application's scripts not working

I wanted to use IL2CPP in my application to make it more performant and also harder to decompile, but whenever I compiled my game using IL2CPP, some scripts are not functining properly (Mainly ones involved in raycasting and copying components from one gameobject to another). I believe it has something to do with AOT compilation, the LOW Managed Code Stripping and or that some of my script's components are obtained via the scripts. If you have a better understanding of how IL2CPP works, please let me know what could have possibly caused this to happen.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JoshPeterson · Jun 18, 2020 at 11:09 AM 0
Share

It is really difficult to tell in general. I'd recommend checking the player log for errors or debugging the code to understand what might be wrong. See https://docs.unity3d.com/$$anonymous$$anual/$$anonymous$$anagedCodeDebugging.html for details.

avatar image unity_0sdsWZad6Fwp-A JoshPeterson · Jun 19, 2020 at 06:10 AM 0
Share

@JoshPeterson I believe the issue is just the code stripper, I tried external debugging and got an exception "$$anonymous$$icrosoft C++ exception: Il2CppExceptionWrapper at memory location ..." whenever my scripts weren't functioning. This exception is probably because the part of the scripts that didn't get removed are trying to access the removed objects which is leading to a null reference exception. I tried using a link.xml file to try and solve this, yet it still says assemblies are being stripped. I also tried using [Preserve] above my classes and [assembly: Preserve] in one of my scripts, yet this issue still seems to be occuring.

avatar image JoshPeterson unity_0sdsWZad6Fwp-A · Jun 22, 2020 at 11:52 AM 0
Share

It sounds like you attached the debugger to native code. I'd recommend following the directions in the link I mentioned to debug managed code. Then you might be able to discover what is being stripped unexpectedly.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by unity_0sdsWZad6Fwp-A · Jun 23, 2020 at 04:11 AM

I figured out that the error had been occurring because of the method that I was using for copying a TrailRenderer to another gameobject.

 public static TrailRenderer CopyTrailRenderer(this GameObject obj, TrailRenderer duplicate)
 {
     TrailRenderer target = obj.AddComponent<TrailRenderer>();
     foreach (PropertyInfo x in typeof(TrailRenderer).GetProperties())
         if (x.CanWrite)
             x.SetValue(target, x.GetValue(duplicate));
     return target;
 }

The error was occurring on the x.SetValue line and the error message was "Get Method not found for 'some TrailRenderer property'". I fixed this by manually getting and setting the properties for the TrailRenderer.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

177 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Physics.Raycast not working on il2cpp 0 Answers

Unity compilation process - JIT and AOT? 1 Answer

This parameter has to be of type: [UNREGISTERED] 0 Answers

How does Unity compilation work? 1 Answer

Is it possible to generate the .s files for AOT compiled dll's outside of Unity? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges