Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Serializable]
- public class Illustration : ISerializable
- {
- public Texture2D Image = new Texture2D(256, 256);
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue(nameof(Image), Image.EncodeToPNG(), typeof(byte[]));
- }
- private Illustration(SerializationInfo info, StreamingContext context)
- {
- Image.LoadImage(info.GetValue(nameof(Image), typeof(byte[])) as byte[]);
- }
- }
- [Serializable]
- public class CustomAnimation : ISerializable
- {
- public Texture2D[] Images;
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- info.AddValue(nameof(Images), Images.Select(x => x.EncodeToPNG()).ToArray(), typeof(byte[][]));
- }
- private CustomAnimation(SerializationInfo info, StreamingContext context)
- {
- var textures = info.GetValue(nameof(Images), typeof(byte[][])) as byte[][];
- if (textures != null)
- {
- var imagesAndTextures = Images.Zip(textures, (i, t) => new {Images = i, textures = t});
- foreach (var it in imagesAndTextures)
- {
- it.Images.LoadImage(it.textures);
- }
- }
- }
- }
- "Illustrations": [
- {
- "Image": {
- "instanceID": 34540
- }
- }
- ]
Add Comment
Please, Sign In to add comment