stride/samples/Physics/PhysicsSample/PhysicsSample.Game/GuiScript.cs
2018-06-19 18:07:32 +09:00

36 lines
1.1 KiB
C#

// Copyright (c) Xenko contributors (https://xenko.com) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using Xenko.Core.Mathematics;
using Xenko.Engine;
using Xenko.Graphics;
using Xenko.UI;
using Xenko.UI.Controls;
using Xenko.UI.Panels;
namespace PhysicsSample
{
/// <summary>
/// The script in charge of displaying the UI
/// </summary>
public class GuiScript : StartupScript
{
public SpriteFont Font;
public override void Start()
{
base.Start();
var textBlock = new TextBlock
{
Text = "Shoot the cubes!",
Font = Font,
TextColor = Color.White,
TextSize = 60
};
textBlock.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 0));
textBlock.SetCanvasRelativePosition(new Vector3(0.5f, 0.9f, 0f));
Entity.Get<UIComponent>().Page = new UIPage { RootElement = new Canvas { Children = { textBlock } } };
}
}
}