File size: 940 Bytes
18a519f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using Unity.VisualScripting.FullSerializer;

namespace Unity.VisualScripting
{
    public class UnitCategoryConverter : fsDirectConverter
    {
        public override Type ModelType => typeof(UnitCategory);

        public override object CreateInstance(fsData data, Type storageType)
        {
            return new object();
        }

        public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType)
        {
            serialized = new fsData(((UnitCategory)instance).fullName);

            return fsResult.Success;
        }

        public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType)
        {
            if (!data.IsString)
            {
                return fsResult.Fail("Expected string in " + data);
            }

            instance = new UnitCategory(data.AsString);

            return fsResult.Success;
        }
    }
}