how to fix class name conflicts between 2 unity assets

i imported 2 different unity assets that i bought from the unity asset store (from 2 different devs) and they both use the same class name in one of their scripts and as soon as i import the second asset i get a massage that the first asset script is trying to convert something like aaaaa.aaaa.effects to the second asset script which has a class named effects deleting the second asset fixes the error but i need to use it both of the assets are huge and not created by me and will probably break if i rename them

is there a way to fix the error with no renaming (i have no problem buying a third asset that will fix this issue(will the asset odin serialize be able to fix it?))
this is my first game and i am trying to build something good using a lot of asset store assets

The assets should be in their own namespace. What class is causing the conflict? Maybe they both include another third party class such as something from Unity assets. If not, I would contact the authors and ask them to move their code to its own unique namespace.

i am new to programming games is there any tool on the asset store that can move the code to its own namespace automatically. the class is called effects its part of an ai integretion to a charecter controller this is the first error of 4
Designer\Integrations\UltimateCharacterController\Scripts\Tasks\StartStopEffect.cs(35,28): error CS0029: Cannot implicitly convert type ‘Opsive.UltimateCharacterController.Character.Effects.Effect’ to ‘Effect’
i like the opsive addons and i don’t want to bother the developer and the other tool is ABC - Ability & Combat Toolkit
i wanted to use abc as an ability hotbar for opsive. i don’t want to bother the devs and i will probably run into a similar problem again

i had another problem between the rpg animation pack from i believe explosive for 100$ and another asset i resolved it by deleting the rpg animations pack custom character animation controller script

is there any way of using something from the asset store to fix this issue
i want to make a game using mostly assets from the asset store and would like to use an asset to fix this issue

fixed the issue myself by manually adding a namespace abc_effects_code to abc_effects class and added a using abc_effects_code to every other abc script/class

My understanding is that every unique class name creates a unique namespace. That class name must be the same as the .cs file.

In case it’s of any use, I made a free asset that automatically adds namespaces to your scripts when you create them, based on the directory path where you create your script. So, if you create a new script in “Assets/Code/Controllers/ABC”, the script would automatically be created with a namespace of “CompanyName.ProjectName.Code.Controllers.ABC”. I find this very useful for avoiding class name conflicts either among my own code, or between my code and some 3rd party libraries I might be using.

Anyway, it’s free, in case you think it’s of any use to you in your project:

1 Like

This is awesome @dgoyette ! I’ve been using a Visual Studio extension that does something similar, but it wouldn’t put companyname/project name in the namespace and I would have to rename the namespaces. This one looks much better for Unity! I’m going to give it a spin!

1 Like

Feel free to message me directly if there are any issues, or you have a feature request.

It appears that the answer to this question is that there is no simple way to import multiple assets that use the same C# scripts. If I uncheck the duplicated scripts from subsequent imports, then those imports lose their components. “Missing script” errors appear on gameobjects/prefabs that depended on those unchecked scripts. I have to hand connect all the missing components to the first imported script? Any smart people know how to skip all this? dgoyette’s asset doesn’t look like it works on imported asset packages.

If the specifics matter, the asset store packages are 48 Particle Effect Pack, and Particle Ingredient Pack both using csDestroyEffect, csMouseOrbit, etc. I’ve had to just hand fix this so far and it beats building all the cool effects on my own, but it’s still really wacky how this is a problem. Thanks for any help!

The typical way this is a problem, while certainly whacky, can actually be fully explained:

  • project A contains a bunch of files, some of them part of the FOO collection of shared files

  • project B contains a bunch of files, some of them part of the FOO collection of shared files

  • you import project A and project B

  • Unity first sees duplicate metafile GUID numbers and goes WHOA! Gotta renumber one of these, and arbitrarily chooses one side to renumber. (It might not be arbitrary, but for us it is because we don’t know which except to catch the yellow warnings that show ONCE when this process happens, and following each individual file).

  • Unity then tries to compile… WHOA! duplicate classes… ERROR!!

  • You go and delete one of the FOO collections… you have a 50/50 chance of deleting the one that Unity did NOT renumber

  • FURTHER complicating an already complex process, it is entirely possible that when Unity dedupes and renumbers the GUIDs, it might actually take some files from project A FOO and some from project B FOO… :slight_smile:

And then your project explodes.

The only guard for this is for the asset maker to duplicate the FOO files himself, delete the original FOO files, then reconnect ALL the things they use. Not gonna likely happen. :slight_smile:

Since it has been 3 years and the conversation is still relevant, I have to assume no one has found a way to fiddle with the import process, for example, adding a merge feature that can replace this script with that script. Apparently it’s not usually an issue since no one else is complaining. ¯_ (ツ)_/¯

The most infuriating part is that it USED to work perfectly under the legacy .unitypackage system.

Go try it yourself: export two separate packages that share some files.

Once you import the first one, subsequent imports of the second one will show those shared files as already present and unchanged so it does nothing to them.

This is just yet another way that the Package Mangler product managers failed to identify the common use cases they were replacing with their new toy.

No, I’m not a fan of the Package Mangler. It causes me grief literally EVERY SINGLE DAY by reinjecting packages I explicitly removed whenever I upgrade a Unity project, forcing me to re-remove them AGAIN AND AGAIN.