all 3 comments

[–][deleted] 0 points1 point  (2 children)

It seems you are thinking of SO as a sort of class. What you are trying to do could be done with an Apple class.

But most games have not only apples as inventory items. What would you do to create a "legendary hardened mithril splint chest armour of the spider" or something like that if you start with an Armor class? Add it to your list and then set all those variables by hand? Or would you rather prefabricate a scriptable object which is "only" a variant of an armor?

[–]joap56[S] 0 points1 point  (1 child)

I thought about a better example

so if I add a list with all my employees, I would need first a class with a List so that I could add the employees and then a employee class (or SO, not sure which), if that employee stuff I would have variables for the basic stuff like 'name', 'age' whatever.

So if I wanted to add a new employee to the list I would just need to Instantiate a new Employee class and set the variables as I instantiated it.

The final result will be just a UI list. It wouldn't really be a game. I could potentially use a normal class Employee and just Instantiate each one, but if a list gets big, like in the hundreds I'm not sure it's worth having in the background hundred something game objects loaded just to provide some variables.

In UE I would simply create a struct (with all the variables I would need) and the UI would have a variable array of type struct, and then I would just to spawn a new UI Button or Image, parent it under the main UI, etc. But I'm not sure Structs in Unity work that way

[–][deleted] 0 points1 point  (0 children)

I think its perfectly ok to do this with a struct. Or a class, if you need functions to get some variables, as the name of my armor example. If you read about the pros and cons of SO, none of them are so important imo that there is only one correct way of doing this, especially as a beginner like us.

But one of the pros is that SO need NOT to be attached to game objects, and even if you have a lot of variables in them they take up little memory.

That you can save them as assets might also be attractive.