Skip to content

Property serialization support #122

Description

@musjj

I really like using this pattern in my Unity classes:

[field: SerializeField]
public int Num { get; private set; }

This allows other classes to read the value, but not set it. The field: tag allows Unity to properly serialize the property for the inspector. But the same pattern doesn't work for Alchemy. For example:

using System;
using System.Collections.Generic;
using Alchemy.Serialization;
using UnityEngine;

[AlchemySerialize]
public partial class FooSO : ScriptableObject
{
    [field: AlchemySerializeField, NonSerialized]
    public HashSet<int> Nums { get; private set; }
}

The Nums property will not be visible in the inspector. But if you turn it into a normal field, it works:

[AlchemySerializeField, NonSerialized]
public HashSet<int> Nums;

Can support for properties be added for Alchemy too?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions