Odin fails to draw custom attributes such as BoxGroups and FoldOutGroups after importing FB SDK 9.0.0

Issue #770 open
Eduardo Cardenas-Cruz created an issue

Description

After updating FB SDK from 8.1.0 to 9.0.0 Odin threw MissingMethodException (console log attached below) and custom attributes such as BoxGroups and FoldOutGroups stopped drawing on the inspector.

After some testing, I found that the one file in the FB SDK causing the conflict is Facebook.Unity.dll. Reverting that file to the one used in FB SDK 8.1.0 fixed the issue. Unfortunately FB is depreciating SDKs bellow 9.0 so we need to have the latest.

How to reproduce

  1. On an empty project import FB SDK 9.0.0 https://developers.facebook.com/docs/unity/
  2. Import Odin. There will be a bunch of exceptions on the console (attached below).
  3. Create a C# script and make use of either the [BoxGroup] or [FoldOutGroup] attributes
  4. Attach the script to an empty GameObject, the attributes won’t draw and there will be a bunch of errors in the console (attached below)

Unity Version

2018.4.24f1

Odin Version

3.0.3.0

Operating System

macOS Big Sur 11.0.1

Comments (3)

  1. Tor Esa Vestergaard

    Thanks for the report!

    Looks like the Facebook.Unity.dll assembly contains some invalid attribute decorations on the assembly itself, namely UnityEngine.UnityAPICompatibilityVersionAttribute..ctor(string,string[]) which is not a constructor signature that exists on that attribute in many versions of Unity. This is to my best knowledge an attribute that Unity itself puts on assemblies that it has run the API updater on, so if an assembly was updated by an earlier (or later) version of Unity in which that attribute differs, then the assembly contains broken attribute metadata.

    I’ve switched the relevant portions of Odin’s code to use our common utilities for safe handling of foreign assemblies. This is a new part of the codebase where we’d forgotten to add those protections; broken assemblies being loaded and needing to be worked around/adapted to are a common occurrence in Unity, after all 🙂 In short, Odin is checking the Facebook assembly’s attributes to see if it contains any Odin extension types that Odin needs to find and incorporate, and when Odin tries to load the assembly attributes to have a look, that exception is thrown. With the fix, Odin will simply pass over the Facebook assembly without choking on it.

    I am not sure if Facebook is distributing their assembly in this semi-broken state, or whether the way you imported it caused it to be broken - if it is the former, you should probably report this issue so they know that calling GetCustomAttributes() on their loaded assembly will cause it to throw exceptions.

    My fix will be in the next release of Odin. If you would like to give it a go to verify that it “fixes” the issue (or ignores it, rather), please contact me on Discord and I’ll send you a build.

  2. Eduardo Cardenas-Cruz reporter

    Thank you for looking into this! I was very confused as to why FB SDK would conflict with Odín, so thanks for the explanation 😄

  3. Log in to comment