alelievr / NodeGraphProcessor

Node graph editor framework focused on data processing using Unity UIElements and C# 4.6
https://github.com/alelievr/NodeGraphProcessor/projects/2
MIT License
2.3k stars 384 forks source link

Question: How about support odin serialize? #87

Closed JusamLiu closed 3 years ago

JusamLiu commented 4 years ago

Do we have a plan about support odin serialize,beacause it's attribute is very convenient and simple? eg: drawing List or custom type.

alelievr commented 4 years ago

The requirement for supporting odin serialize attributes and unity built-in field attributes are the same: I need to use SerializeField to display the fields in UIElement.

The problem is that currently I can't use it because the fields are not serialized, it will be the case when the big serialization refactor lands, but I don't really know when it will be ready (I still wait for a fix on Unity side).

So to answer your question, it's planned but waiting for the serialization task to be completed :)

wqaetly commented 3 years ago

OK, I have almost completed this task, this is my Fork version from the author library, combined with Odin serialization:https://github.com/wqaetly/NodeGraphProcessor This is a related blog I wrote to introduce it:https://www.lfzxb.top/nodegraphprocesssor-and-odin/ Below are some screenshots QQ截图20210404172603 QQ截图20210404172629 QQ截图20210404172705 QQ截图20210404172717 QQ截图20210404172725 QQ截图20210404172956

LudiKha commented 3 years ago

The requirement for supporting odin serialize attributes and unity built-in field attributes are the same: I need to use SerializeField to display the fields in UIElement.

The problem is that currently I can't use it because the fields are not serialized, it will be the case when the big serialization refactor lands, but I don't really know when it will be ready (I still wait for a fix on Unity side).

So to answer your question, it's planned but waiting for the serialization task to be completed :)

Hi @alelievr , any update on this? :)

alelievr commented 3 years ago

The serialization refactor has landed but there is still an issue with the ApplySerializedProperty() function that re-creates all the node data which causes all the nodes to lose their references. So I'm waiting for this issue to be fixed to finish implementing the feature.

leissler commented 3 years ago

So the serialization refactor is in the master branch, but it's not stable for use in products yet?

alelievr commented 3 years ago

Okay, I managed to finish the implementation of SerializedProperties in the node views so now all the builtin Unity property drawers as well as the CustomPropertyDrawers in Odin inspector.

I think it's fairly stable now, so all this work will be available in the next release: the 1.3.0

Here's an example with UnityEvent builtin drawer:

image

And the node code:

using UnityEngine;
using GraphProcessor;
using UnityEngine.Events;

[System.Serializable, NodeMenuItem("Custom/Unity Event Node")]
public class UnityEventNode : BaseNode
{
    [Input(name = "In")]
        public float                input;

    [Output(name = "Out")]
    public float                output;

    public UnityEvent           evt;

    public override string      name => "Unity Event Node";
}
leissler commented 3 years ago

Awesome!!!

LudiKha commented 3 years ago

Fantastic! 🦾

ivankuzev commented 3 years ago

Yeah saves soo much extra work. Btw there is still some visual problem with lists here (nodes with lists get very tall) image

alelievr commented 3 years ago

Hum, it seems to be an issue on GraphView side, I'll see if I can add a workaround somewhere to avoid that issue

alelievr commented 3 years ago

I added this bit of code: https://github.com/alelievr/NodeGraphProcessor/commit/35a0514379d252c019545b41525841eb76626440#diff-88aab6f235f642dfb544df6a26caf202382529e8e056a03c2eaf60934faeb4ceR271

Seems to work pretty well

ivankuzev commented 3 years ago

Border fixed...node not fixed. here is an example with your list node( My mouse is outside the node bellow it, I can select the node from there. Preventing me to select anything else. works only when the list is unfolded. ) image

alelievr commented 3 years ago

Yeah, I can't do much more than that. I've reported the bug in the bug tracker: https://issuetracker.unity3d.com/product/unity/issues/guid/1351693/

Hopefully, it will be fixed soon as it only happens on the 2021.2 betas.