Common Types
Sometimes logically different properties have the same type,
for example, both Selectable.colors.colorMultiplier
and TMP_Text.fontSize
are float
.
And having them in the same options group is undesirable.
In such cases, you should wrap that type to the different structs for each property. Also, you will need to create wrappers and them to the registry since they cannot be automatically created.
Value Wrapper
using System;
using UIThemes;
using UnityEngine;
[Serializable]
public struct FontSizeValue : IEquatable<FontSizeValue>
{
[SerializeField]
public float Value;
public FontSizeValue(float value) => Value = value;
public static implicit operator float(FontSizeValue value) => value.Value;
public static implicit operator FontSizeValue(float value) => new FontSizeValue(value);
// other code...
}
Property Wrapper
using UIThemes;
public class TMProTextFontSize : Wrapper<FontSizeValue, TMPro.TMP_Text>
{
public TMProTextFontSize() => Name = nameof(TMPro.TMP_Text.fontSize);
protected override FontSizeValue Get(TMPro.TMP_Text widget) => widget.fontSize;
protected override void Set(TMPro.TMP_Text widget, FontSizeValue value) => widget.fontSize = value;
}