public override void Render(GameObjectElementBuilder builder, PropCollection props) { base.Render(builder, props); var image = builder.AddComponent <Image>(); var button = builder.AddComponent <Button>(); var onClick = props.GetCallbackAction("onClick"); if (onClick != null) { var buttonClickedEvent = new Button.ButtonClickedEvent(); buttonClickedEvent.AddListener(new UnityAction(onClick)); button.SetProperty(OnClick, buttonClickedEvent); } var imageResource = props.GetString("image", null); if (imageResource != null) { image.SetProperty(Sprite, ComponentResources.Get(imageResource) as Sprite); } image.SetProperty(Type, Image.Type.Sliced); }
private void Awake() { foreach (var resource in resources) { ComponentResources.Register(resource.name, resource); } ComponentResources.Register("ArialFont", Font.CreateDynamicFontFromOSFont("Arial", 16)); }
public override void Render(GameObjectElementBuilder builder, PropCollection props) { base.Render(builder, props); var image = builder.AddComponent <Image>(); var imageResource = props.GetString("image", null); if (imageResource != null) { image.SetProperty(Sprite, ComponentResources.Get(imageResource) as Sprite); } image.SetProperty(Type, Image.Type.Sliced); }
public override void Render(GameObjectElementBuilder builder, PropCollection props) { base.Render(builder, props); var text = builder.AddComponent <Text>(); var textValue = props.GetString("text", string.Empty); var alignment = props.GetEnum("textAnchor", TextAnchor.UpperLeft); var alignByGeometry = props.GetString("alignByGeometry", "false"); text.SetProperty(Font, ComponentResources.Get("ArialFont") as Font); text.SetProperty(ColorProp, Color.black); text.SetProperty(Text, textValue); text.SetProperty(Alignment, alignment); text.SetProperty(AlignByGeometry, alignByGeometry == "true"); }