Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Script attached to a prefab in an asset bundle opens script of same name in a different project

Discussion in 'Prefabs' started by Cosmonaut72, Jul 31, 2019.

  1. Cosmonaut72

    Cosmonaut72

    Joined:
    Nov 16, 2017
    Posts:
    7
    Hi,

    I have a Unity project (Project 1) that is used to build asset bundles and store them in a folder for use in Project 2.
    Project 1 has a single prefab in it. This prefab contains a bunch of geometry. It also contains a nested prefab for an object called a 'locator'. This locator has a script on it.
    The locator script in Project 1 is defined having an enum, a public property of this enum and a public string. No methods except for an OnDrawGizmos but I don't think that matters.

    In project 2 which is a different Unity project in a different folder, I also have a script named locator. It has the same variables with the same values, but also a few methods and added variables.
    When I load the asset built in Project 1 into Project 2, it adds the prefab in and the local version (Project 2's) version of Locator.
    I have inspected the .meta file for both of these scripts and they have different guids

    Can somebody explain how this is possible? It seems to me that the asset bundle finds a monobehaviour script of the same name and stores this rather than some kind of id or hash that is relevant to this specific script.
    This is very curious behaviour and possibly very powerful to somebody who wants to utilise it.