problem about custom node inherited from flowNode class

FlowCanvas Forums Support problem about custom node inherited from flowNode class

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1312
    nicoyiqi
    Participant

    hi,Gavalakis, I hava a question:add a new custom node inherited from flownode class by drag a port connection, I can’t find the node in context menu. how to solve this problem?

    Attachments:
    You must be logged in to view attached files.
    #1315
    nicoyiqi
    Participant

    here is the custom node code
    [Name(“rotate”)]
    [Category(“UnityEngine/Transform”)]
    [Description(“旋转”)]
    public class G_Rotate : FlowNode
    {
    [SerializeField]
    private int index = 0;
    public int Index
    {
    get { return index; }
    set
    {
    if (index != value)
    {
    index = value;
    if (index == 0)
    {
    name = “rotate(Self)”;
    }
    else
    {
    name = “rotate(World)”;
    }
    GatherPorts();
    }
    }
    }
    [SerializeField]
    private int mode = 0;
    public int Mode
    {
    get { return mode; }
    set
    {
    if (mode != value)
    {
    mode = value;
    GatherPorts();
    }
    }
    }

    protected override void RegisterPorts()
    {
    var transform = AddValueInput<Transform>(“Transform”);
    var outPut = AddFlowOutput(“Out”);

    switch (mode)
    {
    case 0:
    {
    var axis = AddValueInput<Vector3>(“Axis”);
    var angle = AddValueInput<float>(“Angle”);

    AddFlowInput(“In”, (f) =>
    {
    transform.value.Rotate(axis.value, angle.value, index == 0 ? Space.Self : Space.World);
    outPut.Call(f);
    });

    break;
    }
    case 1:
    {
    var vector3 = AddValueInput<Vector3>(“Vector3”);
    AddFlowInput(“In”, (f) =>
    {
    transform.value.Rotate(vector3.value, index == 0 ? Space.Self : Space.World);
    outPut.Call(f);
    });

    break;
    }
    case 2:
    {
    var floatX = AddValueInput<float>(“X”);
    var floatY = AddValueInput<float>(“Y”);
    var floatZ = AddValueInput<float>(“Z”);
    AddFlowInput(“In”, (f) =>
    {
    transform.value.Rotate(floatX.value, floatY.value, floatZ.value,
    index == 0 ? Space.Self : Space.World);
    outPut.Call(f);
    });

    break;
    }
    }
    }
    #if UNITY_EDITOR
    protected override void OnNodeInspectorGUI()
    {
    base.OnNodeInspectorGUI();
    Index = UnityEditor.EditorGUILayout.Popup(“Space Type:”, Index, new string[2] { “Self”, “World” });
    Mode = UnityEditor.EditorGUILayout.Popup(“Rotate Mode:”,Mode, new string[3] { “Rotate Along Axis”, “Rotate by Vector3”, “Rotate by 3 Float”});
    }
    #endif
    }

    #1316
    Gavalakis
    Keymaster

    Hello,

    For nodes deriving FlowNode directly (instead of SimplexNodes), you have to add an attribute to let FC know for what types of ports dragged this way, the node will show up in the menu. For this node for example, you could have something like this:

    Let me know if that works for you.
    I also notice that there is an error in your console that seems to relate to FC. Can you please post this error for me here?
    Thanks.

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

    #1320
    nicoyiqi
    Participant

    thanks,Gavalakis. it’s realy helpful.
    the error caused by modify some code in flowNode plugin script, there’s no problem now.

    I also find a small bug about node name display: such as custom event node or code event node which eventdata type is <Color>, will display like this picture. i think the color type string may be conflict with node name rich text type.

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

    Hello,
    Thanks for the follow up of the problem being fixed as well as for the bug report with the color.
    I need to take a look at this and fix it 🙂 It’s indeed relevant to rich text and the title of the node being colored.

    Thanks!

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

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