- changed status to open
Can not change value type once SerializedScriptableObject is assigned.
Issue #247
resolved
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;
}
Comments (3)
-
-
- changed status to resolved
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.
-
We could allow the NullableReferenceDrawer to draw itself around UnityEngine.object types as well. This would the polymorphic object picker box appear around that ScritpableUnityDecProperty HealthValue as well.
- Log in to comment
You should simply be able to right-click, and press "change type".