public bool Set(object obj) { var newValue = string.Empty; if (obj != null) { Type type = m_Type; if (!type.IsAssignableFrom(obj.GetType())) { if (obj is UnityEngine.Object && (obj as UnityEngine.Object == null)) { // Some object couldn't be loaded. just ignore it. } else if (obj is Texture && typeof(Texture).IsAssignableFrom(type)) { } else { throw new ArgumentException(string.Format("Cannot assign an object of type {0} to VFXSerializedObject of type {1}", obj.GetType(), (Type)m_Type)); } } newValue = VFXSerializer.Save(obj); } m_CachedValue = obj; if (m_SerializableObject != newValue) { m_SerializableObject = newValue; return(true); } return(false); }
public static TypedSerializedData SaveWithType(object obj) { TypedSerializedData data = new TypedSerializedData(); data.data = VFXSerializer.Save(obj); data.type = obj.GetType().AssemblyQualifiedName; return(data); }
public static object LoadWithType(TypedSerializedData data, object oldValue) { if (!string.IsNullOrEmpty(data.data)) { System.Type type = SerializableType.GetType(data.type); if (type == null) { Debug.LogError("Can't find type " + data.type); return(null); } return(VFXSerializer.Load(type, data.data, oldValue)); } return(null); }
public object Get() { return(VFXSerializer.Load(m_Type, m_SerializableObject, m_CachedValue)); }