简体   繁体   中英

How to find out if Unity Facebook SDK is in the project?

I have this code:

m_FacebookVersion =  Facebook.Unity.FacebookSdkVersion.Build;

To get the version of Facebook, but I run into problems when Facebook doesn't exist. I can't find a Define to check against ie #if UNITY_EDITOR.

I also tried

Type myType = Type.GetType("Facebook.Unity.FacebookSdkVersion");

But myType returns null.

Any suggestions?

Thanks

After some digging, I came up with this:

        m_FacebookVersion = "N/A";

        Type myType = Type.GetType("Facebook.Unity.FacebookSdkVersion, Assembly-CSharp");
        if(myType != null)
        {
            PropertyInfo myProp = myType.GetProperty("Build");
            if(myProp != null)
            {
                m_FacebookVersion = (string)myProp.GetValue(null, null);
            }
        }

Seems I needed to look in a different Assembly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM