Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug MissingMethodException System.MathF : Cbrt(float) in Adroid build

Discussion in 'Scripting' started by OlegHCP, Jan 15, 2023.

  1. OlegHCP

    OlegHCP

    Joined:
    Mar 7, 2017
    Posts:
    44
    The exception is thown in il2cpp build on for android. Other System.MathF functions wok fine (for example MathF.Pow(float, float)). Does anyone know anything about this?
    Unity 2022.1.24
    .net standart 2.1
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,711
    Any reason you don't just use UnityEngine.Mathf instead? Cbrt can just be done with
    Mathf.Pow(n,1f/3)
     
  3. OlegHCP

    OlegHCP

    Joined:
    Mar 7, 2017
    Posts:
    44
    UnityEngine.Mathf is a wrapper. It calls System.Math (double) inside. So I can't see many reasons to use it. And I know about pow 1/3 but that's not the point. If there is a list of broken functions it would be nice to see it. And would be nice to know whether it's a bug or what.
     
  4. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,524
    While that's true, an Android build goes through IL2CPP anyways and it should map the Mathf methods to the native C++ counterpart. Using Unity's Mathf wrapper also guarantees support on all platforms, which the relatively new MathF seems to be lacking. MathF was introduced in .NET Core 2.1+ (2018) or .NET 5+ (2020).
     
    Kurt-Dekker likes this.