本文整理汇总了C#中Text.SetFont方法的典型用法代码示例。如果您正苦于以下问题:C# Text.SetFont方法的具体用法?C# Text.SetFont怎么用?C# Text.SetFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text.SetFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateScene
async void CreateScene()
{
scene = new Scene();
scene.CreateComponent<Octree>();
var physics = scene.CreateComponent<PhysicsWorld>();
physics.SetGravity(new Vector3(0, 0, 0));
// Camera
var cameraNode = scene.CreateChild();
cameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
cameraNode.CreateComponent<Camera>();
Viewport = new Viewport(Context, scene, cameraNode.GetComponent<Camera>(), null);
RenderPath effectRenderPath = Viewport.RenderPath.Clone();
var fxaaRp = ResourceCache.GetXmlFile(Assets.PostProcess.FXAA3);
effectRenderPath.Append(fxaaRp);
Viewport.RenderPath = effectRenderPath;
Renderer.SetViewport(0, Viewport);
var zoneNode = scene.CreateChild();
var zone = zoneNode.CreateComponent<Zone>();
zone.SetBoundingBox(new BoundingBox(-300.0f, 300.0f));
zone.AmbientColor = new Color(1f, 1f, 1f);
// UI
coinsText = new Text();
coinsText.HorizontalAlignment = HorizontalAlignment.Right;
coinsText.SetFont(ResourceCache.GetFont(Assets.Fonts.Font), Graphics.Width / 20);
UI.Root.AddChild(coinsText);
Input.SetMouseVisible(true, false);
// Background
var background = new Background();
scene.AddComponent(background);
background.Start();
// Lights:
var lightNode = scene.CreateChild();
lightNode.Position = new Vector3(0, -5, -40);
lightNode.AddComponent(new Light { Range = 120, Brightness = 0.8f });
// Game logic cycle
bool firstCycle = true;
while (true)
{
var startMenu = scene.CreateComponent<StartMenu>();
await startMenu.ShowStartMenu(!firstCycle); //wait for "start"
startMenu.Remove();
await StartGame();
firstCycle = false;
}
}
示例2: ShowStartMenu
public async Task ShowStartMenu(bool gameOver)
{
var cache = Application.ResourceCache;
bigAircraft = Node.CreateChild();
var model = bigAircraft.CreateComponent<StaticModel>();
if (gameOver)
{
model.Model = cache.GetModel(Assets.Models.Enemy1);
model.SetMaterial(cache.GetMaterial(Assets.Materials.Enemy1).Clone(""));
bigAircraft.SetScale(0.3f);
bigAircraft.Rotate(new Quaternion(180, 90, 20), TransformSpace.Local);
}
else
{
model.Model = cache.GetModel(Assets.Models.Player);
model.SetMaterial(cache.GetMaterial(Assets.Materials.Player).Clone(""));
bigAircraft.SetScale(1f);
bigAircraft.Rotate(new Quaternion(0, 40, -50), TransformSpace.Local);
}
bigAircraft.Position = new Vector3(10, 2, 10);
bigAircraft.RunActions(new RepeatForever(new Sequence(new RotateBy(1f, 0f, 0f, 5f), new RotateBy(1f, 0f, 0f, -5f))));
//TODO: rotor should be defined in the model + animation
rotor = bigAircraft.CreateChild();
var rotorModel = rotor.CreateComponent<Box>();
rotorModel.Color = Color.White;
rotor.Scale = new Vector3(0.1f, 1.5f, 0.1f);
rotor.Position = new Vector3(0, 0, -1.3f);
var rotorAction = new RepeatForever(new RotateBy(1f, 0, 0, 360f*6)); //RPM
rotor.RunActions(rotorAction);
menuLight = bigAircraft.CreateChild();
menuLight.Position = new Vector3(-3, 6, 2);
menuLight.AddComponent(new Light { LightType = LightType.Point, Brightness = 0.3f });
await bigAircraft.RunActionsAsync(new EaseIn(new MoveBy(1f, new Vector3(-10, -2, -10)), 2));
textBlock = new Text();
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Bottom;
textBlock.Value = gameOver ? "GAME OVER" : "TAP TO START";
textBlock.SetFont(cache.GetFont(Assets.Fonts.Font), Application.Graphics.Width / 15);
Application.UI.Root.AddChild(textBlock);
menuTaskSource = new TaskCompletionSource<bool>();
finished = false;
await menuTaskSource.Task;
}
示例3: Show
public void Show(Color color, int fontSize = 18)
{
if (text != null)
return;
text = new Text();
text.SetColor(color);
text.VerticalAlignment = VerticalAlignment.Top;
text.HorizontalAlignment = HorizontalAlignment.Right;
text.TextAlignment = HorizontalAlignment.Right;
text.SetFont(CoreAssets.Fonts.AnonymousPro, fontSize);
application.UI.Root.AddChild(text);
subscription = application.Engine.SubscribeToPostUpdate(OnPostUpdate);
}
示例4: CreateScene
async void CreateScene()
{
scene = new Scene();
scene.CreateComponent<Octree>();
var physics = scene.CreateComponent<PhysicsWorld>();
physics.SetGravity(new Vector3(0, 0, 0));
// Camera
var cameraNode = scene.CreateChild();
cameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
cameraNode.CreateComponent<Camera>();
Renderer.SetViewport(0, Viewport = new Viewport(Context, scene, cameraNode.GetComponent<Camera>(), null));
// UI
coinsText = new Text();
coinsText.HorizontalAlignment = HorizontalAlignment.Right;
coinsText.SetFont(ResourceCache.GetFont(Assets.Fonts.Font), Graphics.Width / 20);
UI.Root.AddChild(coinsText);
Input.SetMouseVisible(true, false);
// Background
var background = new Background();
scene.AddComponent(background);
background.Start();
// Lights:
var lightNode1 = scene.CreateChild();
lightNode1.Position = new Vector3(0, -5, -40);
lightNode1.AddComponent(new Light { Range = 120, Brightness = 1.5f });
var lightNode2 = scene.CreateChild();
lightNode2.Position = new Vector3(10, 15, -12);
lightNode2.AddComponent(new Light { Range = 30.0f, Brightness = 1.5f });
// Game logic cycle
while (true)
{
var startMenu = scene.CreateComponent<StartMenu>();
await startMenu.ShowStartMenu(); //wait for "start"
startMenu.Remove();
await StartGame();
}
}
示例5: Show
public void Show()
{
if (text != null)
return;
var ui = application.UI;
var root = ui.Root;
var cache = application.ResourceCache;
text = new Text();
text.VerticalAlignment = VerticalAlignment.Top;
text.HorizontalAlignment = HorizontalAlignment.Right;
text.TextAlignment = HorizontalAlignment.Right;
text.SetFont(cache.GetFont("Fonts/Anonymous Pro.ttf"), 18);
root.AddChild(text);
subscription = application.Engine.SubscribeToPostUpdate(OnPostUpdate);
}
示例6: CreateScene
async void CreateScene()
{
// UI text
var helloText = new Text(Context);
helloText.Value = "Hello World from UrhoSharp";
helloText.HorizontalAlignment = HorizontalAlignment.Center;
helloText.VerticalAlignment = VerticalAlignment.Top;
helloText.SetColor(new Color(r: 0f, g: 1f, b: 1f));
helloText.SetFont(font: ResourceCache.GetFont("Fonts/Font.ttf"), size: 30);
UI.Root.AddChild(helloText);
// 3D scene with Octree
var scene = new Scene(Context);
scene.CreateComponent<Octree>();
// Box
Node boxNode = scene.CreateChild(name: "Box node");
boxNode.Position = new Vector3(x: 0, y: 0, z: 5);
boxNode.SetScale(0f);
boxNode.Rotation = new Quaternion(x: 60, y: 0, z: 30);
StaticModel boxModel = boxNode.CreateComponent<StaticModel>();
boxModel.Model = ResourceCache.GetModel("Models/Box.mdl");
boxModel.SetMaterial(ResourceCache.GetMaterial("Materials/BoxMaterial.xml"));
// Light
Node lightNode = scene.CreateChild(name: "light");
var light = lightNode.CreateComponent<Light>();
light.Range = 10;
light.Brightness = 1.5f;
// Camera
Node cameraNode = scene.CreateChild(name: "camera");
Camera camera = cameraNode.CreateComponent<Camera>();
// Viewport
Renderer.SetViewport(0, new Viewport(Context, scene, camera, null));
// Do actions
await boxNode.RunActionsAsync(new EaseBounceOut(new ScaleTo(duration: 1f, scale: 1)));
await boxNode.RunActionsAsync(new RepeatForever(
new RotateBy(duration: 1, deltaAngleX: 90, deltaAngleY: 0, deltaAngleZ: 0)));
}
示例7: Start
protected override void Start()
{
var cache = ResourceCache;
var helloText = new Text()
{
Value = "Hello World from UrhoSharp",
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
helloText.SetColor(new Color(0f, 1f, 0f));
helloText.SetFont(font: cache.GetFont("Fonts/Anonymous Pro.ttf"), size: 30);
UI.Root.AddChild(helloText);
Graphics.SetWindowIcon(cache.GetImage("Textures/UrhoIcon.png"));
Graphics.WindowTitle = "UrhoSharp Sample";
// Subscribe to Esc key:
Input.SubscribeToKeyDown(args => { if (args.Key == Key.Esc) Exit(); });
}
示例8: CreateScene
async void CreateScene()
{
// UI text
helloText = new Text()
{
Value = "Hello World from MySample",
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
helloText.SetColor(new Color(0f, 1f, 1f));
helloText.SetFont(
font: ResourceCache.GetFont("Fonts/BlueHighway.ttf"),
size: 30);
UI.Root.AddChild(helloText);
// Create a top-level scene, must add the Octree
// to visualize any 3D content.
var scene = new Scene();
scene.CreateComponent<Octree>();
// Box
Node boxNode = scene.CreateChild();
boxNode.Position = new Vector3(0, 0, 5);
boxNode.Rotation = new Quaternion(60, 0, 30);
boxNode.SetScale(0f);
StaticModel modelObject = boxNode.CreateComponent<StaticModel>();
modelObject.Model = ResourceCache.GetModel("Models/Box.mdl");
// Light
Node lightNode = scene.CreateChild(name: "light");
lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f));
lightNode.CreateComponent<Light>();
// Camera
Node cameraNode = scene.CreateChild(name: "camera");
Camera camera = cameraNode.CreateComponent<Camera>();
// Viewport
Renderer.SetViewport(0, new Viewport(scene, camera, null));
// Perform some actions
await boxNode.RunActionsAsync(
new EaseBounceOut(new ScaleTo(duration: 1f, scale: 1)));
await boxNode.RunActionsAsync(
new RepeatForever(new RotateBy(duration: 1,
deltaAngleX: 90, deltaAngleY: 0, deltaAngleZ: 0)));
}
示例9: CreateButton
Button CreateButton(int x, int y, int xSize, int ySize, string text)
{
UIElement root = UI.Root;
var cache = ResourceCache;
Font font = cache.GetFont("Fonts/Anonymous Pro.ttf");
// Create the button and center the text onto it
Button button = new Button();
root.AddChild(button);
button.SetStyleAuto(null);
button.SetPosition(x, y);
button.SetSize(xSize, ySize);
Text buttonText = new Text();
button.AddChild(buttonText);
buttonText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
buttonText.SetFont(font, 12);
buttonText.Value = text;
return button;
}
示例10: SetupInstructions
void SetupInstructions()
{
var instructions = new Text()
{
Value = "Use WASD keys and mouse/touch to move",
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
var font = ResourceCache.GetFont("Fonts/Anonymous Pro.ttf");
instructions.SetFont(font, 15);
UI.Root.AddChild(instructions);
// Animating text
Text text = new Text();
text.Name = "animatingText";
text.SetFont(font, 15);
text.HorizontalAlignment = HorizontalAlignment.Center;
text.VerticalAlignment = VerticalAlignment.Center;
text.SetPosition(0, UI.Root.Height/4 + 20);
UI.Root.AddChild(text);
}
示例11: CreateSlider
Slider CreateSlider(int x, int y, int xSize, int ySize, string text)
{
UIElement root = UI.Root;
ResourceCache cache = ResourceCache;
Font font = cache.GetFont("Fonts/Anonymous Pro.ttf");
// Create text and slider below it
Text sliderText = new Text();
root.AddChild(sliderText);
sliderText.SetPosition(x, y);
sliderText.SetFont(font, 12);
sliderText.Value = text;
Slider slider = new Slider();
root.AddChild(slider);
slider.SetStyleAuto(null);
slider.SetPosition(x, y + 20);
slider.SetSize(xSize, ySize);
// Use 0-1 range for controlling sound/music master volume
slider.Range = 1.0f;
return slider;
}
示例12: CreateUI
void CreateUI()
{
var cache = ResourceCache;
// Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
// control the camera, and when visible, it will point the raycast target
XmlFile style = cache.GetXmlFile("UI/DefaultStyle.xml");
Cursor cursor = new Cursor();
cursor.SetStyleAuto(style);
UI.Cursor = cursor;
// Set starting position of the cursor at the rendering window center
var graphics = Graphics;
cursor.SetPosition(graphics.Width / 2, graphics.Height / 2);
// Construct new Text object, set string to display and font to use
var instructionText = new Text();
instructionText.Value =
"Use WASD keys to move, RMB to rotate view\n" +
"LMB to set destination, SHIFT+LMB to spawn a Jack\n" +
"CTRL+LMB to teleport main agent\n" +
"MMB to add obstacles or remove obstacles/agents\n" +
"F5 to save scene, F7 to load\n" +
"Space to toggle debug geometry";
instructionText.SetFont(cache.GetFont("Fonts/Anonymous Pro.ttf"), 15);
// The text has multiple rows. Center them in relation to each other
instructionText.TextAlignment = HorizontalAlignment.Center;
// Position the text relative to the screen center
instructionText.HorizontalAlignment = HorizontalAlignment.Center;
instructionText.VerticalAlignment = VerticalAlignment.Center;
instructionText.SetPosition(0, UI.Root.Height / 4);
UI.Root.AddChild(instructionText);
}
示例13: CreateUI
void CreateUI()
{
IsLogoVisible = false; // We need the full rendering window
var graphics = Graphics;
UIElement root = UI.Root;
var cache = ResourceCache;
XmlFile uiStyle = cache.GetXmlFile("UI/DefaultStyle.xml");
// Set style to the UI root so that elements will inherit it
root.SetDefaultStyle(uiStyle);
Font font = cache.GetFont("Fonts/Anonymous Pro.ttf");
chatHistoryText = new Text();
chatHistoryText.SetFont(font, 12);
root.AddChild(chatHistoryText);
buttonContainer = new UIElement();
root.AddChild(buttonContainer);
buttonContainer.SetFixedSize(graphics.Width, 20);
buttonContainer.SetPosition(0, graphics.Height - 20);
buttonContainer.LayoutMode = LayoutMode.Horizontal;
textEdit = new LineEdit();
textEdit.SetStyleAuto(null);
buttonContainer.AddChild(textEdit);
sendButton = CreateButton("Send", 70);
connectButton = CreateButton("Connect", 90);
disconnectButton = CreateButton("Disconnect", 100);
startServerButton = CreateButton("Start Server", 110);
UpdateButtons();
// No viewports or scene is defined. However, the default zone's fog color controls the fill color
Renderer.DefaultZone.FogColor = new Color(0.0f, 0.0f, 0.1f);
}
示例14: CreateButton
Button CreateButton(string text, int width)
{
var cache = ResourceCache;
Font font = cache.GetFont("Fonts/Anonymous Pro.ttf");
Button button = new Button();
buttonContainer.AddChild(button);
button.SetStyleAuto(null);
button.SetFixedWidth(width);
var buttonText = new Text();
button.AddChild(buttonText);
buttonText.SetFont(font, 12);
buttonText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
buttonText.Value = text;
return button;
}
示例15: CreateInstructions
void CreateInstructions()
{
var cache = ResourceCache;
UI ui = UI;
// Construct new Text object, set string to display and font to use
instructionText = new Text();
instructionText.Value = ("Use arrow up and down to control sound filtering");
instructionText.SetFont(cache.GetFont("Fonts/Anonymous Pro.ttf"), 15);
// Position the text relative to the screen center
instructionText.TextAlignment = HorizontalAlignment.Center;
instructionText.HorizontalAlignment = HorizontalAlignment.Center;
instructionText.VerticalAlignment = VerticalAlignment.Center;
instructionText.SetPosition(0, ui.Root.Height/4);
ui.Root.AddChild(instructionText);
}