[Best practice questions] Prefab with scriptable object that has the said prefab in it

Hi,

I have a list of scriptable object of “Item”, which I named as ItemScriptableObject. These scriptable object each has public GameObject prefabObject; in it as a variable, and as the name suggests I drag and drop the related prefabs to the scriptable object.

The prefab has a monobehaviour component Item.cs with public ItemScriptableObject data; as a variable. So, when I edit some value in the ItemScriptableObject, that value is immediately reflected on the prefab’s data such as damage, distance, knockback (bool), etc, which are other variables included in ItemScriptableObject.

But from what I’m seeing in the inspector, it’s somewhat circular–or infinite–loop of referencing. Scriptable object references prefab asset which references scriptable object which references prefab asset which references scriptable object… and so on.

So, I worry if what I’m doing is the best practice of using prefab / scriptable object. Is my way of setting up scriptable object / prefab okay, or would this practice cause some sort of trouble in the long run? If latter’s the case, how should I do it?

Absolutely fine. Object A which references Object B which references Object A etc is not an issue. You’ll find similar patterns in many language e.g. Parent/Child references to each other.

I’d rename what you’re calling them though, I always try to refrain from calling any variable “Data”, try ItemStats, make it as descriptive as possible.