No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UnitCategoryConverter.cs 940B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using Unity.VisualScripting.FullSerializer;
  3. namespace Unity.VisualScripting
  4. {
  5. public class UnitCategoryConverter : fsDirectConverter
  6. {
  7. public override Type ModelType => typeof(UnitCategory);
  8. public override object CreateInstance(fsData data, Type storageType)
  9. {
  10. return new object();
  11. }
  12. public override fsResult TrySerialize(object instance, out fsData serialized, Type storageType)
  13. {
  14. serialized = new fsData(((UnitCategory)instance).fullName);
  15. return fsResult.Success;
  16. }
  17. public override fsResult TryDeserialize(fsData data, ref object instance, Type storageType)
  18. {
  19. if (!data.IsString)
  20. {
  21. return fsResult.Fail("Expected string in " + data);
  22. }
  23. instance = new UnitCategory(data.AsString);
  24. return fsResult.Success;
  25. }
  26. }
  27. }