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 andycodes · Aug 22, 2020 at 02:09 AM · il2cpp

[Resolved] IL2CPP Argument Out Of Range Exception When using "in" keyword

I'm getting the following error when performing an Android build in Unity Cloud Build: [Unity] IL2CPP error for method 'System.Void VectorMath.Vector2D::.ctor(System.Single&,System.Single&)'

il2cpp.exe didn't catch exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

This error is referring to this code from my project:

 public Vector2D(in float x = 0.0f, in float y = 0.0f)
 {
     this.x = x;
     this.y = y;
 }

I've been trying to make a faster Vector Math library for some more intensive operations. A lot of the methods take Advantage of the in keyword introduced in C# version 7.2 to improve performance.

I'm currently using Unity 2018.4 LTS, and am using the following build settings:

alt text

Is this an issue with how I'm using the in keyword, or is this an issue with compiler support? I read around and saw that the 2018.4 version should be able to support a .NET 4.6 Equivalent, which I've assumed up to this point means the .NET 4.x equivalent. Do I need to update to 2019.x to be able to use this? Source for C# compiler: https://docs.unity3d.com/2018.4/Documentation/Manual/CSharpCompiler.html

screen-shot-2020-08-21-at-100409-pm.png (60.6 kB)
Comment
Add comment · Show 1
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 · Aug 24, 2020 at 11:54 AM 0
Share

This is a bug in IL2CPP that has been corrected in 2019.4 and later, as far as I recall. If you would like to use the in modifier, please try that version of Unity or newer.

1 Reply

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

Answer by andycodes · Aug 22, 2020 at 02:57 AM

So I found out what was failing, but I don't know why. Removing the in keyword from the constructors that had default float values seems to have fixed all my woes. If anyone knows why this is, I'd like to be enlightened!

Working code:

 public Vector2D(float x = 0.0f, float y = 0.0f)
 {
     this.x = x;
     this.y = y;
 }
Comment
Add comment · Show 1 · 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
avatar image Bunny83 · Aug 24, 2020 at 02:35 PM 0
Share

Have you read the documentation? The in modifier makes the argument being passed by reference instead of passed by value. If there's an actual improvement is questionable since passing a float variable by reference would require a 64 bit memory address being passed in (at least on 64bit systems), instead of a 32 bit float value. Since the in modifier makes the argument passed by reference the parameter has to be a variable. In any case you don't pass in a variable but a constant / immediate value, the compiler has to generate a temp variable. Like Josh said above the IL2CPP compiler probably has / had issues with that required temp variable.

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

132 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

Related Questions

Can't builder IOS in Unity5.0f4 Exception:UnusedBytecodeStripper2.exe 1 Answer

Unity 5.0.2 iOS IL2CPP Networking RPC Issues 1 Answer

IL2CPP Build error with enum or coroutine. 0 Answers

iOS build error (5.3.6p6) "UnusedBytecodeStripper2.exe" did not run properly! 1 Answer

Why doesn't IL2CPP support latest version of NDK? 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