Having unique names

I was wondering if we really have to use unique names for the scriptable object if have a resource folder.

For example:
if i have a folder Attack/Ressources with an unarmed scriptable object and in an other folder named defence with the same name, does unity not look into these specific folders ?
Because i do need to write the path into the declaration no?

I hope my question made sense :smiley:

thank you

As far as I’m aware, it is just a folder structure so files within the same folder need to be unique, but they don’t have to be across folders. However Unity adds all folders that are named Resources together, meaning
Attack/Resources and Defense/Resources is the same folder because anything before the Resources is ignored.
Resources/Attack and Resources/Defense on the other hand will be fine because that is an Attack folder and a Defense folder within the Resources
Makes sense?

1 Like

The Resources.Load(string) method will likely fail in either case. If you had a ScriptableObject name “Bob”, and an animation named “Bob”, and a prefab named “Bob”, all within separate resource folders, the Resources system will grab the first “Bob” it finds.

In the Inventory course, we’re going to be flipping this logic on it’s head. We’ll be using a method called Resources.LoadAll, which gathers all resources containing the type specified and match the path specified (in our case, simply “”). We’re going to give each inventory item a unique ItemID (much like we do the characters in our scene for the saving system. Then we’ll get the InventoryItem by finding the one with the same ItemID.

Privacy & Terms