A game about forced loneliness, made by TACStudios
1using UnityObject = UnityEngine.Object; 2 3namespace Unity.VisualScripting 4{ 5 [FuzzyOption(typeof(INesterUnit))] 6 public class NesterUnitOption<TNesterUnit> : UnitOption<TNesterUnit> where TNesterUnit : INesterUnit 7 { 8 string m_Name; 9 10 public override string formerHaystack => string.IsNullOrEmpty(m_Name) ? base.formerHaystack : m_Name; 11 12 public NesterUnitOption() : base() { } 13 14 public NesterUnitOption(TNesterUnit unit) 15 : base(unit) 16 { 17 // Store the name here as formerHaystack is called from a thread and UnitObject.Name can't be 18 // called from a thread 19 var macro = (UnityObject)unit.nest.macro; 20 m_Name = macro != null ? macro.name : string.Empty; 21 } 22 23 // TODO: Favoritable 24 public override bool favoritable => false; 25 26 protected override string Label(bool human) 27 { 28 return UnityAPI.Await(() => 29 { 30 var macro = (UnityObject)unit.nest.macro; 31 return macro != null ? macro.name : BoltFlowNameUtility.UnitTitle(unit.GetType(), false, false); 32 }); 33 } 34 } 35}