Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Dhelio

3
Posts
1
Topics
A member registered Apr 03, 2020

Recent community posts

SOLVED.


Turns out that parsing float uses CultureInfo to determine what counts as a separator; for example, I'm italian and we typically use comma as separator, so writing the float in the xml file as "1.0" makes it not parsable according to italian CultureInfo. So weight values in the xml file should be separated by comma, not point.

Relevant Stackoverflow question: https://stackoverflow.com/questions/5592950/why-do-i-get-a-formatexception-when-...

Sure!

https://pastebin.com/2CSbF3vk

(2 edits)

Hi,

I'm trying to implement the Simple Tiled Model, but it throws exception on this line of SimpleTiledModel.cs:


for (int t = 0; t < cardinality; t++) tempStationary.Add(xtile.Get("weight", 1.0f));


The error is "

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, System.Globalization.NumberStyles style, System.IFormatProvider provider) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.ComponentModel.SingleConverter.FromString (System.String value, System.Globalization.NumberFormatInfo formatInfo) (at <ae22a4e8f83c41d69684ae7f557133d9>:0)
System.ComponentModel.BaseNumberConverter.ConvertFrom (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) (at <ae22a4e8f83c41d69684ae7f557133d9>:0)
Rethrow as Exception: 1.0f is not a valid value for Single.
System.ComponentModel.BaseNumberConverter.ConvertFrom (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value) (at <ae22a4e8f83c41d69684ae7f557133d9>:0)
System.ComponentModel.TypeConverter.ConvertFromString (System.String text) (at <ae22a4e8f83c41d69684ae7f557133d9>:0)
Stuff.Get[T] (System.Xml.XmlNode node, System.String attribute, T defaultT) (at Assets/unity-wave-function-collapse/impl/Stuff.cs:53)
SimpleTiledModel..ctor (System.String name, System.String subsetName, System.Int32 width, System.Int32 height, System.Boolean periodic) (at Assets/unity-wave-function-collapse/impl/SimpleTiledModel.cs:125)
SimpleTiledWFC.Generate () (at Assets/unity-wave-function-collapse/SimpleTiledWFC.cs:85)
TileSetEditor.OnInspectorGUI () (at Assets/unity-wave-function-collapse/SimpleTiledWFC.cs:135)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <af78ad00a40d4f61b82afc6cafb0a416>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)"