public static string Create(string name, IDictionary <string, object> props = null) { var id = Guid.NewGuid().ToString(); var propCollection = new PropCollection(props); var children = propCollection.GetElements("children") .Where(e => e != null) .ToList(); var component = ComponentPool.Instance.GetComponentByName(name); if (component == null) { throw new InvalidOperationException($"Component {name} not found inside {HookComponentRegistration.CurrentContainer.Component.Name}"); } var element = new Element( id, ComponentPool.Instance.GetComponentByName(name), propCollection); foreach (var child in children) { child.Parent = element; } element.Children = children; Elements.Add(id, element); return(id); }
public override void Render(GameObjectElementBuilder builder, PropCollection props) { base.Render(builder, props); var image = builder.AddComponent <Image>(); image.SetProperty(e => e.color, Color.red); builder.RenderElements(props.GetElements("children")); }