如何确定以前引用的、现在丢失的 MonoBehaviour 脚本的名称?

Duc*_*tro 4 unity-game-engine

我有一个带有警告的 Unity 项目:

The referenced script on this Behaviour is missing! 
Run Code Online (Sandbox Code Playgroud)

我已经确定了哪些游戏对象具有这些错误引用,并且我有一组脚本(cs 文件),我知道其中包括预期的脚本,但是哪些组件实例(及其保存的状态)映射到哪些脚本我无法明显辨别。

有没有办法知道缺少引用的组件最初指向哪些脚本,以便我可以手动将正确的脚本重新分配回组件并保留组件状态?

Jea*_*Luc 6

Make sure in the Editor Settings the Asset Serialization Mode is on “Force Text”.

You could open up your scene (or prefab) file in a text editor and search for the GameObject name with the missing script reference e.g. “TheGameObjectWithTheMissingBehaviour”

you should see something like this (i just copied down the important lines)

--- !u!1 &298606752
GameObject:
  m_Component:
  - 54: {fileID: 1199074165}
  - 114: {fileID: 1199074166}
  m_Name: TheGameObjectWithTheMissingBehaviour
---
Run Code Online (Sandbox Code Playgroud)

below the GameObject there should be a list with at least one MonoBehaviour, which looks like this

--- !u!114 &1199074166
MonoBehaviour:
  m_Enabled: 1
  _myCustomVariableA: 1
  _myCustomVariableB: 2
  _myCustomVariableC: 2
---
Run Code Online (Sandbox Code Playgroud)

you can see in the last lines there are the custom variable i.e. [SerializedField] or public members.

then you could search your project for a script with those custom variable name.