Painless conversion from MonoBehaviour to ScriptableObject?

I’ve made a few scripts to represent a Weapon and an Ability.
I didn’t know about ScriptableObjects so I created a WeaponContainer and a AbilityContainer MonoBehaviour which I load from Resources folder depending on the weaponId is saved on persistence.

It works quite well, but it doesn’t seems to be the best way to do stuff, also every time I need to reference any of these I need to navigate into the project folders and drag/drop the prefab into the inspector, and this is getting frustrating! :face_with_spiral_eyes: When I discovered ScriptableObjects I wished I could convert the two MonoBehaviours to ScriptableObjects, but I’ve already referenced these MonoBehavious in many scenes of the game so it would mean an intense work of writing down every single reference to restore, and every value of the weapons and of the abilities, otherwise I’ll loose all the data…

Have any of you been in a similar situation? Do you know if there’s any tag that would let me choose the desired prefab in the inspector without doing drag and drop? Or maybe there’s a magic tool that does this work for me :stuck_out_tongue:

Yuck… I feel for you. I’ve been in this exact situation several times, but your desire to switch to SOs is legitimate.

In the end I bit the bullet and used it as an excuse to refactor all the little tiny things that had been bugging me before, and basically rewrote everything using ScriptableObjects.

But I did it system by system, not all-at-once. And in fact in one game I stood up a separate system alongside the Prefab-based system and kept both of them alive. Someday I might tear down the Prefabs and make equivalent SOs, but… maybe not!

ALSO: don’t even consider doing this without proper source control to guard and protect your hard-earned work.

Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

As far as configuring Unity to play nice with git, keep this in mind:

Here’s how I use git in one of my games, Jetpack Kurt:

Using fine-grained source control as you work to refine your engineering:

Share/Sharing source code between projects:

Setting up an appropriate .gitignore file for Unity3D:

Generally setting Unity up (includes above .gitignore concepts):

It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place.

“Use source control or you will be really sad sooner or later.” - StarManta on the Unity3D forum boards

Wow this is great… I use git all the time in my job with Java, but I had no idea it could be used on Unity!

My story teaches it’s important to do research on technologies before starting a project, as well as analysis, not just searching for stuff in the moment you need them :smile:

1 Like

But be careful: I cannot tell you how many times I see people on here asking questions like “Should I use Prefabs or ScriptableObjects?” and getting all worried about it and then having analysis paralysis and never starting anything.

Far more important than how you do it, it is critical that you actually GO DO it, and you have done this!

There are an infinite number of possible engineering solutions you can create, and if you don’t try any ofthem because you’re unsure which to do, you’re no different than that weirdo at the party who says “Oh you make games? I have a GREAT GAME IDEA!” Of course as you know, game ideas have zero value. It’s the created game that has value. :slight_smile: