Skip to content

Instantly share code, notes, and snippets.

@ZedDevStuff
Created June 14, 2025 09:11
Show Gist options
  • Save ZedDevStuff/3b341661b559f9963dd3b01c59790602 to your computer and use it in GitHub Desktop.
Save ZedDevStuff/3b341661b559f9963dd3b01c59790602 to your computer and use it in GitHub Desktop.
using System.Runtime.CompilerServices;
using osu.Framework.Graphics;
namespace ProjectHarmony.Game.Extensions;
public static class DrawableExtensions
{
private static readonly ConditionalWeakTable<Drawable, DrawableExtensionProperties> Properties = [];
extension(Drawable el)
{
public string ClassName
{
get => Properties.GetOrCreateValue(el).ClassName;
set => Properties.GetOrCreateValue(el).ClassName = value;
}
public string[] Classes
{
get => el.ClassName.Split(' ');
set => el.ClassName = string.Join(' ', value);
}
}
public class DrawableExtensionProperties
{
public string ClassName { get; set; } = string.Empty;
public string[] Classes
{
get => ClassName.Split(' ');
set => ClassName = string.Join(' ', value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment