I hope I can put my problems into the right words :).
I’m writing an game where the user can create recipes. If the recipe matches a predefined recipecombo something happens.
Right now I’m writing the editor script for creating the predefined recipecombos. As any recipe can consist of different ingredients and any ingredient can be added multiple times I have created a helper class NeededIngredient which inherits ScriptableObject. It just holds a reference to an ingredient and the min and max value of the ingredient.
When the user adds a new NeededIngredient to the combo in the editor I create a new instance of this helper-class and store it in a list like this:
After a lot of googling I found out that CreateInstance() should only be called during runtime or that I have to save the ScriptableObject to an asset.
But I can’t believe that this is the solution. This is a simple helper class and I don’t want to create any assets or something similar.
Any help in solving this issue is really appreciated.
We do something similar with our Items. But yes, you need to save them as assets. Really, it’s not cumbersome. And it should void the need for a custom editor.
Sometimes Unity is really great and easy, sometimes Unity is really, really **cking me up for things that should be very very simple but are not in Unity :(.
This helperclass will be used a lot. There might be hundret of instances. Do I need to create an asset for every instance used at runtime or do I need to create only one?
If I do need more than one is there any other solutions to solve my problem as it will surely not be managle to have an asset for every instance.
only 4 years since this thread was alive? Better stick an irrelevant subjective answer to it!
ScriptableObjects shine when you need global functionality not constrained by the currently loaded scene or when you’re going for a modular approach.
Imagine your game designer to be able to tweak and test functionality of your game just by drag’n’dropping scriptable objects into appropriate slots instead of coming back to you with “Can you please edit this little bit so that I can see what it does?” 1000 times a day.