Well what do you think is more memory efficient: Every material having a reference to that one single texture, or every material having its own unique copy of that texture? The first is the allegory for referencing a ScriptableObject and the latter would be the Prefab.
So the savings are in things like default types and common components, and thatâs about it?
If so, donât Prefab Variants provide this same benefit, with the addition of adding additional GameObjects and Components, too?
I honestly donât know why you keep bringing other things into it. The savings are in the memory allocated per instance of each active object.
If you have 1,000 Monsters with 1,000 integers: you create 1,000,000 integers or 4 million bytes.
If you have 1 ScriptableObject with 1,000 integers and have 1,000 Monsters that reference that 1 ScriptableObject: you create 1,000 integers and 1,000 references which is 8,000 bytes.
Exactly, default types. Which are small, generally speaking.
I get that. But those savings are going to be trivial, in most instances (excuse the pun) because most normal game prefabs are going to have very few values, and need local storage for most of them, that can also serve as default storage and setters during editing, and reference a game manager for any defaults needed after theyâve changed during gameplay.
Nothing new brought into it. Prefabs Variants are part of the prefab workflow. And they have, as I mention, additional benefits, which are (quite frankly) immense.
If Prefab Variants each use their own storage memory for whatâs common to them in their parent prefab, as opposed to only Overrides and Additional GO and Components using unique storage, then I can see one example of a possible benefit (involving much more work and loss of creative freedoms) to Scriptable Objects, in terms of storage space but this wonât reduce RAM needed for instances.
If you understand, and have understood from the beginning, whatâs really the point of this thread? If you donât want to use them, donât. No oneâs forcing you to use one architectural strategy over another. The strategy of sharing common data has a demonstratable effect on memory consumption, and those savings could be significant or even essential depending on the hardware youâre targeting or the scope of a project.
Prefab variants have no bearing on the discussion because theyâre only relevant to the editor and are regular GameObjects with buckets of data at runtime.
I donât understand your hostility. These are sincere questions.
When many make claims about memory usage being less, I presumed (perhaps wrongly) that this must be significant and obvious memory savings. It seems, from whatâs been put forth so far, thatâs not the case.
If you canât see the workflow similarities between a Prefab Variantâs relationship with the Prefab it derives from and a Prefabâs potential relationship with, and reliance upon, a ScriptableObject, as per this question of memory savings, perhaps you havenât used Prefab Variants.
Itâs smaller regardless of if your use of them is trivial.
It isnât to say that prefabs should be avoided.
Itâs to say use the tool that best fits what you are needing to do.
A ScriptableObject can serve many purposes. One of them is to share immutable data across multiple instances to reduce the memory footprint of that data.
Give you an example where the savings is very high.
Say you have some prefabs that need to know what inventory items exist (maybe itâs mobs for a region that on death drop an item by some odds). You could just have an array on the âItemDropâ script that you fill with the items. Meaning every mob has a copy of this array. And if this array is large⌠and you have a large number of mobs. This can end up taking up a lot of memory (similar to the texture example from before).
But if it was in a scriptableobject that each mob referenced. Then itâs just one single array that is referenced by every mob.
Reduced memory.
You can believe that trivial⌠but itâs still reduced.
And if you multiply this by the multiple times you do this, this can be significant⌠depending what you define as significant. In the end graphical data is going to be far more memory intensive than this sort of data just because of the nature of things. So at the end of the day it may only end up being a 1% savings if your game is graphically bloated. But for some people that 1% may actually be significant if it is what stands between them and release.
Now it comes with implications though⌠it means every mob has the same exact pool of inventory items that it can drop. If you want distinct item drops per mob youâd have to create the distinct pools of items for each category of drop. Thus reducing the benefits of the memory. BUT that only applies if your game is a game where each mob has a distinctly unique set of items that it drops from.
On the flip side. Say your game is a completely different design where a region has a static number of items that can be dropped regardless of which mob it is. As a mob drops some item, it is no longer available to be dropped by another mob. This is something the shared scriptableobject could benefit since it COULD be used to store that mutable value (what items were consumed).
It all comes down to what YOU need for YOUR game and understanding the implications of the design choices you made.
Cause mind you < memory isnât necessary important if it doesnât help you make the game you want to make. BUT if it is critical to your game that you reduce some memory footprint because the benefits of distinct lists per prefab is not beneficial to the game, but the lower memory overhead is because say youâre targeting mobile or something⌠then it is.
Itâs up to your needs.
(and mind you this is only one feature of scriptableobjects. And technically speaking a prefab could be used in a similar manner. Where your prefab for you mob references a shared prefab of the inventory items. Back in olden times when SOs didnât exist. We just used prefabs like this. But it came with weird caveats and annoyances arising from the ambiguity of prefabs from actual instances of those prefabs).
In the end though if this is not adequate to your concept of significance.
Well⌠we didnât claim that SOâs saved all that much memory. Weâre just demonstrating HOW it can save memory.
The unnamed âpresentationsâ and âtalksâ are who you may want to take your semantical gripes about the significance of memory savings. Maybe they exaggerated it, maybe you misinterpreted it, thereâs no way for us to actually know since itâs an unnamed source you didnât offer up.
Itâs to the point where itâs EVERYONE that mentions ScriptableObjects, as though itâs a mantra that must be ushered when talking about ScriptableObjects.
All Hail The Memory Savings of ScriptableObjects.
To the rest of your writings.
Thank you!
Will digest and attempt to wrap head around.
More stupid questions will likely follow. Pre-emptive apologies.
THANK YOU!
I had wrongly envisaged that the savings must be more significant, and that I simply didnât see or understand where or how that significant saving was occurring, considering the desire to mention this aspect of using ScriptableObjects by everyone promoting their usage.
Youâre right, thereâs many other reasons to use them, only some of which I grok. I am at an inflection point, trying to figure out how much I should balance use of SOâs against Prefabs, for a final push to publishable quality of code and gameplay, in a quite modular game. One last refactoringâŚ
You are the one who asked for what benefits ScriptableObjects bring, what replies were you expecting if not attempts at that? In my case, I donât even use ScriptableObjects much now, if at all, but draw on what Iâve read and experienced to answer.
If you really want a visual comparison, create a monobehavior with some random variables, put it in a GameObject, and make it a prefab.
Create an instance of a ScriptableObject with the same variables as you have put in the monobehavior, and create an instance.
Go to your window explorer, and compare the filesize of the prefab and ScriptableObject instance.
Considering Iâve been using Unity for a decade or so now.
I have never heard anyone significantly praise SOs for their memory savings features. I may have heard it passingly mentioned that it could potentially be used for such.
But that is not the primary praise I see foisted upon SOs. The primary praise is the modularity of design it allows you to exercise on an asset level. Basically⌠as data containers (similar to how other assets like materials, animations, or pretty much all of this stuff:
Before SOs, these were hard coded things from Unity.
Now I can create similar things like so:
Hereâs one I especially like. Being able to modularize my build/input settings:
That modularity in my opinion is the benefit of ScriptableObjects, and is the primary feature that I hear rung most often around the community since their release.
âŚ
What I also do know is that the community has a butt ton of confusion around it as well.
And this confusion may even come in the form of talks/presentations that may either go over the heads of viewers. Or be put on by people who donât know what theyâre talking about. I can not speak to these specifically⌠for the same reason I canât speak to the talks/presentations you mentioned already because you did not offer up any direct examples.
Why I and others have remained hyper focused on space savings is because of OPâs opening:
and inability to stray from it:
Even after being told that there is more to ScriptableObjects than that one thing:
And the point of my post that youâre quoting is to sayâŚ
what talks/presentations?
This topic of memory savings is a topic I rarely see. This thread being probably the only time Iâve actively engaged with the topic (noting not from a lack of engagement with Unity⌠noting my heavily engaged history with Unity).
I understand you and april may be âhyper focusedâ on this topic because of aprilâs OP. But thatâs circular in nature. Of course this thread is about that topic, itâs what the thread was started for.
I am claiming I donât believe the original statement nor this one:
(the statement I had quoted/responded to with that specific post youâre quoted)
Who is this âEVERYONEâ?
I donât see them.
The only people I see is OP. And theyâre only saying they donât believe the claims they heard these hypothetical others say.
OKâŚ
Stop listening to these unknown actors then.
âŚ
Basically. Why stay laser focused on a topic that OP clearly isnât satisfied with the answer of. When their entire foundation for the topic is based on hearsay.
Try to understand that the materials you look at, as a seemingly god-like master of Scriptable Objects, and that which I come across as someone barely using them and wanting to learn more about them, are two entirely different groups of reading material.
I donât understand the use case youâve presented that youâre all chuffed about, at all. Thatâs how far apart we are.
So it would be bloody nice if youâd just take my word for it when I say Iâm seeing almost ubiquitous claims of memory reduction in all I read and watch about why to use ScriptableObjects.
These things seem so simple and powerful that it boggles the mind how nobody has managed to trouble themselves to teach them in a manner suitable for those considering architecture of their games without examples. But thatâs like a lot of programming, those with the knowledge forget what itâs like to not have the knowledge, insights and wisdom and instead distrust the stated experiences of others, and simply present their own experiences as though thatâs normal and to be expected of everyone.
Itâs one thing to distrust the claims of a person (water is wet) itâs entirely another to doubt the experiences of others (many have told me that water is wet).
And I get that you want mono/solo examples of something so you can repurpose their words and make it somehow my fault for misinterpreting what theyâre saying âwell⌠heâs saying this, and you should therefore think thisâŚâ but hereâs the thing⌠every source Iâve read, every presentation Iâve seen attempting to justify using ScriptableObjects as the new god of Unity architectural considerations, they all say, at some point⌠memory reduction.
After a while, it got distracting, even though this wasnât a factor in my considerations of whether or not to use ScriptableObjects (or how or why or when to use them, which are still things uncertain), AND I couldnât see how it could be such a significant factor that EVERYONE I was seeing mentioned it as though it was a significant bullet point in the reasons to use it.
Hence the original question.
This isnât a âgod-likeâ thing.
This is a, you didnât supply what youâre referencing.
Think of it like this. When someone comes onto the forums and is having trouble with a tutorial and they say âI was following this tutorial and they said do X,Y,Z, but I donât get why.â
Our most often response is âWhat tutorial???â
Because yes⌠you may come across material I donât. But thatâs my point⌠We donât know what material youâre talking about. We donât know the quality. We donât know what theyâre saying in it. We donât know if you misinterpreted/misrepresented what they said.
To say⌠âI heard a thingâ, with out saying who, is called⌠hearsay.
I didnât say âI heard a thingâ, I said âI heard a thing A LOTâ.
Thereâs a difference.
EDIT: ADD EVIDENCE FOR WHATEVER REASON::
NB: This is not how I searched for info about Scriptable Objects, itâs to prove to you that there might actually be a lot of talk about the memory reduction when using scriptable objects.
Of all the things to argue about, the experience of having read and heard this claim, many, many times, is probably the most asinine. Why bother with that? Why not just stick to "Hereâs how much memory they can save⌠itâs not a lot⌠it is a lot⌠details⌠"?
AlsoâŚ
Memory savings being a bullet point is different from:
Bullet points of reasons does not mean that each reason has equal praise. And it most certainly doesnât mean âall hailâ. Which is why I feel you may be misrepresenting the unsourced talks/presentations.
But who knows⌠maybe there are a couple people who blow the âmemory savingsâ thing out of proportion.
I just doubt it.
It sounds like one of those things where people are saying:
âScriptable Objects have many benefits including: a, b, c, d, e, f, g, hâ
And one of them happens to be memory. Which it CAN assist in saving. Itâs just not as significant as you assumed for whatever reason you assumed it since I donât know what you saw/read/heard.
âŚ
Itâs still âI heardâŚâ
I hear a lot of people say vaccines cause autism. Doesnât mean itâs true!
In this metaphor, I came to a Doctorâs convention to ask if these lots of people had a point, and to what extent.
Why oh why are we going down this path?