Skip to content

Releases: OctopBP/unity-attributes

1.4.0

19 Mar 20:28
Compare
Choose a tag to compare

Add EnumTypeFor attribute

You can add this attribute to enum

[EnumTypeFor(typeof(AssetReference))]
public enum UnitType
{
    Frog,
    Snake,
}

and it will generate new type for you

[Serializable]
public class UnitTypeForAssetReference
{
    [SerializeField] public AssetReference Frog;
    [SerializeField] public AssetReference Snake;

    public AssetReference Get(UnitType key)
    {
        return key switch
        {
            UnitType.Frog => Frog,
            UnitType.Snake => Snake,
            _ => throw new System.ArgumentOutOfRangeException(nameof(key), key, null),
        };
    }
}

So you can use it like this:

var assetAtType = unitAssets.Get(type);

1.3.1

18 Mar 18:00
Compare
Choose a tag to compare

Fixes

1.3.0.0

18 Mar 17:41
Compare
Choose a tag to compare

Update PublicAccessor to IncrementalGenerator

1.2.1.0

02 Dec 10:48
Compare
Choose a tag to compare
  • GenConstructor
  • PublicAccessor
  • Readonly
  • MonoReadonly
  • Singleton

1.1.2.1

19 Oct 12:07
Compare
Choose a tag to compare
  • GenConstructor
  • PublicAccessor
  • Readonly
  • MonoReadonly