public void Initialize(Node node) { Node = node; Node.OnDeleted += () => { Destroy(gameObject); }; List <NodeComponent> createdComponents = new List <NodeComponent>(); foreach (GameObject possibleComponentObject in AvailableNodeComponents) { NodeComponent possibleComponent = possibleComponentObject.GetComponent <NodeComponent>(); if (possibleComponent.IsApplicable(Node)) { NodeComponent newComponent = Instantiate(possibleComponentObject, transform).GetComponent <NodeComponent>(); newComponent.ParentWidget = this; newComponent.LoadFrom(Node); createdComponents.Add(newComponent); } } Components = createdComponents.ToArray(); }