Hey there!
I have a Serializable Class called SaveFile with a System.DateTime field in it.
However when I load the Scriptable Object with the SaveFile Class in it all the System.DateTime fields default to January 1st, 0001, Midnight.
Is there a way to keep the fields as System.DateTime rather than saving it as a value type and converting back and forth?
Any help would be great! Thanks!
Thanks!
EDIT
Also wanted to mention that way to save the timestamp is to use a ‘long’ and get the Ticks property from the DateTime struct.
Unity can’t serialize DateTime values. Have a look at script serialization. There’s a list of types Unity can serialize. You can implement the “ISerializationCallbackReceiver” interface as shown in the manual and serialize the DateTime value to a value that Unity can serialize.