Can not change value type once SerializedScriptableObject is assigned.

Issue #247 resolved
wavebit
created an issue

hello, please check the code comment.

public interface IReadOnlyProperty<T>
{
    T Value { get; }
}

public interface IProperty<T> : IReadOnlyProperty<T>
{
    new T Value { get; set; }
}
[Serializable]
public class Property<T> : IProperty<T>
{
    [SerializeField]
    private T _value;

    public T Value
    {
        get { return _value; }
        set { _value = value; }
    }
}
[CreateAssetMenu]
public class ScriptableUnitDecProperty : SerializedScriptableObject, IReadOnlyProperty<int>
{
    [SerializeField] private int _value;

    public int Value { get { return _value; } set { _value = value; } }
}
[CreateAssetMenu]
public class UnitDec : SerializedScriptableObject
{
// If we choose the ScriptableUnitDecProperty from the dropdown list, then we can not select other type even the ScriptableUnitDecProperty itself.
    [SerializeField] public IReadOnlyProperty<int> HealthValue;
    [SerializeField] public IReadOnlyProperty<int> MaxHealthValue;
}

cap1.PNG cap2.PNG

Comments (3)

  1. Tor Esa Vestergaard

    I've confirmed that this is possible - the confusion is due to an interaction between how Unity objects are drawn by default. You merely need to remove the object reference (click and press delete, or right-click and press "Set To Null"), and then you can select a new type as per usual.

  2. Log in to comment