D
D
Dmitry Korolev2016-12-24 06:13:42
C++ / C#
Dmitry Korolev, 2016-12-24 06:13:42

How to convert string to int?

FormatException: Input string was not in the correct format
System.Int32.Parse (System.String s) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Int32.cs:629)
System. Convert.ToInt32 (System.String value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Convert.cs:1270)
PhotoPoserAuto.Mass (System.String fold) (at Assets/Scripts /PhotoPoserAuto.cs:46)
PhotoPoserAuto.GetInfo () (at Assets/Scripts/PhotoPoserAuto.cs:32)
PhotoPoserAuto.AutoPosing () (at Assets/Scripts/PhotoPoserAuto.cs:25)
PhotoPoserAutoGUI.OnInspectorGUI () (at Assets/ Scripts/PhotoPoserAutoGUI.cs:15)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1236)
UnityEditor.DockArea:OnGUI() is such an error
pastebin.com/5nA1bt54 and I
can’t figure out what’s wrong with the code, only metas are shown from the directory elements, and it doesn’t convert number paths to sort

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MrDywar Pichugin, 2016-12-24
@adressmoeistranici

1) Catch an error in the debugger, look at which value of the argument System.Int32.Parse throws an error, it's definitely not a number.
2) Use Int32.TryParse in order not to catch exceptions on your own, but simply to skip such situations.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question