two-way binding properties node.

FlowCanvas Forums Support two-way binding properties node.

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2121
    toto007
    Participant

    Hi guys,

    I have created a custom node ‘TweenPosition’ with different properties (look image attachment). When the node is selected then I want change for example the value of property Y via script.

    This is my attempt:

    I don’t know if this is the right way to do that because in this way I’m changing the default value and not the current value.

    Anyway, I want to edit this value both ways (two-way binding).

    I need to do that because I want to show current gameobject status on which the selected node is working in editor mode.

    Any suggestions?
    Thank you
    Giuseppe

    Attachments:
    You must be logged in to view attached files.
    #2131
    Gavalakis
    Keymaster

    Hello there,

    Using the [ContextMenu] attribute is totaly valid within nodes like you do, but to change the “current value” please dont use the “SetDefaultAndSerializedValue”. Simply set the “.serializedValue” property. Setting this property will actually only set the serialized value that you see in the inspector and leave the defaultValue unchanged.
    “SetDefaultAndSerializedValue” is just a shortcut to setting both “.defaultValue” and “.serializedValue” properties :).

    Please let me know if that works for you.
    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

    #2133
    toto007
    Participant

    Thanks, It’s works!

    I want that user can editing some variables of node through the tools of support.
    So, I have created a node custom “TweenPosition” for create an animation of an object in a determinate position (To). You can look my example here:

    If you can look at my code I would like to know if it is the correct way to achieve this goal.Basically what I do that when the node is selected I then transfer the reference of the “to” field of the node to an internal my class that serves to manage the waypoint on the scene.

    This class is my custom flownode
    Tweenposition.cs

    This class is useful to create the placeholder waypoint on the object on which the node works
    TweenPositionEditor.cs

    This class does the through to share the variable position of the node “Tweenposition.cs” with the class “TweenPositionEditor.cs “that manage the waypoint drawn the handles on the Scenaview
    TweenPositionMonoB.cs

    If I may I would ask you another advice. I would like to know when the Serializevalue changes value. I thought I’d extend the class Valueinput<T> and overwrite the serializedvalue set method to launch an event when its value changes from the previous.

    #2136
    toto007
    Participant

    Regarding the advice I asked you about how I could listen to the change in the value of an ValueInput, I extended the ValueInput class this way:

    I also had to extend the FlowControlNode class by adding the AddObservableValueInput method. The problem that to do this I had to modify the class changing the access level of the QualifyPortNameAndID method and the inputPorts variable from private to protected. How can I achieve the same result without modifying your framework? I do not want to have to report my changes to your framework every time when there is a new update

    #2144
    Gavalakis
    Keymaster

    Hello and sorry for the late reply.
    Hmm, regarding the ObservableInput, probably the best way right now, would be to make the FlowNode class a “partial” class and as such, you will be able to provide extra registration methods (or other functionality as well) without changing the source code itself. If making FlowNode a partial class works for your use case, I will gladly make it partial officially for the next version.

    Furthermore and based on your use case, I am thinking that maybe an OnSceneGUI callback could be added for nodes, so that editor specific utilities like Handles.PositionHandle can be used much easier.

    Let me know what you think on the above.
    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

    #2149
    toto007
    Participant

    Thank you for you advices.
    I do your flownode class a partial class and it’s works and more easy extended flownode. So I will gladly when you make it partial officially for the next version 🙂

    Furthermore for my use case I have followed your advice for extend my nodo with a custom method OnSceneGUI

    To do this when the node is selected I add to the reference subject gameobject a support class “ActionsceneGUI”

    So to ActionSceneGUI I associate a class ActionGUIEditor that extends Editor and invokes the OnsceneGUI method based on the selected node

    This avoids me writing a lot of code around. Thanks for you advice 🙂 . I was wondering if you have any more optimal solutions or if it may be enough so

    #2155
    Gavalakis
    Keymaster

    Hello again,

    Thanks for the follow up. I am glad that it works for you. I will make FlowNode partial in the next version, no problem 🙂
    Regarding OnSceneGUI, I am thinking of adding a virtual “OnSceneGUISelected” in the base “Node” class, so that it’s easy for people to simply override and work with SceneGUI without a lot of fuss 🙂 It will basically do prety much what you are already doing, but more tight with the rest of the framework. Until the next version (v3.0) is out though, I think your solution is fine as it is 🙂

    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.