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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions