Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

PField: FREE Unity Generic UI Editor for SerializeReference Fields.

Discussion in 'Assets and Asset Store' started by EnesShahn, Mar 16, 2023.

  1. EnesShahn

    EnesShahn

    Joined:
    Oct 27, 2015
    Posts:
    2
    Project is located on GitHub, link:
    https://github.com/EnesShahn/PField

    A while ago I've started taking different approach writing game systems.
    I wanted a character data collection that is stored as Scriptable Object, it contains data regarding each character in a list, pretty simple.
    the problem was that characters in my game could be of any form, So I had the idea to have some sort of polymorphic list of character data that's can be edited through the inspector.
    Using [SerializeReference] attribute would solve the problem regarding the serialization of polymorphic data, but there were no official support of a UI that would allow the developers/designers to select the type of the element (Character Data).

    Great minds from the Unity community already made tools to do just that. Unfortunately, they all lacked a common feature: making sure that new/duplicate elements automatically had their reference point to an actual new instance not other element in the list. e.g. I add a new element to the list and the new element referenced the element that preceded it. so changing values on element at index 1 would change the values of element at index 0.

    Another important feature for me was the ability to have nested lists for different collection of polymorphic data.

    So long story short, I've made this tool to support these features.

    UI showcase? :

    Field editor
    PField.gif

    List Editor:
    PList.gif

    List Editor (Nested):
    PListNested.gif


    Instead of using List<BaseClass> use PList<BaseClass>
    Code (CSharp):
    1. using EnesShahn.PField;
    2. public class Example
    3. {
    4.     public PList<BaseClass> list;
    5. }
    Code (CSharp):
    1. using EnesShahn.PField;
    2. public class Example
    3. {
    4.     [SerializeReference, PField] public BaseClass var;
    5. }

    Looking forward to your feedback!

    Cheers.