Display Recursive types in editor

I have a tree-structured type that is of course recursive, and I made a reader for it(my own purposes)
But I want the reader to have a custom editor I can use. I managed to make a display for the tree but since it is recursive I can make those branches inside each other over and over again.

My question is: How do I display in the editor(inspector) a recursive type without infinitely writing the code over and over again?

My types(to help answer the question)
Branch - containing a list of splits and a value
Split - containing a parent branch and a list of sub-branches
The editor is on a reader which receives a Brach reads all the values and splits and their branches and etc…

It doesn’t sound recursive… I think the word you mean is hierarchal?

There’s two problems:

  1. the layout of the data in 2D space so it does not overlap, and also does not get massively huge with whitespace

  2. the actual traversal of your graph at draw time in order to render all the nodes and connections

Be sure to address those two things separately or it will get very complicated.

For problem 1, initially just hardwire positions based on depth in graph and lateral spacing, or just hand-assign positions with numbers. You can get clever later.

For problem 2, have helpers that draw each type of node and each type of connection.

Finally just traverse your graph calling the appropriate helpers to present the data.

It is a recursion between 2 types
a Branch has a list of Splits that each has a list of Branches that each has a list of Splits etc

It’s a directed graph that starts somewhere and draws the all the links and nodes and eventually gets done, right?

I still think what I wrote above is useful, and I hope you do too.

This is how it looks so far…

In the Choices one (which represent the split) I want a list of routes(which represent the branch) to be made, in this picture, you can see how ONE route looks like (the button called Add Main Route can add another route to the initial list of routes but I want to make it so you can add another list into the choices and so on recursively)

Ohhh… I didn’t mean to display them this way…
sorry if I wasn’t clear enough… I just wanted to make a generator in the inspector

So it’s a custom editor that can display and allow you to edit a directed graph of these things, where each thing can be 1 of 3 possible nodes. Take a look at some tutorials for custom editors; your code would traverse your data tree and make decisions about how to render (and allow editing of) each part of the graph.