Skip to content

Instantly share code, notes, and snippets.

View neoRiley's full-sized avatar

John Grden neoRiley

View GitHub Profile
@neoRiley
neoRiley / ScalableFontLabel.cs
Last active May 27, 2025 19:42
`ScalableFontLabel.cs` is a subclass of TextElement (Label etc) and gives you extra properties to dial in your font scaling. If you just want to create it with code, I've added an extension method. Be sure to grab all 3 files regardless. Add the 3 files to your project, and you should be able to add via the UI Builder IDE
using System;
using UnityEngine.UIElements;
using Utils.Extensions;
namespace N30R1L37.UI
{
[UxmlElement]
public partial class ScalableFontLabel : TextElement, IDisposable
{
private TextElementScaler _scaler;
@neoRiley
neoRiley / AspectRatioButton.cs
Last active October 4, 2024 00:37
Extends VisualElement and provides the ability to maintain an aspect ratio as well as add a Label who's font size is scaled with the AspectRatioPanel
using System;
using System.Collections.Generic;
using UniRx;
using UnityEngine;
using UnityEngine.UIElements;
namespace N30R1L37
{
[UnityEngine.Scripting.Preserve]