About scriptable object architecture and the implementation of generic unity objects #13
Replies: 3 comments
-
Hi, thanks for such interest in this project. I'm glad it comes in handy for someone. About DLLs: yes, it was primarily done to make so that C# projects don't get cluttered with auto-generated scripts and so that there are no issues when you refactor your generic classes. My first implementation of generic scriptable objects was through plain scripts, and as I worked with them, it quickly became apparent that some refactorings may mess up the code in generated scripts in ways that are sometimes hard to fix. When you just change the name of the generic class, it's usually not a problem, but if you change the name of a generic parameter and some namespaces, and god knows what else, it may lead to compilation errors in the generated scripts that are hard to fix. And there may be hundreds of generated classes. The plugin can't recover from the failed compilation state because no C# code will work if the project does not compile. On the other hand, when you create a DLL, and it contains some failed code, it usually does not throw errors until someone tries to use this code. And even if it has invalid code, the Unity solution compiles successfully even without the failed DLLs, so you can track issues in generated classes and re-generate the DLLs. Long domain reload time when a concrete type is generated: it happens because of two reasons, and both are caused by Unity, so unfortunately I cannot resolve them from my end.
Of those 5 seconds, the actual code generation takes maybe 200-300 ms, no more. Everything else is the excessive domain reloads and recompilations caused by Unity. |
Beta Was this translation helpful? Give feedback.
-
Guess we will just have to live with those initial load times. Question 2: How should you handle nested variables? The classic example for a variable is an implementation of player health with [Serializable]
public class Modifier {}
[Serializable]
public class ModifierRefList : List<Reference<Modifier>> {} Does not have its initial value displayed at all: However, even if it did display properly it would be awkward to work with. The scenario I have laid out has many problems. |
Beta Was this translation helpful? Give feedback.
-
@SolidAlloy Are you ok? You haven't been active on github for a while. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I have been a fan of the idea of scriptable object architecture ever since I first saw Ryan Hipple's talk on the matter.
This project is by far the best implementation of that idea that I have seen.
I've tried integrating several scriptable object architecture projects into my workflow.
However when my projects reach a non-trivial size I always reach roadblocks that I am unsure how to overcome.
I want to ask you about those roadblocks and how you would go about overcoming them.
I would also like to ask some questions about the specifics of this project.
I will ask one queation at a time so that this discussion doesn't become too bloated.
Question 1: Why generate dlls for generic unity objects instead of just generating class files directly?
Is it to make sure people don't modify and potentially break them?
The whole process takes about 5 seconds per type. It is instant every other time you reuse that generic unity object type but still, 5 seconds is 5 seconds.
I have tried to implement a scriptable object architecture project myself and I just generate the file directly under a directory in the assets folder.
The file generates pretty much instantly, I just wait for the domain to reload.
Beta Was this translation helpful? Give feedback.
All reactions