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
  4. Dismiss Notice

Have 2 versions of an asset in the same project

Discussion in 'Scripting' started by yonson_chappers, Jan 6, 2021.

  1. yonson_chappers

    yonson_chappers

    Joined:
    Feb 6, 2017
    Posts:
    31
    I have a problem whereby I have a unity asset which has had 2 update patches.

    Each update fixes one part of our code, but breaks another. They both make calls to the asset to get a response.

    My query is, is it possible to run both assets in the same project? obvioulsy at the moment one will just overwrite the other. I was thinking perhaps just going through and renaming one of the updates with a different name but this won't be very clean. Does anyone else have any thoughts?

    Many thanks!
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    It's hard to say, because you say it breaks your code, I'm thinking you mean the asset is code based. If it's an image or audio, then you could do that. But code doesn't work that way. If you rename a script and the class, it might work or it might not, depending on what the other bits of code do that might reference that script. And you can't have the two versions of a script with the same name in your project without some way to distinguish them (such as a namespace for example).

    If the asset is being updated, there may also be a reason for it's update that could be important for why it fixes one part even if it breaks another part, which may have just changed something up and you simply have to change your call to the new way of doing it.
     
  3. yonson_chappers

    yonson_chappers

    Joined:
    Feb 6, 2017
    Posts:
    31
    thanks for the reply and I totally understand what you're saying. Basically the asset 'works' but unreliably on various instances, so its not bugs as such but unreliable behaviour. But yes its code based, I'm thinking as you suggest just to take one version and rename everything with a different name etc, and try that out. Was just trying to see if there was something else someone could suggest
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    Are you working in source control for your project? If so then when you update the package you can see exactly what changed in each update. This might let you reason about how to fix it (as long as it is C# and not a DLL), or perhaps identify how it is causing you issues.
     
  5. yonson_chappers

    yonson_chappers

    Joined:
    Feb 6, 2017
    Posts:
    31
    Thanks Kurt, yes to be fair I think if we went through the code (it is c#) we might be able to eventually diagnose the problem however its a huge asset and if the developer themselves isn't fixing it then we are less confident. The proposed parallel solution was to try and basically get a solution working quickly. Thanks for your help though
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    One other way to get both versions into your project at once (but beware of the confusion it might cause!) is to modify the code so that you namespace all the classes.

    Code (csharp):
    1. namespace Version1
    2. {
    3. }
    or

    Code (csharp):
    1. namespace Version2
    2. {
    3. }
    That would require touching all files of both versions though.

    BUT... any prefabs or scene objects will refer to the GUIDs that originally came in the original package, so you'd have a lot of remapping to do in that case.

    Might be better to address the bugs. :)
     
  7. yonson_chappers

    yonson_chappers

    Joined:
    Feb 6, 2017
    Posts:
    31
    thanks Kurt yes I think thats the best solution. Prefab remapping etc is relatively straightforward actually so utimlately we're looking to do whatever will get us over the finish line of getting it working with the least effort. You're right about addressing the bugs but unfortunately as its not our asset its not a trivial task. Thanks for your input though I think this is an excellent solution, much appreciated!