A game about forced loneliness, made by TACStudios
1using System; 2using UnityObject = UnityEngine.Object; 3 4namespace Unity.VisualScripting 5{ 6 [FuzzyOption(typeof(Literal))] 7 public class LiteralOption : UnitOption<Literal> 8 { 9 public LiteralOption() : base() { } 10 11 public LiteralOption(Literal unit) : base(unit) 12 { 13 sourceScriptGuids = UnitBase.GetScriptGuids(unit.type).ToHashSet(); 14 } 15 16 public Type literalType { get; private set; } 17 18 protected override void FillFromUnit() 19 { 20 literalType = unit.type; 21 base.FillFromUnit(); 22 } 23 24 protected override string Label(bool human) 25 { 26 if (unit.value is UnityObject uo && !uo.IsUnityNull()) 27 { 28 return UnityAPI.Await(() => uo.name); 29 } 30 31 return unit.type.SelectedName(human) + " Literal"; 32 } 33 34 protected override EditorTexture Icon() 35 { 36 if (unit.value is UnityObject uo && !uo.IsUnityNull()) 37 { 38 return uo.Icon(); 39 } 40 41 return base.Icon(); 42 } 43 44 protected override string FavoriteKey() 45 { 46 return $"{literalType.FullName}@literal"; 47 } 48 49 public override void Deserialize(UnitOptionRow row) 50 { 51 base.Deserialize(row); 52 53 literalType = Codebase.DeserializeType(row.tag1); 54 } 55 56 public override UnitOptionRow Serialize() 57 { 58 var row = base.Serialize(); 59 60 row.tag1 = Codebase.SerializeType(literalType); 61 62 return row; 63 } 64 } 65}