本文整理汇总了C#中UILabel.AlignTo方法的典型用法代码示例。如果您正苦于以下问题:C# UILabel.AlignTo方法的具体用法?C# UILabel.AlignTo怎么用?C# UILabel.AlignTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UILabel
的用法示例。
在下文中一共展示了UILabel.AlignTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FPSCameraUI
private FPSCameraUI()
{
var uiView = FindObjectOfType<UIView>();
var fullscreenContainer = uiView.FindUIComponent("FullScreenContainer");
cameraModeButton = uiView.AddUIComponent(typeof(UIButton)) as UIButton;
cameraModeButton.name = "FPSCameraConfigurationButton";
cameraModeButton.gameObject.name = "FPSCameraConfigurationButton";
cameraModeButton.width = 36;
cameraModeButton.height = 36;
cameraModeButton.pressedBgSprite = "OptionBasePressed";
cameraModeButton.normalBgSprite = "OptionBase";
cameraModeButton.hoveredBgSprite = "OptionBaseHovered";
cameraModeButton.disabledBgSprite = "OptionBaseDisabled";
cameraModeButton.normalFgSprite = "InfoPanelIconFreecamera";
cameraModeButton.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
cameraModeButton.scaleFactor = 1.0f;
cameraModeButton.tooltip = "FPS Camera configuration";
cameraModeButton.tooltipBox = uiView.defaultTooltipBox;
UIComponent escbutton = uiView.FindUIComponent("Esc");
cameraModeButton.relativePosition = new Vector2
(
escbutton.relativePosition.x + escbutton.width / 2.0f - cameraModeButton.width / 2.0f - escbutton.width - 8.0f,
escbutton.relativePosition.y + escbutton.height / 2.0f - cameraModeButton.height / 2.0f
);
cameraModeButton.eventClick += (component, param) => { panel.isVisible = !panel.isVisible; };
var labelObject = new GameObject();
labelObject.transform.parent = uiView.transform;
cameraModeLabel = labelObject.AddComponent<UILabel>();
cameraModeLabel.textColor = new Color32(255, 255, 255, 255);
cameraModeLabel.Hide();
FPSCamera.onCameraModeChanged = state =>
{
if (state)
{
cameraModeLabel.text = String.Format("Press ({0}) to exit first-person mode", FPSCamera.GetToggleUIKey());
cameraModeLabel.color = new Color32(255, 255, 255, 255);
cameraModeLabel.AlignTo(cameraModeButton, UIAlignAnchor.BottomRight);
cameraModeLabel.relativePosition += new Vector3(-38.0f, -8.0f);
cameraModeLabel.Show();
}
else
{
cameraModeLabel.Hide();
}
};
FPSCamera.onUpdate = () =>
{
if (cameraModeLabel.color.a > 0)
{
var c = cameraModeLabel.color;
cameraModeLabel.color = new Color32(c.r, c.g, c.b, (byte)(c.a - 1));
}
};
panel = fullscreenContainer.AddUIComponent<UIPanel>();
panel.size = new Vector2(400, 700);
panel.isVisible = false;
panel.backgroundSprite = "SubcategoriesPanel";
panel.relativePosition = new Vector3(cameraModeButton.relativePosition.x - panel.size.x, cameraModeButton.relativePosition.y + 60.0f);
panel.name = "FPSCameraConfigPanel";
var titleLabel = panel.AddUIComponent<UILabel>();
titleLabel.name = "Title";
titleLabel.text = "First-person camera configuration";
titleLabel.autoSize = false;
titleLabel.size = new Vector2(panel.size.x, 24.0f);
titleLabel.AlignTo(panel, UIAlignAnchor.TopLeft);
titleLabel.relativePosition = new Vector3(titleLabel.relativePosition.x, titleLabel.relativePosition.y + 2.0f);
titleLabel.textAlignment = UIHorizontalAlignment.Center;
float y = 48.0f;
var hotkeyToggleLabel = panel.AddUIComponent<UILabel>();
hotkeyToggleLabel.name = "ToggleFirstpersonLabel";
hotkeyToggleLabel.text = "Hotkey to toggle first-person";
hotkeyToggleLabel.relativePosition = new Vector3(4.0f, y);
hotkeyToggleLabel.textScale = 0.8f;
hotkeyToggleButton = MakeButton(panel, "ToggleFirstpersonButton",
FPSCamera.instance.config.toggleFPSCameraHotkey.ToString(), y,
() =>
{
if (!waitingForChangeCameraHotkey)
{
waitingForChangeCameraHotkey = true;
waitingForShowMouseHotkey = false;
waitingForGoFasterHotkey = false;
hotkeyToggleButton.text = "Waiting";
}
//.........这里部分代码省略.........