JohnEvans512 / UBSPMapTools

BSP map tools for Unity game engine.
MIT License
61 stars 10 forks source link

Errors when trying to import map #1

Open Skaruts opened 2 years ago

Skaruts commented 2 years ago

(Found solution, see second post.)

I'm on Unity 2019.3.13f1. When I do Tools -> BSP -> Import Map I immediately get an error:

FormatException: Input string was not in a correct format.
System.Number.ParseSingle (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Single.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Single.Parse (System.String s) (at <437ba245d8404784b9fbab9b439ac908>:0)
BSPCommon.LoadSettings () (at Assets/UBSPMapTools/Scripts/Editor/BSPCommon.cs:166)
BSPMapImport.Init () (at Assets/UBSPMapTools/Scripts/Editor/BSPMapImport.cs:419)

On this line here:

https://github.com/JohnEvans512/UBSPMapTools/blob/4c4a2eec33d40808e22ae7e41aad38694d207598/UBSPMapTools/Scripts/Editor/BSPCommon.cs#L166

I'm new to Unity and C#, so I don't know how to fix this. However, if I try to workaround it by replacing float.Parse(settings[6]) with 0.02f, then it works, but I still get similar errors during the map import process (and it fails to import):

FormatException: Input string was not in a correct format.
System.Number.ParseSingle (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Single.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Single.Parse (System.String s) (at <437ba245d8404784b9fbab9b439ac908>:0)
BSPMapImport+BSPEntity.GetVector3 (System.String key) (at Assets/UBSPMapTools/Scripts/Editor/BSPMapImport.cs:162)
BSPMapImport.LoadBSP (System.String bsp_path) (at Assets/UBSPMapTools/Scripts/Editor/BSPMapImport.cs:814)
BSPMapImport.ImportMap () (at Assets/UBSPMapTools/Scripts/Editor/BSPMapImport.cs:536)
BSPMapImport.OnGUI () (at Assets/UBSPMapTools/Scripts/Editor/BSPMapImport.cs:481)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <480b5a3bd3214ce5831f6dd8c68fdc55>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <480b5a3bd3214ce5831f6dd8c68fdc55>:0)
UnityEditor.HostView.OldOnGUI () (at <480b5a3bd3214ce5831f6dd8c68fdc55>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <95b42489e2e04430a87c3760aa29fca2>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <35bab3c7b0dc4999845bcfccc7758d96>:0)
Skaruts commented 2 years ago

Found the solution for this here. The problem has to do with the CurrentCulture settings.

There's probably an easier solution, but for now I fixed it by adding the CultureInfo.InvariantCulture argument to all calls to float.Parse and to all ToString calls that are made on float values.

The test map was imported successfully now. :)

linospngn commented 1 year ago

How do I do that?