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); }
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"); }
public override void Render(GameObjectElementBuilder builder, PropCollection props) { base.Render(builder, props); var text = builder.AddComponent <Text>(); var textValue = props.GetString("text", string.Empty); text.SetPropertyDelayed(e => e.font, () => Font.CreateDynamicFontFromOSFont("Arial", 16)); text.SetProperty(e => e.color, Color.black); text.SetProperty(e => e.text, textValue); }
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); }