Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question FormatException. ElectiveExtensions.cs

Discussion in 'Unity MARS' started by Cedric_3DM, Dec 10, 2020.

  1. Cedric_3DM

    Cedric_3DM

    Joined:
    Nov 13, 2020
    Posts:
    3
    Hi everyone,

    I have an issue when i try to build or even i just do a "Build settings check" in Mars :

    FormatException: Input string was not in a correct format.
    System.Number.ParseSingle (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) (at <9577ac7a62ef43179789031239ba8798>:0)
    System.Single.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <9577ac7a62ef43179789031239ba8798>:0)
    System.Single.Parse (System.String s) (at <9577ac7a62ef43179789031239ba8798>:0)
    UnityEditor.MARS.Build.ElectiveExtensions.EqualOrNewerVersion (System.String current, System.String minimum) (at Library/PackageCache/com.unity.mars@1.2.0/Editor/Scripts/Build/ElectiveExtensions.cs:126)
    UnityEditor.MARS.Build.ElectiveExtensions+<>c.<CheckUnityEditorVersion>b__5_0 (System.String version) (at Library/PackageCache/com.unity.mars@1.2.0/Editor/Scripts/Build/ElectiveExtensions.cs:100)
    System.Linq.Enumerable.Any[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
    UnityEditor.MARS.Build.ElectiveExtensions.CheckUnityEditorVersion (UnityEditor.MARS.Build.ElectiveExtensions+SupportedConfiguration config) (at Library/PackageCache/com.unity.mars@1.2.0/Editor/Scripts/Build/ElectiveExtensions.cs:100)
    UnityEditor.MARS.Build.ElectiveExtensions.RunReport (UnityEditor.MARS.Build.ElectiveExtensions+SupportedConfiguration config) (at Library/PackageCache/com.unity.mars@1.2.0/Editor/Scripts/Build/ElectiveExtensions.cs:28)
    UnityEditor.MARS.Build.ElectiveExtensionsToolbarMenu.RunElectiveExtensionsBuildCheck () (at Library/PackageCache/com.unity.mars@1.2.0/Editor/Scripts/Build/ElectiveExtensionsToolbarMenu.cs:12)

    I just created a new project (Unity 1019.4.16f1), imported Mars, loaded the "Tabletop" template and i get this error... (I don't modify anything in the template)

    Thanks for your help !

    Cedric
     
  2. Seth_Persigehl_Unity

    Seth_Persigehl_Unity

    Unity Technologies

    Joined:
    Sep 25, 2019
    Posts:
    5
    Hi Cedric, thanks for reaching out!

    I've tested building the tabletop scene on 2019.04.16f1 on both Windows and MacOS to both Android and iOS but wasn't able to replicate the error you've experienced.

    Would you be willing to send me your Packages/manifest.json from your project folder? It looks like one of the package versions isn't parsing correctly.
    Which platform are you editing on? (Mac / PC)
    Which build target are you building for? (Android / iOS)
    Finally, is the project still building successfully, or does this halt the build with this error?
     
  3. Cedric_3DM

    Cedric_3DM

    Joined:
    Nov 13, 2020
    Posts:
    3
    Hi !
    I am on PC and try to build for Android and this error stop the building process.
    I've attached the manifest.json.

    Thanks !
     

    Attached Files:

  4. Seth_Persigehl_Unity

    Seth_Persigehl_Unity

    Unity Technologies

    Joined:
    Sep 25, 2019
    Posts:
    5
    Hi Cedric, thanks for providing your package manifest!

    I've now found a way to force the error to appear. Since this is a build-blocking issue, I'd like to try adding the following code to skip the editor version checking code that seems to be causing the issue. Please do the following:

    Open the file `[your unity project]\Library\PackageCache\com.unity.mars@1.2.0\Editor\Scripts\Build\ElectiveExtensions.cs`

    Paste the following code into a new line at line #125 (right above the line that starts with "var currentVersion"):

    Code (CSharp):
    1. Debug.Log($"MARS Debugging report: \nUnity Editor Version: '{Application.unityVersion}'\nRegex currentMatch: '{currentMatch.Groups[0].Value}'\nRegex minimumMatch: '{minimumMatch.Groups[0].Value}'\nDebug output complete. Overriding version check value and returning 'true'");
    2.             return true;
    This should allow the code to (temporarily) skip over the error. Please send me a copy of the new "MARS Debugging report" debug output and let me know if this lets you build to Android again.
     
  5. Cedric_3DM

    Cedric_3DM

    Joined:
    Nov 13, 2020
    Posts:
    3
    Hey Seth,

    Thanks a LOT for this "tip" that solved the issue ! :)
    Now, i can build to Android !

    MARS Debugging report:
    Unity Editor Version: '2019.4.16f1'
    Regex currentMatch: '2019.4'
    Regex minimumMatch: '2019.3'
    Debug output complete. Overriding version check value and returning 'true'
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  6. styGGx

    styGGx

    Joined:
    Aug 27, 2017
    Posts:
    19
    Hi there @Seth_Persigehl_Unity.

    I have the same problem.

    I am using Unity 2020.3.6f1 with the Unity MARS package version 1.3.1.
    Edit: I've also tried this with Unity 2019.4.23f1 LTS, same results

    When I try to modify the ElectiveExtensions.cs to add the code pasted above, as soon as I focus the Editor again, the inserted code gets stripped out and restored to its original state.

    Steps to reproduce:
    1. Clone from https://github.com/Petrie65/unity-mars-build-fail (This is a clean project with just Unity MARS imported)
    2. Switch build platform to Android
    3. Window > MARS > Build Settings Check

    The stack trace is the same as Cedric posted above (with some different versions and line numbers):
    Code (CSharp):
    1. FormatException: Input string was not in a correct format.
    2. System.Number.ParseSingle (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    3. System.Single.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    4. System.Single.Parse (System.String s) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    5. UnityEditor.MARS.Build.ElectiveExtensions.EqualOrNewerVersion (System.String current, System.String minimum) (at Library/PackageCache/com.unity.mars@1.3.1/Editor/Scripts/Build/ElectiveExtensions.cs:102)
    6. UnityEditor.MARS.Build.ElectiveExtensions+<>c__DisplayClass8_0.<CheckSinglePackageVersion>b__0 (System.String listVersion) (at Library/PackageCache/com.unity.mars@1.3.1/Editor/Scripts/Build/ElectiveExtensions.cs:179)
    7. System.Linq.Enumerable.Any[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
    8. UnityEditor.MARS.Build.ElectiveExtensions.CheckSinglePackageVersion (System.String version, System.Collections.Generic.IEnumerable`1[T] listVersions) (at Library/PackageCache/com.unity.mars@1.3.1/Editor/Scripts/Build/ElectiveExtensions.cs:179)
    9. UnityEditor.MARS.Build.ElectiveExtensions.ComparePackagesForReport (UnityEditor.MARS.Build.ElectiveExtensions+MatchedPackagePair pair, UnityEditor.MARS.Build.ElectiveExtensions+ElectiveReport report) (at Library/PackageCache/com.unity.mars@1.3.1/Editor/Scripts/Build/ElectiveExtensions.cs:197)
    10. UnityEditor.MARS.Build.ElectiveExtensions.CheckPackageVersions (UnityEditor.MARS.Build.ElectiveExtensions+SupportedConfiguration config) (at Library/PackageCache/com.unity.mars@1.3.1/Editor/Scripts/Build/ElectiveExtensions.cs:171)
    11. UnityEditor.MARS.Build.ElectiveExtensions.RunReport (UnityEditor.MARS.Build.ElectiveExtensions+SupportedConfiguration config) (at Library/PackageCache/com.unity.mars@1.3.1/Editor/Scripts/Build/ElectiveExtensions.cs:28)
    12. UnityEditor.MARS.Build.ElectiveExtensionsToolbarMenu.RunElectiveExtensionsBuildCheck () (at Library/PackageCache/com.unity.mars@1.3.1/Editor/Scripts/Build/ElectiveExtensionsToolbarMenu.cs:12)
     
    Last edited: Jul 13, 2021
  7. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    297
    Hello @Stygian65

    I have tried to reproduce this error and I am unable to see it failing; being said that, do note that @Seth_Persigehl_Unity 's comment was for MARS 1.2.0; which in your case with MARS 1.3.1 line 125 would not be the correct line.

    Can you try adding that on line 101 (again, above var currentVersion (for MARS 1.3.1))?


    static bool EqualOrNewerVersion(string current, string minimum)
    {
    // Regex that matches the first two number components in the version
    // i.e. for "2019.4.5f1" it matches "2019.4", which we can treat as a float for comparisons
    var regex = new Regex(@"^\d+\.\d+");
    var currentMatch = regex.Match(current);
    var minimumMatch = regex.Match(minimum);

    if (!(currentMatch.Success && minimumMatch.Success))
    return false;

    // ======> ADD LINE HERE <=========

    var currentVersion = float.Parse(currentMatch.Groups[0].Value);
    var minimumVersion = float.Parse(minimumMatch.Groups[0].Value);

    return currentVersion >= minimumVersion;
    }


    Do bear in mind that Elective extensions will be disappearing on newer versions of MARS and will be changed with an enhanced system.
     
  8. styGGx

    styGGx

    Joined:
    Aug 27, 2017
    Posts:
    19
    Hi @jmunozarUTech

    It works when adding the line on 101.

    It is still a struggle to get Unity to not delete the changes, but at least I can build now thanks. :)