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

Guids of MonoBehaviours in managed plug-ins

Discussion in 'Scripting' started by ALantean, Aug 8, 2022.

  1. ALantean

    ALantean

    Joined:
    Nov 13, 2017
    Posts:
    8
    Hello!

    I'm currently working on creating a managed plug-in for Unity.

    As it is I have some code that is build into a DLL which can be dropped in an Unity project. The documentation regarding this topic has an image of an expanded DLL in a Unity project attached that shows all MonoBehaviours that are part of the DLL [1][2].

    In a regular Unity project, when a MonoBehaviour is dragged onto a GameObject in a scene, it is referenced in the .unity scene file via the guid that is part of the MonoBehaviour's meta file.

    Now when working with a MonoBehaviour that is part of a DLL, we can also drag it onto a GameObject in a scene and in the .unity scene file it is referenced via some guid.

    My question now is, where do the guids for MonoBehaviours in DLLs come from? The meta files, that usually contain that guid, are not part of a DLL.
    I also noticed that the guid of a MonoBehaviour in a regular Unity project differs from the guid of the same MonoBehaviour in a DLL.

    My goal is to get a better understanding for guids of MonoBehaviours in DLLs to avoid breaking references when releasing a new version of my managed plug-in.
    For example with regular non-DLL code, I know that under no circumstances must I change an existing meta file, because that will lead to a new guid and break existing references. I'm looking for dos and don'ts of MonoBehaviour guids, but for managed plug-ins / DLLs.

    Best regards
     
  2. ALantean

    ALantean

    Joined:
    Nov 13, 2017
    Posts:
    8
    I think that I've found the answer I was looking for by realizing that the DLL in the Unity project has a meta file. The guid of this meta file is used to resolve references of MonoBehaviours in the DLL with a .unity scene file.