Exemplo n.º 1
0
        private static object LoadNodeValue(Type valueType, XmlElement nodeField)
        {
            if (valueType == typeof(int))
            {
                return(QuickUtils.ParseInt(nodeField.FirstChild.InnerText));
            }
            else if (valueType == typeof(float))
            {
                return(QuickUtils.ParseFloat(nodeField.FirstChild.InnerText));
            }
            else if (valueType == typeof(string))
            {
                return(nodeField.FirstChild.InnerText);
            }
            else if (valueType == typeof(bool))
            {
                return(QuickUtils.ParseBool(nodeField.FirstChild.InnerText));
            }
            else if (valueType.IsEnum)
            {
                return(QuickUtils.ParseEnum(valueType, nodeField.FirstChild.InnerText));
            }
            else if (IsUnityFloatContainer(valueType))
            {
                return(LoadUnityFloatContainer(valueType, nodeField));
            }
            else if (valueType.IsSubclassOf(typeof(UnityEngine.Object)))
            {
#if UNITY_EDITOR
                string guid      = nodeField.FirstChild.InnerText;
                string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
                return(UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath, valueType));
#endif
            }
            //else if (valueType.IsClass) return Activator.CreateInstance(valueType);

            return(null);
        }