Search Unity

Sync assetID using different scenes with uNET

Discussion in 'UNet' started by imaewyn, Mar 21, 2017.

  1. imaewyn

    imaewyn

    Joined:
    Apr 23, 2016
    Posts:
    211
    Hello. I'm tryiying to sync prefab between similar scenes in different projects (because they will work on different devices and they plugins conflict to each other. I can't put all plugins in one project), so prefabs have different assetID. Is any way to sync instantiated prefabs with different AssetID? Or may be I can override syncronization wich based on AssetId to my variable?
     
    Last edited: Mar 21, 2017
  2. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    Hmm yeah it sounds like you're trying to solve a problem by creating a problem... although I can't be 100% sure without seeing the code of unet, the assetID is something that appears to be shared over the network and therefore we can assume that it is how unet identifies objects over the network.

    Ultimately, in anything complicated, especially when associated to technology, if something is broken: fix it. Implementing work-arounds is one hell of a bad practice (probably the worst habit that you can get into...) as it will only set you up for problems later on, as you have discovered already. I would suggest to take a closer look at what is causing your plugins to conflict and then:
    • look at either fixing these conflicts yourself or contacting the publishers and letting them know. Publishers are often concerned about their plugins conflicting with others so they are likely to want to solve these types of problems
    • do you really need the plugins? Remember that a lot of the time a "plugin" is just a convenience tool... to basically provide you with a set of functionality that (in theory) you could build yourself. Are there maybe some plugins that you could ditch and implement your own functionality?
    • failing all of the above, if you need a lower-level solution, where you have more control over what the networking does, then you might want to look into using the LLAPI. It's a more difficult foundation to start from, but it gives you full control over your solution allowing you to avoid situations like this. Alternatively, you could use third-party networking solutions such as photon, however there are some drawbacks with this route, mainly the cost involved.
    Hopefully this helps. Good luck with your game!
     
  3. imaewyn

    imaewyn

    Joined:
    Apr 23, 2016
    Posts:
    211
    Thank you for answer. I will looking for other decision. May be you can say how I can exclude some folders or files from builds under different devices. It would be useful for me))
     
  4. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    There are a few different ways to do that:
    • if your plugins exist as dll files, you can select these files within unity (within your project files) and then exclude them from certain platforms. You will see options in the inspector to exclude the library from the platforms that you are currently able to build to. This will result in the dll not being loaded into your assembly, and therefore not being available to your code, if your currently selected build platform is one that you have excluded the dll for.
    • using platform specific directives, as described here: https://docs.unity3d.com/Manual/PlatformDependentCompilation.html you can state that sections of your code (even whole scripts) are to only be compiled on certain platforms. So if your plugins are not dll files, and are scripts that you have access to, you could use this method to exclude the associated code on certain platforms
    • finally, the most complex solution is to modify the assembly/xcode of your project. Unity does this for you automatically, and it is ultimately how unity defines what code is available to you and to the compiler based on your selected platform. You can edit the assembly/xcode yourself if you wish to make further modifications to what goes into the compiler, however this is a pretty advanced topic and I wouldn't recommend doing this unless you know what you are doing...
    Hopefully this helps. Let me know if you have any further questions.
     
  5. imaewyn

    imaewyn

    Joined:
    Apr 23, 2016
    Posts:
    211
    Thank you)) I've deleted undesirable folders before build)) after that imported it once more)