コード例 #1
0
ファイル: RaiseSignal.cs プロジェクト: pavel-fadrhonc/of2
     public void OnAfterDeserialize()
     {
 #if ODIN_INSPECTOR
         _parameters =
             SerializationUtility.DeserializeValueWeak(_parametersSerializedBA, DataFormat.JSON, referencedObjects) as object[];
 #endif
     }
コード例 #2
0
        public static object Deserialize(byte[] json, List <UnityEngine.Object> objectReferences)
        {
            if (json == null || json.Length == 0)
            {
                return(null);
            }

            return(SerializationUtility.DeserializeValueWeak(json, DataFormat.JSON, objectReferences));
        }
コード例 #3
0
        public static bool DeserializeOverrideNonUnityObject(string stringData, Type type, ref object objectToOverwrite, List <Object> objectReferences)
        {
            if (type == Types.String)
            {
                objectToOverwrite = stringData;
                return(true);
            }

                        #if !DONT_USE_ODIN_SERIALIZER
            if (JsonDotNetCanHandlePropertySerialization(type))
                        #endif
            {
                try
                {
                    objectToOverwrite = JsonConvert.DeserializeObject(stringData, type, InspectorPreferences.jsonSerializerSettings);
                    return(true);
                }
                                #if DEV_MODE && DEBUG_DESERIALIZE_FAIL
                catch (Exception e)
                {
                    Debug.Log("JsonConvert failed deserializing to " + StringUtils.ToStringSansNamespace(type) + ": " + e);
                                #else
                catch
                {
                                #endif
                    return(false);
                }
            }

                        #if !DONT_USE_ODIN_SERIALIZER
            try
            {
                var bytes = Encoding.UTF8.GetBytes(stringData);
                objectToOverwrite = SerializationUtility.DeserializeValueWeak(bytes, DataFormat.JSON, objectReferences);
                                #if DEV_MODE && DEBUG_DESERIALIZE
                Debug.Log("OdinSerializer deserialized to " + StringUtils.ToString(type) + ": " + StringUtils.ToString(objectToOverwrite));
                                #endif
                return(true);
            }
                        #if DEV_MODE && DEBUG_DESERIALIZE_FAIL
            catch (Exception e)
            {
                Debug.Log("OdinSerializer failed deserializing to " + StringUtils.ToString(type) + ": " + e);
                return(false);
            }
                        #else
            catch
            {
                return(false);
            }
                        #endif
                        #endif
        }