我从昨天开始就面临开发者工具的问题。我使用
我在重构一些东西,开发者工具问我要访问权限。开发者工具访问需要控制另一个进程才能继续调试。请输入你的密码,允许这个...
此后,发生了两件事。
如果启用了开发者工具访问权限 (也试过通过 sudo /usr/sbin/DevToolsSecurity --enable
命令)几乎每次当我在代码中改变一些东西时,Unity都会停止工作(加载轮存在),我无法关闭它的应用程序。我试着使用活动监视器,它不显示任何活动。我只能看到加载轮。
我甚至试过杀死Unity进程,通过 kill unitypid
进程列表中没有这个进程,所以它 "杀死 "了这个进程,但我仍然可以在桌面上看到它,就像之前一样。
检查Unity日志,我可以看到它停止在。
Begin MonoManager ReloadAssembly
custom-attrs.c:1250: (null)
assembly:/Applications/Unity/Hub/Editor/2018.4.17f1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.CoreModule.dll type:UnityException member:(null) signature:<none>
Stacktrace:
Native stacktrace:
0 libmonobdwgc-2.0.dylib 0x00000001460b4976 mono_handle_native_crash + 242
如果开发者工具访问被禁用,应用程序要求我几次启用它。按了几次取消后,Unity就崩溃了,然后关机,并给我发送日志错误的能力,苹果例外。
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
abort() called
我真的不知道该怎么办 我试过更新Rider、Catalina,安装新的Unity版本。
更新:我格式化了磁盘,又安装了Catalina,还是不行。
非常感谢您的帮助!
经过进一步的调查,我发现了以下的重现。
PropertyAttribute
该电话 AssetDatabase.FindAssets("somethingsomething")
的构造函数中。MonoBehaviour
类,以便能够调用构造函数,因为在场景上放置了gameObject),其中包含一个具有上述自定义属性的字段。FormerlySerializedAs
属性到这个字段(例如在重构期间)。这将导致弹出一个窗口,上面有我在问题中提到的信息。
开发工具访问需要控制另一个进程才能继续调试。输入你的密码来允许这个...
例子
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
public class CustomObjectPathAttribute : PropertyAttribute
{
/// <summary>
/// Default constructor.
/// </summary>
public CustomObjectPathAttribute()
{
var guids = AssetDatabase.FindAssets("Resources");
}
}
using UnityEngine.Serialization;
[System.Serializable]
public class TestClass
{
/// <summary>
/// Path to the file.
/// </summary>
[FormerlySerializedAs("pathToFile")]
[CustomObjectPath]
public string pathToFile2 = string.Empty;
}
using System.Collections.Generic;
using UnityEngine;
public class MyBehaviour : MonoBehaviour
{
private List<TestClass> testClasses;
void Start()
{
testClasses = new List<TestClass>();
}
}
附上... MyBehaviour
脚本到场景上放置的gameObject。该问题将在项目重新编译后发生。
使用 AssetDatabase.FindAssets("Resources")
在自定义属性的构造函数中,如果没有使用 FormerlySerializedAs
中的字段的属性。TestClass
.
我已经向Unity QA团队报告了这个错误,他们成功重现了这个问题。这里是Unity问题追踪器的链接。https:/issuetracker.unity3d.comissuescrash-when-using-assetdatabase-dot-findassets-in-a-custom-propertyattribute-and-when-formerlyserializedas-attribute-is-also-used。
在这一点上,我已经无能为力了,除了。
AssetDatabase.FindAssets
在我的propertyconstructor中。