Using the following code I’m creating a Button, UI Page, UI Component, then adding it to an newly created Entity, attempting to rotate that entity, and finally adding it the current scene. All of this works with exception for the button does not rotate, even though I’ve modified the transform rotation (Quaternion Y). Why does this not work?
var entity = new Entity(position: new Vector3(0, 0, 0), name: “TestEntity”);
var spriteSheet = Content.Load(“SpriteSheet”);
var buttonUpImage = (SpriteFromTexture)spriteSheet[“button_up”];
var buttonDownImage = (SpriteFromTexture)spriteSheet[“button_down”];
var buttonMouseImage = (SpriteFromTexture)spriteSheet[“button_mouse”];
var buttonSize = new Vector3(spriteSheet[“button_up”].SizeInPixels.X, spriteSheet[“button_up”].SizeInPixels.Y, 0);
var button = new Button
{
PressedImage = buttonDownImage,
NotPressedImage = buttonUpImage,
MouseOverImage = buttonDownImage,
Size = buttonSize,
Name = “button”
};
button.SetCanvasAbsolutePosition(new Vector3(20, 20, 0));
button.Click += delegate { OnClick(); };
var backBufferSize = new Vector2(GraphicsDevice.Presenter.BackBuffer.Width, GraphicsDevice.Presenter.BackBuffer.Height);
var centerPoint = new Vector2(backBufferSize.X / 2, backBufferSize.Y / 2);
var rootElement = new Canvas() { Children = { button }, MaximumWidth = backBufferSize.X, MaximumHeight = backBufferSize.Y };
var page = new UIPage { RootElement = rootElement };
var uic = new UIComponent { Page = page };
entity.Add(uic);
uic.Entity.Transform.Rotation = Quaternion.RotationY(35.0f);
SceneSystem.SceneInstance.RootScene.Entities.Add(entity);