Example #1
0
        /// <summary>
        /// Creates a text panel.
        /// </summary>
        /// <param name="content">The <c>ContentArea</c> to put the text panel in.</param>
        /// <param name="name">The name of the text panel game object.</param>
        /// <param name="size">The size of the text panel.</param>
        /// <param name="config">The configuration options for the text panel.</param>
        /// <param name="text">The <c>Text</c> component on the created text panel.</param>
        /// <returns></returns>
        public static ContentArea AddTextPanel(
            this ContentArea content,
            string name,
            RelVector2 size,
            TextPanelConfig config,
            out Text text
            )
        {
            content.AddStaticPanel(name, size, out var go);
            text          = go.AddComponent <Text>();
            text.text     = config.Text;
            text.fontSize = config.Size;
            text.font     = config.Font switch
            {
                TextPanelConfig.TextFont.TrajanRegular => MenuResources.TrajanRegular,
                TextPanelConfig.TextFont.TrajanBold => MenuResources.TrajanBold,
                TextPanelConfig.TextFont.Perpetua => MenuResources.Perpetua,
                TextPanelConfig.TextFont.NotoSerifCJKSCRegular => MenuResources.NotoSerifCJKSCRegular,
                _ => MenuResources.TrajanRegular
            };
            text.supportRichText = true;
            text.alignment       = config.Anchor;

            return(content);
        }
 /// <summary>
 /// Creates a text panel.
 /// </summary>
 /// <param name="content">The <c>ContentArea</c> to put the text panel in.</param>
 /// <param name="name">The name of the text panel game object.</param>
 /// <param name="size">The size of the text panel.</param>
 /// <param name="config">The configuration options for the text panel.</param>
 /// <returns></returns>
 public static ContentArea AddTextPanel(
     this ContentArea content,
     string name,
     RelVector2 size,
     TextPanelConfig config
     ) => content.AddTextPanel(name, size, config, out _);