itsschwer / schwer-scripts

Open-source code for Unity
MIT License
1 stars 0 forks source link

ItemEditor exposes too many properties #5

Closed itsschwer closed 3 years ago

itsschwer commented 3 years ago

The current implementation of drawing Item properties into the ItemEditor can expose more properties than what is normally shown in the Inspector. This can easily be observed by creating a new class that derives from Item with a UnityEvent field:

[CreateAssetMenu(menuName = "Scriptable Object/Item System/Usable Item")]
public class UsableItem : Item {
    [SerializeField] private UnityEvent _OnUse = default;
    public UnityEvent OnUse => _OnUse;
}
itsschwer commented 3 years ago

Fixed by replacing SerializedObject and PropertyFields with Editor.DrawDefaultInspector.