#thats how it currently looks

1 messages · Page 1 of 1 (latest)

midnight hornet
#

Hmmm when you call BindItem can you bind the property to (new SerializedObject(ConsiderationAxis).FindProperty(nameof(responseCurve)?

#

But I could be wrong on the depth. It's kinda hard to tell with out looking at any code

still frost
#

ill try to show some code

midnight hornet
#

oh because it's not a scriptable object...

still frost
#
{
    public Port port;
    public CurveField animCurve = new CurveField();

    public AxisInputElement(ConsiderationNode node,ConsiderationScrObj scriptableObjectData)
    {
        port = node.InstantiatePort(Orientation.Horizontal, Direction.Input, Port.Capacity.Single, typeof(ConsiderationPortType));
        Add(port);
        
        Add(animCurve);
    }
}```  that is the element i create in MakeItem
#

and then id just like to somehow bind it : Action<VisualElement, int> bindItem = (e, i) => { var element = (e as AxisInputVisualElement2); element.animCurve.value = scriptableObjectData.axis[i].responseCurve.responseCurveGraph; };

#

but that binding doesnt work

midnight hornet
#

That doesn't work at all? or it doesn't update when you update the scriptable object?

still frost
#

When i change the ScrObj data it is not updated. only if i call Refresh on the ListView it is

#

as i understand it it is because i create everything from scratch again then

midnight hornet
#

ok so the bindItem is working, its just not propagating the scriptable obj change

still frost
#

but it is bound though? or do i just once assign the value from the scr obj?

midnight hornet
#

Yea I guess thats true, I'm new to UI terminology.

still frost
#

i have not defined a bindingpath anywhere

still frost
midnight hornet
#

Have you tried deriving ConsiderationAxis from scriptable object? that way you can use it as a SerializedObject?

still frost
#

i mean it kinda is serialized on a scriptable object but inside a list right?
i cant make a scriptable object out of it though.

midnight hornet
#

Yea it is serialized inside the list

#

You can only bind to serialized properties. This means you can only bind visual elements to the following objects that are compatible with the Serialization system:

User-defined ScriptableObject classes
User-defined MonoBehaviour classes
Native Unity component types
Native Unity asset types
Primitive C# types such as int, bool, float, and so on.
Native Unity types such as Vector3, Color, Object, and so on.

still frost
#

but animationcurve is in there afaik

midnight hornet
#

Since you are trying to bind to a Unity component inside of a user Defined class

#

If you had say an array of animationcurve's then I think you could bind to it just fine

still frost
#

i found this but i dont really understand whats happening

midnight hornet
#

I would try to see if you can get basic binding done. Just a quick test from an animationcurve inside of a SO

#

I found the same link but don't understand it either lol

still frost
midnight hornet
#

But after you confim that you can bind to an animationcurve I would post to the forums and ask your question with more detail and code.

#

You might get lucky and have someone from Unity help you out

still frost
#

okay thanks alot! ill try that

midnight hornet
#

Yea no problem. Thanks for your help. and Hopfully you can figure your issue out!

still frost
#

just quick followup: yes animationcuve and curvefield binding works like a charm

midnight hornet
#

Awesome, now you know at least that its possible

still frost
#

and this is how i bound to nested objects: priorityField.bindingPath = "outputProcessor.responseCurve.responseCurveGraph";

#

now ill just need to figure out how to do it with list elements