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

Error in UnityEngine.UI.dll used by Managed plug-ins

Discussion in 'Scripting' started by kumamoto10, Jul 12, 2021.

  1. kumamoto10

    kumamoto10

    Joined:
    Jun 25, 2018
    Posts:
    18
    I am creating a Managed plug-ins for use with Unity 2020.
    Using UnityEngine.UI.dll found in Unity2020 will result in a build error.
    Where can I find UnityEngine.UI.dll that doesn't cause a build error?
    The content of the error is
    "Error CS0012: Type'MonoBehaviour'is defined in an unreferenced assembly. You need to add a reference to the assembly'UnityEngine.CoreModule, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null'. "

    In Unity2020, UnityEngine.UI.dll did not exist in the same folder as Unity2019.1.
    (Editor \ Data \ UnityExtensions \ Unity \ GUISystem \ UnityEngine.UI.dll)
    After searching, it was found in the following folder.
    Editor \ Data \ Resources \ PackageManager \ ProjectTemplates \ libcache
    \ Com.unity.template.2d-5.0.0 \ ScriptAssemblies \ UnityEngine.UI.dll
    \ Com.unity.template.3d-5.0.4 \ ScriptAssemblies \ UnityEngine.UI.dll
    \ Com.unity.template.hd-10.5.0 \ ScriptAssemblies \ UnityEngine.UI.dll
    \ Com.unity.template.universal-10.5.0 \ ScriptAssemblies \ UnityEngine.UI.dll
    However, both result in a build error.

    Using the dll in the project folder will result in the same build error.
    ([project name] \ Library \ ScriptAssemblies \ UnityEngine.UI.dll)
     
  2. reij

    reij

    Joined:
    Oct 14, 2018
    Posts:
    4
    Does this only happen for a certain project or does it happen also if you create a new one?
     
  3. kumamoto10

    kumamoto10

    Joined:
    Jun 25, 2018
    Posts:
    18
    Thank you for your reply.
    I tried the following, but I get a build error.
    -Changed the .Net FrameWork version of the project at Unity 2019 to 4.7.1 and added UnityEngine.UI.dll.
    -Create a new project and add UnityEngine.UI.dll.

    For example, if you write the following in the test, it will not cause an error,
    public bool Check (GameObject obj)
    {
    UnityEngine.UI.Graphic com = obj.GetComponent <Graphic> ();
    return (obj);
    }
    If you change the return statement as follows, a build error will occur.
    public bool Check (GameObject obj)
    {
    UnityEngine.UI.Graphic com = obj.GetComponent <Graphic> ();
    return (com);
    }

    When I check UnityEngine.UI.Graphic in the object browser of Visual Studio, it doesn't seem to recognize "MonoBehavior".

     

    Attached Files:

  4. Andres19899

    Andres19899

    Unity Technologies

    Joined:
    Nov 22, 2016
    Posts:
    4
    Hi,

    Sorry to hear you are having issues with the dll,

    Having researched a bit about this, this error message you are getting suggests a compatibility issue with API. It looks like you mentioned you tried updating the net in your project. Did you do it in the player settings?

    .Net framework supports versions that support different libraries, so you may need to use the correct version to use the one you want.

    https://docs.unity3d.com/Manual/overview-of-dot-net-in-unity.html

    https://docs.unity3d.com/2020.3/Documentation/Manual/dotnetProfileAssemblies.html

    Below you will find documentation on using additional class library assemblies and the .Net versions that support said libraries.

    I hope this helps!
     
  5. kumamoto10

    kumamoto10

    Joined:
    Jun 25, 2018
    Posts:
    18
    Thank you for your response.
    I checked what you answered, but I feel that it is a little different from what you asked.
    What I'm hearing is that it's not the Unity project of the application that is causing the error.
    It's happening in a project that creates a custom dll for use in an application.
    This custom dll uses UnityEngine and UnityEngine.UI instructions.
    Therefore, I am trying to refer to and register UnityEngine.dll and UnityEngine.UI.dll in the custom dll project.
    However, when I use UnityEngine.UI.dll provided by Unity, which I know, I get an error.
    At the time of Unity2019.1, I used the dll provided by (Editor \ Data \ UnityExtensions \ Unity \ GUISystem \ UnityEngine.UI.dll).
    However, in 2020.3, the same folder as 2019.1 does not exist.
    Please tell me UnityEngine.UI.dll to prevent error in custom dll project.
    If I don't understand what you're telling me, please point it out.
    thank you.
     
  6. kumamoto10

    kumamoto10

    Joined:
    Jun 25, 2018
    Posts:
    18
    I was taught how to deal with it.
    The dll can be solved by using the one in the following location.
    UnityEngine.dll:
    /[UNITY_EDITOR]/Editor/Data/Managed/UnityEngine/UnityEngine.dll
    UnityEngine.CoreModule.dll:
    / [UNITY_EDITOR] /Editor/Data/Managed/UnityEngine/UnityEngine.CoreModule.dll
    UnityEngine.UI.dll:
    / [PROJECT] /Library/ScriptAssemblies/UnityEngine.UI.dll

    There is a commentary in the documentation.
    https://docs.unity3d.com/Manual/UsingDLL.html