Forums › 💬 FlowCanvas › ⚙️ Support › two-way binding properties node. › Reply To: two-way binding properties node.
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
|
1 2 3 4 5 6 7 8 |
public class MyNode: FlowControlNode { public ObservableValueInput<GameObject> subject; ... virtual public void OnSceneGUI () { } ... } |
To do this when the node is selected I add to the reference subject gameobject a support class “ActionsceneGUI”
|
1 2 3 4 5 6 7 8 9 |
protected override void OnNodePicked () { if(subject.value!=null){ ActionSceneGUI actionGUI = subject.value.GetComponent<ActionSceneGUI> (); if (actionGUI == null) subject.value.AddComponent<ActionSceneGUI> (); } } |
So to ActionSceneGUI I associate a class ActionGUIEditor that extends Editor and invokes the OnsceneGUI method based on the selected node
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[CustomEditor (typeof (ActionSceneGUI))] public class ActionSceneGUIEditor : Editor { void OnSceneGUI () { var t = target as ActionSceneGUI; if (NodeCanvas.Editor.GraphEditorUtility.activeNode != null) { if (NodeCanvas.Editor.GraphEditorUtility.activeNode is MyNode) { var node = NodeCanvas.Editor.GraphEditorUtility.activeNode as MyNode; if (t.gameObject == node.subject.value) { node.OnSceneGUI (); } } } } } |
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
