A game about forced loneliness, made by TACStudios
1using System; 2using UnityEngine; 3 4namespace Unity.VisualScripting 5{ 6 public static class ObjectVariables 7 { 8 public static VariableDeclarations Declarations(GameObject source, bool autoAddComponent, bool throwOnMissing) 9 { 10 Ensure.That(nameof(source)).IsNotNull(source); 11 12 var variables = source.GetComponent<Variables>(); 13 14 if (variables == null && autoAddComponent) 15 { 16 variables = source.AddComponent<Variables>(); 17 } 18 19 if (variables != null) 20 { 21 return variables.declarations; 22 } 23 24 if (throwOnMissing) 25 { 26 throw new InvalidOperationException($"Game object '{source.name}' does not have variables."); 27 } 28 else 29 { 30 return null; 31 } 32 } 33 } 34}