Everything twice
As with many things with Unity, separation of front and backend often means having to write everything in at least two forms
7/17/20251 min read
After a quick fix up of some last errors from the day before I finally set my eyes on the task of updating (fixing) the visual scripting UI for the Mesm editor. As it was important for me to keep the packages for user interface (and all the reflection that comes along with that) separate from the functionality of the system, I had already spent a lot of time creating two almost identical sets of classes. Ports had UIPorts, Nodes had UINodes, and of course Graphs had UIGraphManagers (confusing naming but trust me it makes sense). While this is just a part of doing something like this, it often meant that there were multiple ways to perform actions in the code instead of a clear, correct method. As UIPorts represented two groups where only one could actually manage connections, many times one would have to check if the "new, connecting port" was compatible, before then asking the to do the same and "execute" the connection. There is always a bit of this but in this case the solution was to manage all of this in the backend, without UI elements speaking with each other very much at all. With the new version two UI ports will simply hand over each others data accessors to the backend and let them figure it all out, only reporting whether connection was successful with a simple bool. I also finally fixed multi ports (ports that can connect to multiple others). These did not function at all anymore, as each port now represents a single connection, so needed to be adjusted to the new list based multi-port system. The original 5 different types of UIPorts are now boiled down to only 3, where a UIRefPort being represent both single and multi port fields, with the third being an extra type that can show connections as a foldout list in case this is needed in the future (possibly for the dialog system coming next?).