【问题标题】:Undefined Reference errors when using IL2CPP in Unity在 Unity 中使用 IL2CPP 时出现未定义的参考错误
【发布时间】:2023-03-21 02:36:01
【问题描述】:

在将统一脚本切换到 IL2CPP 脚本后,我的 android 版本出现了很多未定义的参考错误。其中很多都提到了 IOS ARKit 相关的东西。我可以使用 #if !UNITY_IOS 语句将它们从我的 android 构建中删除吗?我可以把这些#if 语句放在哪里?

错误与 Bulk_Assembly-CSharp_8.cpp 相关。我尝试将 @if 语句放入其中以用于特定于平台的构建,但似乎没有任何区别

如果 !UNITY_IOS

public class ARFaceAnchor 
{
    private UnityARFaceAnchorData faceAnchorData;
    private static Dictionary<string, float> blendshapesDictionary;

    public ARFaceAnchor (UnityARFaceAnchorData ufad)
    {
        faceAnchorData = ufad;
        if (blendshapesDictionary == null) {
            blendshapesDictionary = new Dictionary<string, float> ();
        }
    }


    public string identifierStr { get { return faceAnchorData.identifierStr; } }

    public Matrix4x4 transform { 
        get { 
            Matrix4x4 matrix = new Matrix4x4 ();
            matrix.SetColumn (0, faceAnchorData.transform.column0);
            matrix.SetColumn (1, faceAnchorData.transform.column1);
            matrix.SetColumn (2, faceAnchorData.transform.column2);
            matrix.SetColumn (3, faceAnchorData.transform.column3);
            return matrix;
        }
    }


    public ARFaceGeometry faceGeometry { get { return new ARFaceGeometry (faceAnchorData.faceGeometry); } }

    public Dictionary<string, float> blendShapes { get { return GetBlendShapesFromNative(faceAnchorData.blendShapes); } }

    delegate void DictionaryVisitorHandler(IntPtr keyPtr, float value);

    [DllImport("__Internal")]
    private static extern void GetBlendShapesInfo(IntPtr ptrDic, DictionaryVisitorHandler handler);

    Dictionary<string, float> GetBlendShapesFromNative(IntPtr blendShapesPtr)
    {
        blendshapesDictionary.Clear ();
        GetBlendShapesInfo (blendShapesPtr, AddElementToManagedDictionary);
        return blendshapesDictionary;
    }

    [MonoPInvokeCallback(typeof(DictionaryVisitorHandler))]
    static void AddElementToManagedDictionary(IntPtr keyPtr, float value)
    {
        string key = Marshal.PtrToStringAuto(keyPtr);
        blendshapesDictionary.Add(key, value);
    }
}

endif

【问题讨论】:

    标签: il2cpp


    【解决方案1】:

    如果您想从 Android 构建中删除,请使用

    #if !UNITY_ANDROID
           // your code here
    #endif
    

    如果您可以发布与哪一行有关的错误消息,将会更有帮助。

    【讨论】:

    • 感谢 Darren,设法构建 64bit 。但现在相机不能工作了。
    【解决方案2】:

    谢谢达伦,

    我一定是搞错了。所以

    if !UNITY_ANDROID 表示如果不是 Android ?

    【讨论】:

    • 是的,抱歉之前无法添加评论
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-21
    • 1970-01-01
    • 2023-03-14
    • 2020-08-27
    相关资源
    最近更新 更多