From 8b6de5ca562d8fbc3b197356ee90fc37ba79acd0 Mon Sep 17 00:00:00 2001 From: Zhixiang Zhu Date: Fri, 4 May 2018 15:20:58 +0900 Subject: [PATCH] Allowed empty cells for non-enum array types. --- .../Editor/GDataDB/GDataDB/Impl/Serializer.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Assets/QuickSheet/GDataPlugin/Editor/GDataDB/GDataDB/Impl/Serializer.cs b/Assets/QuickSheet/GDataPlugin/Editor/GDataDB/GDataDB/Impl/Serializer.cs index e1b8191..50b5f0c 100644 --- a/Assets/QuickSheet/GDataPlugin/Editor/GDataDB/GDataDB/Impl/Serializer.cs +++ b/Assets/QuickSheet/GDataPlugin/Editor/GDataDB/GDataDB/Impl/Serializer.cs @@ -95,17 +95,19 @@ public T Deserialize(ListEntry e) { char[] charToTrim = { ',', ' ' }; str = str.TrimEnd(charToTrim); - // split by ',' - object[] temp = str.Split(DELIMETER); + if (!string.IsNullOrEmpty(str)) { + // split by ',' + object[] temp = str.Split(DELIMETER); - Array array = (Array)Activator.CreateInstance(property.PropertyType, temp.Length); + Array array = (Array)Activator.CreateInstance(property.PropertyType, temp.Length); - for (int i = 0; i < array.Length; i++) - { - array.SetValue(Convert.ChangeType(temp[i], property.PropertyType.GetElementType()), i); - } + for (int i = 0; i < array.Length; i++) + { + array.SetValue(Convert.ChangeType(temp[i], property.PropertyType.GetElementType()), i); + } - property.SetValue(r, array, null); + property.SetValue(r, array, null); + } } } else