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); }