Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Dealing with overlapping dependencies?

Discussion in 'General Discussion' started by jpthek9, Dec 24, 2015.

Thread Status:
Not open for further replies.
  1. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    For example, Rotorz's ReorderableList project is a popular asset among Unity tools because it offers a clean, highly functional editor list. Currently, Lockstep Framework uses it for database editing and Photon has it in their codebase as well, so name conflicts crop up when they're in the same project. How would someone go about having both Lockstep Framework and Photon in the same Unity project when they have conflicting assets in them?
     
  2. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    While I have none of those assets, that's very common problem with Camera classes and such too. If the source is C# and the asset developer hasn't created their own namespace just do this:

    namespace rotorzReorderableList
    {

    ...
    }// rotorzReorderableList

    namespace Photon
    {

    ...
    }// Photon

    namespace Lockstep
    {

    ...
    }// Lockstep

    for each source file in the individual asset files. And I do the same for other assets. I try my best to avoid assets that use UnityScript because of the trouble they make. This way there will be Photon.reorderableList members and Lockstep.reorderableList members and if you actually have the ReorderableList asset already imported independently there will be rotorzReorderableList.reorderableList members too and so on.
     
    jpthek9 likes this.
  3. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Thanks for the solution. I'm going to try to find some way to automate this because going through every script'll be hell.
     
  4. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    Actually shouldn't be too hard to automate if you put the script that will add the namespace to add the namespace as Unity imports the assets from the package. No sure exactly when in the import process you'd get a change for your script to add it's own edits however you'll notice that Unity now says it deletes and cleans up the old package when you import a package even when the old package isn't there.
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Isn't this the job reshaper was built for? (It might not be, I haven't used it myself).
     
    landon912 likes this.
  6. KellyThomas

    KellyThomas

    Joined:
    Jul 1, 2012
    Posts:
    39
    If they are using the same version of the dependency then just deleting the duplicate files should fix things.

    If they rely on having different versions then namespacing and importing will give you fine grained control.

    No matter which option you go for send a note to the asset publishers so they can fix things upstream for everyone else.
     
    angrypenguin and Kiwasi like this.
  7. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya I have a major big gripe with Unity on this one. Unity will decline assets that include open source libraries that also happen to be in the asset store if you put them where the original author put them, they want you to put it in with your own stuff. Which is just guaranteed to cause problems for anyone else using the same asset. I don't think the publishing department has any real developers there, or they just don't care. I about went through the roof when I had an asset declined on this issue.
     
  8. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    That's a major hassle to delete the duplicate scripts because when you delete the duplicates any scenes and prefabs that were using the duplicates deleted would break. You would need to determine if they really matched 100% and take note of all the parameter values they are dependent on and then if they were 100% compatible replace the script on the asset or scene you are updating with the duplicate script you are keeping before deleting the original script. It's easier to put them in their own name spaces and not subject yourself to wondering if you've unintentionally introduced bugs.
     
    Ryiah likes this.
  9. KellyThomas

    KellyThomas

    Joined:
    Jul 1, 2012
    Posts:
    39
    Different approaches for different circumstances. Which is easiest would depend of whether interactions are primarily through code or the inspector.

    Ideally everyone uses good namespacing to start with and then we don't have any conflicts to fix.
     
  10. KellyThomas

    KellyThomas

    Joined:
    Jul 1, 2012
    Posts:
    39
    If you had a different version of the library you it would cause all kinds of problems overwriting the existing files.

    If you include your version of the library but store it in your directory and place it under your namespace it is entirely under your control, and won't get in anybody else's way.
     
  11. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    Really, different circumstances doesn't apply here. There are duplicate files and you can't pretend to know what is in those files without thorough inspection and you sure can't pretend to know the developer's future plans for those files. Creating namespaces for those files is the solution.
     
    jpthek9 likes this.
  12. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Except of course you've just bloated out compile times for no good reason whatsoever.

    Name spacing three versions of the same library isn't all roses.
     
  13. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    And in deleting those three redundant files in those libraries for one you've created dependencies that the asset developers using those libraries must heed to keep from breaking your project but they know nothing about your project. You're not saving any substantial compiler time at all really after that code is compiled and cached time stamps are the only things being checked by the build process. So really, deleting those duplicate library files doesn't save you a lot of time and developmentally you paint yourself into a corner. But no it's not all a bed of roses but the alternative is a crown of thorns.
     
  14. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Compile times are usually negligible compared to other time consumers in a Unity project.
     
  15. KellyThomas

    KellyThomas

    Joined:
    Jul 1, 2012
    Posts:
    39
    Isn't this is the case with either option?

    Wouldn't any changes we make to as Assets' scripts be be rolled back when we update an Asset?

    Any changes made after import are going to be fragile. These are just workarounds.

    Any permanent solution is going to involve either 1) freezing at the current (modified) version or 2) an upstream modification to improve the Asset's compatibility.
     
  16. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,328
    Run diff on the different versions, if they're identical, nuke one of them. If they're NOT identical, you have a problem, because one of the assets that relies on shared dependency may also rely on feature that is present only in one specific version of that dependency. You'll probably have to pinpoint key differences and try to guess how important they are. Running two copies of dependency usually undesirable, because IF data between two copies end up being exchanged (Murphy's law says it will), you'll get very hardcore bugs that will be hard to pinpoint. Basically in this case you'll end up maintaining a fork of both projects AND maybe of original dependency too.
     
    angrypenguin and theANMATOR2b like this.
  17. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Clearly, this would be easily resolved if Unity packages have had dependencies system, like packages in Linux distros. This way you wouldn't have to put lib in your project, only put asset store ID where it is and when you download package, it will download dependencies as well, telling you that you have to buy those which are paid but you don't have them.
     
    Kiwasi likes this.
  18. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,328
    In order for linux dependency checking to work, someone needs first to waste lots of time resolving the dependencies and manually specifying what depends on what, because there are(were?) no automatic dependency detection programs.

    In situation where PackageA and PackageB both depend on some SupportLib, BUT they need different version of it, dependency checking will fail miserably, because both versions of SupportLib will expose same symbols to the same namespace, so you'll still have a clash.

    Dealing with this kind of issue is somewhat similar to several iterations of Microsoft's solutions to DLL hell. As far as I know, their latest idea is to install every single version of every single library software needs - based on information from application manifest. That's quite inelegant, but it works.
     
  19. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Of course it'll be up to package's developer to specify dependencies. For older packages, nothing will change. For newer ones, devs would specify what library it needs and then keep it updated so it will work with newest version of said library.
     
  20. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    The solution is really easy with the new Monodevelop tools (not sure if the old one has this). Right click the namespace (i.e. Rotorz.ReorderableList) -> Refactor -> Rename and rename it. Then import Photon and everything works :D.
     
    neginfinity likes this.
  21. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,328
    That would work, but it'll create duplicate functionality.
    Also, I had monodevelop mess up my code during refactoring on some occasion, so that's worth keeping in mind too (but version control can deal with that).
     
  22. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    upload_2016-1-3_17-19-45.png

    In future post in one of the support forums. I'll lock this due to it being caught late, but we will delete any threads typically with >40 posts that could be better in scripting or general support due to a new policy.
     
    angrypenguin and Ryiah like this.
Thread Status:
Not open for further replies.