Seneral / Node_Editor_Framework

A flexible and modular Node Editor Framework for creating node based displays and editors in Unity
https://nodeeditor.seneral.dev
MIT License
2.01k stars 414 forks source link

Implementation of a Logic Graph #197

Closed Softelectro closed 3 years ago

Softelectro commented 3 years ago

I have been trying to create a logic graph system where I used the Dialog system mainly as reference. My use case will be to export the logic graph into an xml file to get the logic aspect for another application. For that I need to create a node that handles Multiple choice questions (e.g which options do you chose : option A, B ,C. it can be A or B or C or AB or AC or BC or ABC). Do you have any idea in mind on how to implement that node?

Seneral commented 3 years ago

Since the notion of state is not in the base framework, you'll have to elaborate on what exactly you mean. State is only what an external system assigns to the node system. By default, there is only the Calculation system which evaluates the node gaph in an instant to assign a value to each node. So without a clue what you do with your node graph, I can't help.

Softelectro commented 3 years ago

Thanks for the reply. I will try to elaborate more. The system I am creating is mainly used for exporting all the nodes and their connections. So I will not be calculating any value. Each node will have a forward and back connections just like the Dialog system. The forward will direct to the next node and back direct to the previous node. And the information that interests me are the connections so that later I will know if I click Next or Previous I will know which node's information I need to display. Here is an example of a node I'm using for single choice questions: CaptureGit But for multiple choice questions, choosing option 1 will give one resulting node and choosing option 1 + option 2 will give another resulting node. This is where I'm struggling.

No3371 commented 3 years ago

Just change the design, Instead of "1 node port = 1 option", make it like "1 node port = 1 option combination". The options GUI should looks like mask layer dropdown. 圖片

Seneral commented 3 years ago

Sounds like you have two easy options: Allow each output to connect to multiple nodes and then adapt your interpretation algorithm to select the nodes. If only one output A connects to a node, it's the result of choice A. If both A and B connect to it, it's the result of choice A+B, etc. However that limits you in that A and B can not have the same individual nodes, for example A->X, B->X, A+B->Y

Or generate read-only combinatory ports (A+B, B+C, A+B+C) below your options (you can programmatically create and delete them as you edit your real options, you seem to have figured that out already). Such a mask dropdown as @No3371 shows is unfortunately not that easy, unless you're willing to accept a lot of visual glitches. Standard Editor Dropdown controls really do not play well with built-in scaling, they will appear at random positions if you are not a 1x scale (unless they fixed that, doubt that though). But instead of the dropdown you could also use three (or more) toggle buttons to select the combination for each port (though I'm not sure that scales well with the amount of options to combine).

No3371 commented 3 years ago

Ah, now you mention it, menus did have the issue with scaling, It was too long ago I played with the framework so I missed that.

As for drop buttons I guess a edit toggle would be good enough, like it only draws all the toggles when you click on it, instead of drawing all toggles all the time.

Softelectro commented 3 years ago

Thanks for the help guys! For the second solution, I thought about using the multipath node of the dialog system as a reference and made something like this: CaptureGit Options will be in the first node and the multipath node will create the read only fields for all the different combinations. Do you think it's a good idea?

Seneral commented 3 years ago

Since this is solely a choice of which interface fits your use case best, if it feels easy to use, then I guess it's alright. But if you're going for another node you might want to consider a node which takes 3+ inputs and serves to combine only those. So if you want to override A+B->C, you add a node D and create connections from A->D and B->D and D->C. Good luck!